您的位置:首页 > Web前端 > HTML5

ElasticSearch5.6.3 安装步骤

2017-11-17 11:09 447 查看

环境准备

1.操作系统:CentOS7.3

2.JDK1.8

安装须知: elasticsearch-5.x的版本要求JDK1.8以上,所以安装前,确保每台服务器已经安装JDK1.8及以上版本。

集群准备

elasticsearch-5.6.3.tar.gz

elasticsearch-HQ-master.zip

集群安装

机器安排:

192.168.102.30(默认master node)

192.168.102.31

192.168.102.32

1. 下载elasticsearch(简称:ES)安装包

# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz[/code] 
# tar -zxvf elasticsearch-5.6.3.tar.gz


2. 修改配置文件

cd elasticsearch-5.6.3

vim config/elasticsearch.yml

添加以下配置(以下是192.168.102.30机器上的配置,其他机器对应修改):

shell

cluster.name: elasticsearch    #集群里的每台服务都要一致

node.name: node1    #每台服务器节点都不一样

node.master: true     #是否为master

network.host: 192.168.102.30    #本机ip

http.port: 9200     #本机端口

transport.tcp.port: 9300    #Java client调用

discovery.zen.ping.unicast.hosts: ["192.168.102.30:9300","192.168.102.31:9300","192.168.102.32:9300"]

path.data:  /data/comm_apps/elasticsearch-5.6.3/data

path.logs:   /data/comm_apps/elasticsearch-5.6.3/logs


3. 配置足够内存

# vim /data/comm_apps/elasticsearch-5.6.3/config/jvm.options
-Xms2g
-Xmx2g


4. 配置环境变量

# vim /etc/profile
export ES_HOME=/data/comm_apps/elasticsearch-5.6.3
# source /etc/profile


5.启动elasticsearch

# cd elasticsearch-5.6.3 && /bin/elasticsearch -d


6.验证服务是否启动:

# netstat -tnl | grep 9200
或者
ps -ef | grep elasticsearch


常用插件安装

head插件

目前都只安装在192.168.102.30这台服务器上

检查node环境,查看是否安装命令:node -v

请确保已经安装nodejs6.0版本以上

1. 下载插件包:

# wget https://codeload.github.com/mobz/elasticsearch-head/zip/master[/code] 
解压:

unzip elasticsearch-head-master.zip


2. 安装插件:

# cd elasticsearch-head-master


# npm install


3. ElasticSearch整合elasticsearch-head插件:

# cd elasticsearch-5.6.3


# vim config/elasticsearch.yml


4. 在配置文件的最后加上运行head插件跨域访问rest接口

http.cors.enabled: true


http.cors.allow-origin: "*"


http.cors.allow-credentials: true


5. 启动插件:
npm run start

输出日志:
Started connect web server on http://localhost:9100[/code] 表示启动成功

能成功访问http://localhost:9100



IK分词插件

每台机器都需要安装

以插件形式安装:

# cd elasticsearch-5.6.3


# ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.3/elasticsearch-analysis-ik-5.6.3.zip[/code] 
访问:

http://192.168.102.30:9200/_analyze?analyzer=ik_max_word&text=中华人民共和国&pretty=true




Elastic HQ插件

1. 下载

# wget https://github.com/royrusso/elasticsearch-HQ/archive/master.zip[/code] 

2. 解压

# unzip elasticsearch-HQ-master.zip


3. 安装

# cd elasticsearch-HQ-master


4. 启动

以下二选一:

# python -m SimpleHTTPServer(前台启动)


# nohup python -m SimpleHTTPServer > elasticsearch-HQ.file 2>&1 &(后台启动)


5. 验证是否安装成功

访问http://192.168.102.30:8000/#cluster



问题解决

问题一



解决办法:

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

办法:修改/etc/security/limits.conf文件,添加或修改如下行:

es hard nofile 65536


es soft nofile 65536


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

办法:

原因:最大虚拟内存太小

root用户执行命令:

sysctl -w vm.max_map_count=262144
临时添加

echo "vm.max_map_count=262144" >> /etc/sysctl.conf
永久添加

注意:修改完后都需要重启服务器才能生效

问题二

ES有执行脚本的能力,因安全因素,不能在root用户下运行,强行运行会报如下错误:

org.elasticsearch.bootstrap.StartupException:

java.lang.RuntimeException: can not run elasticsearch as root

解决方案:

shell

groupadd es                                          #增加es组

useradd es -g es -p pwd                      #增加es用户并附加到es组

chown -R es:es elasticsearch-5.6.3      #给目录权限

su es                                  #使用es用户

./bin/elasticsearch -d                 #后台运行es
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息