Elasticsearch 5.x集群安装详细步骤-线上使用环境

838 阅读2分钟

安装

官方安装文档介绍-可以跳转移步

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz
sha1sum elasticsearch-5.6.16.tar.gz 
tar -xzf elasticsearch-5.6.16.tar.gz

cd elasticsearch-5.6.16

设置权限账号

设置ES账号权限:找到ES的安装目录,使用ROOT账户,设置读写ES账户权限

chown -R hjops elasticsearch-5.6.16

安装JDK

yum install java-1.8.0-openjdk-devel.x86_64

新增ES账户

因为ES启动不能使用ROOT账户,需要新建账户,也可以使用已经存在非ROOT 账户

新增用户:

[root@os ~]# groupadd elastic
[root@os ~]# useradd elastic -g elastic

环境系统配置

配置1:使用命令vim /etc/security/limits.conf

在最后添加数据如下:(soft nproc和hard nproc也可以设置成65536) 主要给ES 账户添加权限设置

默认配置是

root soft nofile 65535
root hard nofile 65535

如果搜索加入账户是 hjops账户,需要添加以下

hjops soft nofile 65536
hjops hard nofile 65536
hjops soft memlock unlimited
hjops hard memlock unlimited

或有账户开通*代表所有账户

  • soft nofile 65535
  • hard nofile 65535
  • soft memlock unlimited
  • hard memlock unlimited

配置2:/etc/sysctl.conf

vim /etc/sysctl.conf 在最后添加一行数据如下:

vm.swappiness = 0
vm.max_map_count=262144

然后刷新命令生效

sysctl -p

es.yml配置:

cluster.name: hujiang.qa.5.6
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.38.100","192.168.38.133"]
network.host: 192.168.38.133
transport.tcp.port: 10293
http.port: 10292
node.name: node133
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
reindex.remote.whitelist: ["192.168.36.163:10292","192.168.36.162:10292"]

ES内存设置

vim elasticsearch-5.6.16/config/jvm.options

可以调整ES堆栈内容大小,设置规则集群内存大小50%,不能超过32G,可以设置31G,有钱任性也不行,超过32G会导致集群启动不了,不信自己试试

-Xms2g
-Xmx2g

分词器安装

IK分词器官方介绍,可以参考官方直接安装不同版本

github.com/medcl/elast…

拼音分词官方地址 github.com/medcl/elast…

本次安装方式直接命令:

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.16/elasticsearch-analysis-ik-5.6.16.zip

安装完毕直接后台启动

进入elasticsearch-5.6.16 根目录下执行命令

./bin/elasticsearch -d

浏览器访问地址即可看到安装效果

http://127.0.0.1:10292/