Elasticsearch5.3.0安装部署

一、Elasticsearch5.3.0安装

1,从Elasticsearch官网下载5.3.0版本安装文件:

https://www.elastic.co/downloads/past-releases/elasticsearch-5-3-0

2,使用rz –e命令上传至服务器/export/servers,进行解压

3,修改elasticsearch配置文件:/elasticsearch-5.3.0/config/elasticsearch.yml

添加如下配置:

cluster.name: elasticsearch

node.master: true
node.data: true
node.name: node-1

#path.data: /path/to/data
#path.logs: /path/to/logs

network.host: 192.168.171.124
http.port: 9401
transport.tcp.port: 9501

# allow origin 允许head跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"

#disable auto create index
action.auto_create_index: false

#disable swap
bootstrap.memory_lock: true


discovery.zen.ping.unicast.hosts: ["192.168.171.124:9501","192.168.171.125:9501","192.168.178.126:9501"]
discovery.zen.fd.ping_interval: 10s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6

cluster.routing.allocation.allow_rebalance: indices_all_active
cluster.routing.allocation.disk.watermark.high: 10gb
cluster.routing.allocation.disk.watermark.low: 20gb
cluster.routing.allocation.same_shard.host: true
cluster.routing.rebalance.enable: all

script.search: true
script.stored: true
script.inline: true
script.engine.painless.inline.aggs: true
script.legacy.default_lang: painless

thread_pool.bulk.queue_size: 500

4,修改elasticsearch启动内存

vi /elasticsearch/config/jvm.options

-Xms31g

-Xmx31g

5,启动elasticsearch

cd  /elasticsearch-5.3.0/bin

./elasticsearch  -d

 

问题记录:

(1)Please pass JVM parameters via ES_JAVA_OPTS instead

解决方案:

vi bin/elasticsearch 
添加如下配置项: 
JAVA_HOME="/export/servers/jdk1.8.0_60" 
JAVA_OPTS=""

JAVA_OPTS配置为空,是为了不受系统配置的环境变量的影响

(2)ERROR: bootstrap checks failed

memory locking requested for elasticsearch process but memory is not locked

解决方案: 
切换到root用户,编辑limits.conf配置文件: 
sudo vim /etc/security/limits.conf

添加如下内容: 
admin soft memlock unlimited 
admin hard memlock unlimited 
备注:admin 为用户名称

(3)failed to send join request to master [{node-1}{NwwQ0RYaTkiOGa7WtHDOgg}{XbHDVxCnS-KFaf0WagFcFg}{192.168.171.124}{192.168.171.124:9501}], reason [RemoteTransportException[[node-1][192.168.171.124:9501][internal:discovery/zen/join]]; nested: NotMasterException[Node [{node-1}{NwwQ0RYaTkiOGa7WtHDOgg}{XbHDVxCnS-KFaf0WagFcFg}{192.168.171.124}{192.168.171.124:9501}] not master for join request]; ]

解决方案:

如果node2是拷贝的node1的文件夹,则需要将data文件夹下内容清空

(4)bootstrap checks failed

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

解决方案:

vi /etc/sysctl.conf 添加如下:

vm.max_map_count=262144

保存后执行:sysctl -p

查看是否生效:sysctl -a | grep vm.max_map_count

(5)

ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

原因:
这是在因为Centos6不支持SecComp,而ES5.3.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

(6)

ERROR: bootstrap checks failed 
memory locking requested for elasticsearch process but memory is not locked

原因:

ElasticSearch5.3.3 在CentOS 7.x以上版本中,默认配置bootstrap.memory_lock: true,但是系统又锁定内存失败。

解决:

 a,root权限执行ulimit -l unlimited,告诉操作系统可以无限制分配内存给一个进程

b,配置/etc/security/limits.conf,增加下面两行到文件末尾
admin soft memlock unlimited
admin hard memlock unlimited

二、Elasticsearch5.3.0插件安装

1, analysis-ik插件安装(必须)

(1)下载elasticsearch-analysis-ik-5.3.0.zip

https://github.com/medcl/elasticsearch-analysis-ik/tree/v5.3.0

(2)解压后打包

cd elasticsearch-analysis-ik-5.3.0

mvn clean package

(3)拷贝生成的target/releases/elasticsearch-analysis-ik-5.3.0.zip至elasticsearch-5.3.0/plugins/ik目录(无该目录则自己新建)

