电影推荐系统-环境搭建(四)

 

第三个安装ElasticSearch-搜索服务器

1)解压压缩包

[root@tjx1 local]# tar -zxvf ./tars/elasticsearch-5.6.2.tar.gz -C ./

2)创建存放日志和数据的目录

[root@tjx1 local]# cd elasticsearch-5.6.2/

[root@tjx1 elasticsearch-5.6.2]# mkdir data

[root@tjx1 elasticsearch-5.6.2]# mkdir logs

2)接下来修改配置文件

[root@tjx1 elasticsearch-5.6.2]# vi config/elasticsearch.yml

17 cluster.name: my-application

23 node.name: tjx1

33 path.data: /usr/local/elasticsearch-5.6.2/data

37 path.logs: /usr/local/elasticsearch-5.6.2/logs

修改内存

43 bootstrap.memory_lock: false

44 bootstrap.system_call_filter: false  (后添加的)

55 network.host: 192.168.212.21

68 discovery.zen.ping.unicast.hosts: ["tjx1"]   (单节点的配不配都行,最好配一下)

3)配置linux系统环境

(参考:http://blog.csdn.net/satiling/article/details/59697916)

都以root用户进行-sudo

(1)编辑limits.conf 添加类似如下内容

 [root@tjx1 elasticsearch-5.6.2]# sudo vi /etc/security/limits.conf

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 4096

* hard nproc 4096

不然会报错:

ERROR: [2] bootstrap checks failed

[1] : max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

(2)进入limits.d目录下修改配置文件。

[root@tjx1 elasticsearch-5.6.2]# cd /etc/security/limits.d/

[root@tjx1 limits.d]# ll

total 4

-rw-r--r--. 1 root root 191 Aug 18  2015 20-nproc.conf

 vi 20-nproc.conf

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 4096

(3)修改配置sysctl.conf

[root@tjx1 limits.d]# sudo vi /etc/sysctl.conf  

添加下面配置:

vm.max_map_count=655360

并执行命令:

[root@tjx1 elasticsearch-5.6.2]# sudo sysctl -p

然后,重新启动elasticsearch,即可启动成功。

5)切换用户(非root)启动ES

新建用户参考:https://www.cnblogs.com/liuxinrong/articles/13550320.html

(注意ES版本号的变换)

启动ES:

[root@tjx1 elasticsearch-5.6.2]# su demouser

[demouser@tjx1 elasticsearch-5.6.2]$ bin/elasticsearch

发现报错:

 

 

 

 这表明缺少JDK ,安装JDK并加上环境变量即可:

这台克隆机有之前写好的JDK环境变量,位置在/opt/module/,所以我直接在此安装的JDK。

6)测试ES

[demouser@tjx1 jdk1.8.0_144]$ curl http://192.168.212.21:9200/

{

  "name" : "tjx1",

  "cluster_name" : "my-application",

  "cluster_uuid" : "MI0473sERDqG7v-99SYkjQ",

  "version" : {

    "number" : "5.6.2",

    "build_hash" : "57e20f3",

    "build_date" : "2017-09-23T13:16:45.703Z",

    "build_snapshot" : false,

    "lucene_version" : "6.6.1"

  },

  "tagline" : "You Know, for Search"

}

这样ES就配置好了

上面输入的是IP并不是主机名,如果输入主机名给出提示:

 

解决-更改主机名映射(Linux上的):

[root@tjx1 ~]# vi /etc/hosts

添加这行:

192.168.212.21 tjx1

这样即使输入tjx1也能测试成功了:

[demouser@tjx1 jdk1.8.0_144]$ curl http://tjx1:9200/

{

  "name" : "tjx1",

  "cluster_name" : "my-application",

  "cluster_uuid" : "MI0473sERDqG7v-99SYkjQ",

  "version" : {

    "number" : "5.6.2",

    "build_hash" : "57e20f3",

    "build_date" : "2017-09-23T13:16:45.703Z",

    "build_snapshot" : false,

    "lucene_version" : "6.6.1"

  },

  "tagline" : "You Know, for Search"

}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3