elasticsearch6.3.2集群安装

版权声明:本文为博主原创文章,转载时请注明出处链接。 https://blog.csdn.net/lk7688535/article/details/81452147

环境

  • ubuntu14.04
  • JDK8
  • elasticsearch6.3.2

安装、配置、启动

1、官网下载tar.gz安装包

https://www.elastic.co/downloads/elasticsearch

2、解压

tar -zxvf es_6.3.2 /usr/server

3、修改配置文件

cd /es_6.3.2/config

vim elasticsearch.yml

不同机器的node.name和network.host不同,其他可相同。

#集群名称
cluster.name: logs_cluster
#节点名称
node.name: node_master
#是否可作为master
node.master: true
#是否可作为datanode
node.data: true
path.data: /usr/server/elasticsearch-6.3.2/node_master/data
path.logs: /usr/server/elasticsearch-6.3.2/node_master/logs
#锁内存,保证jvm不swap
bootstrap.memory_lock: true
network.host: 120.133.17.XXX
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["120.133.17.XXX:9300", "120.133.17.XXX:9300", "120.133.17.XXX:9300"]
#可以作为master的最大数量,集群必须有大于等于这个数量的节点,集群才能正常工作
#默认为1,建议设置为nodenum/2+1
discovery.zen.minimum_master_nodes: 2

4、启动elasticsearch

cd es_6.3.2/bin

./elasticsearch

这里有一些错误和解决办法:

(1)不可以用root用户启动es。

错误信息:

java.lang.RuntimeException: can not runelasticsearch as root

解决:

#增加用户组
sudo groupadd es

#增加用户,并规定所属用户组和密码
sudo useradd es -g es -p es

# 递归更改文件的拥有者
sudo chown -R es:es /usr/server/elasticsearch6.3.2

(2)max_map_count太小。
错误信息:

max virtual memory areas vm.max_map_count [65530] is too low

max_map_count:允许一个进程在VMAs(虚拟内存区域)拥有最大数量。

解决:

sudo vim /etc/sysctl.conf

#增加以下内容:
vm.max_map_count=262144

#保存退出vim后使sysctl.conf生效:
sysctl -p

(3)最大文件数、最大进程数、 最大锁定内存地址空间。

错误信息:

Unable to lock JVM Memory: error=12, reason=Cannot allocate memory

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

memory locking requested for elasticsearch process but memory is not locked

解决:

修改limits.conf配置

sudo vim /etc/security/limits.conf


es soft nofile 65536
es hard nofile 65536
es soft nproc 65536
es hard nproc 65536 
es soft memlock unlimited
es hard memlock unlimited 

PAM配置修改,使上面配置生效

etc/pam.d/login

etc/pam.d/sshd

etc/pam.d/su

#分别去掉注释:
session requiredpam_limits.so

5、启动集群

三台都按上述方法配置好后,执行命令:

cd /elasticsearch/bin
./elasticsearch

通过打印的配置信息察看是否启动成功,成功后退出再后台启动。

./elasticsearch -d

6、查看集群状态

linux命令行:

#查看可以监测的参数
curl localhost:9200/_cat

#查看集群健康信息
curl localhost:9200/_cat/health

浏览器:

#查看集群的每个节点是否启动成功
http://120.133.17.xxx:9200/

#查看集群健康状态
http://120.133.17.xxx:9200/_cat/health?v

#查看每个节点状态
http://120.133.17.xxx/_cat/nodes?v 

猜你喜欢

转载自blog.csdn.net/lk7688535/article/details/81452147