解压elasticsearch-5.3.0.zip,删除elasticsearch-5.3.0.zip

启动Elasticsearch集群后,若出现loaded plug in [analysis-ik]

即为安装成功

2, pinyin插件安装

(1)下载elasticsearch-analysis-pinyin-5.x.zip

https://github.com/medcl/elasticsearch-analysis-pinyin/tree/5.x

(2)解压后打包

cd elasticsearch-analysis-pinyin-5.3.x

mvn clean package

(3)拷贝生成的target/releases/elasticsearch-analysis-pinyin-5.3.x.zip至elasticsearch-5.3.0/plugins/pinyin目录(无该目录则自己新建)

解压elasticsearch-analysis-pinyin-5.3.x.zip,删除elasticsearch-analysis-pinyin-5.3.x.zip

启动Elasticsearch集群后,若出现loaded plug in [pinyin]

即为安装成功

3,head插件安装

head插件是个nodejs应用,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)

1)、安装Head

a、https://github.com/mobz/elasticsearch-head 下载zip安装包解压
cd elasticsearch-head 
npm install 
注:如果出现下面问题: 
npm WARN [email protected] license should be a valid SPDX license expression 
原因:spdx license,开源软件或者其他合作类软件的一个使用声明,查看官网https://spdx.org/licenses/,“License Text”里的内容 
解决问题:打开elasticsearch-head目录下的package.json文件,找到license位置,修改为上面这个网站上存在Identifier 
Apache内容修改为Apache-2.0

b、修改elasticsearch-head下Gruntfile.js文件,添加hostname字段 
connect: { 
     server: { 
       options: { 
          hostname: ‘192.168.171.124’, 
          port: 9100, 
          base: ‘.’, 
          keepalive: true 
        } 
     } 

修改head的连接地址: 

 cd elasticsearch-head/_site

vi app.js
this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://localhost:9200“; 
把localhost修改成你es的服务器地址,如: 
this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://192.168.171.124:9401“;

c、启停命令:

npm run start

后台启动:nohup npm run start &

浏览器打开:http://localhost:9100/

停止:

lsof -i:9100

kill -9 pid

2)、安装node

去官网下载nodejs,https://nodejs.org/en/download/ 
tar -zxvf node-v6.9.2-Linux-x64.tar.gz

配置下环境变量,编辑/etc/profile,添加 

export NODE_HOME=/export/servers/node-v6.11.1-linux-x64

export PATH=$PATH:NODE_HOME/bin

保存之后执行: 
source /etc/profile

测试一下node是否生效: 
echo $NODE_HOME 
node -v 
npm -v

4、bigdesk监控插件

Bigdesk为Elastic集群提供动态的图表与统计数据。

(1)下载bigdesk-master.zip包

https://github.com/hlstudio/bigdesk

或者 

git clone https://github.com/hlstudio/bigdesk

(2) 修改连接配置:

vi bigdesk/_site/js/bigdeskApp.js

endpoint: getSearchUrlVar("endpoint") || "http://192.168.171.124:9401"

(3) 

cd bigdesk/_site/ 

python -m http.server 8000

python3版本以下使用:

python -m  SimpleHTTPServer 8000

后台启动:

nohup python -m http.server 8000 &

(4) bigdesk访问地址:

http://192.168.171.124:8000

5、数据迁移工具

a、elasticsearch-esm工具(不支持迁移mapping)(不需要)

https://github.com/medcl/esm/releases

下载linux64.tar.gz 上传至esm文件夹

命令:
./bin/esm  -s http://192.168.1.x:9200   -d http://192.168.1.y:9200 -x index_name  -w=5 -b=10 -c 10000

b、elasticsearch-dump工具(支持兼容的mapping)

1) yum install epel-release  

2) yum install nodejs  

3) yum install npm  

4) npm install elasticdump  

5) cd node_modules/elasticdump/bin 后便可以执行操作。

命令:

拷贝analyzer如分词

 ./elasticdump --input=http://192.168.171.124:19200/40 --output=http://192.168.171.124:9401/40 --type=analyzer

拷贝映射

./elasticdump --input=http://192.168.171.124:19200/40 --output=http://192.168.171.124:9401/40 --type=mapping

 拷贝数据

./elasticdump --input=http://192.168.171.124:19200/40 --output=http://192.168.171.124:9401/40  --type=data

你可能感兴趣的:(Elasticsearch5.3.0安装部署)