二、Elasticsearch集群安装部署

1. 环境信息

主机名操作系统版本IP地址安装软件
zxw6CentOS 7.3.1611 192.168.126.6elasticsearch-7.4.2

zxw7

CentOS 7.3.1611 192.168.126.7elasticsearch-7.4.2
zxw8CentOS 7.3.1611 192.168.126.8elasticsearch-7.4.2

下载连接

https://download.elasticsearch.org

安装版本选择

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

第一步上传es安装包并安装

[root@zxw6 ~]# ls
anaconda-ks.cfg  elasticsearch-7.4.2-linux-x86_64.tar.gz

[root@zxw6 ~]# tar xf elasticsearch-7.4.2-linux-x86_64.tar.gz
[root@zxw6 ~]# ls
anaconda-ks.cfg elasticsearch-7.4.2 elasticsearch-7.4.2-linux-x86_64.tar.gz

[root@zxw6 ~]# mv elasticsearch-7.4.2 /opt
[root@zxw6 ~]# cd /opt/
elasticsearch-7.4.2/ rh/
[root@zxw6 ~]# cd /opt/elasticsearch-7.4.2/

第二步加入到环境变量

[root@zxw6 config]# vim /etc/profile.d/es.sh

export ES_HOME=/opt/elasticsearch-7.4.2

export PATH=$JAVA_HOME/bin:$ES_HOME/bin:$PATH


[root@zxw6 config]# source /etc/profile.d/es.sh

第三步:创建用户和用户组

[root@zxw7 elasticsearch-7.4.2]# groupadd zxw
[root@zxw7 elasticsearch-7.4.2]# useradd zxw -g zxw 

[root@zxw7 opt]# passwd zxw
[root@zxw7 elasticsearch-7.4.2]# cd ..
[root@zxw7 opt]# ls
elasticsearch  elasticsearch-7.4.2  rh
[root@zxw7 opt]# chown -R zxw:zxw elasticsearch elasticsearch-7.4.2/

第四步优化内核参数 必须写我们创建好的用户

[root@zxw6 config]# vim /root/sysctl.sh


echo "zxw soft nproc 8192" >> /etc/security/limits.conf
echo "zxw hard nproc 16384" >> /etc/security/limits.conf
echo "zxw soft nofile 4096" >> /etc/security/limits.conf 内存大小
echo "zxw hard nofile 65536" >> /etc/security/limits.conf
echo "zxw soft memlock unlimited" >> /etc/security/limits.conf
echo "zxw hard memlock unlimited" >> /etc/security/limits.conf echo "vm.max_map_count=655360" >> /etc/sysctl.conf


[root@zxw7 opt]# vim /etc/security/limits.d/20-nproc.conf

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

zxw soft nproc 4096   #这里把*改成用户
root soft nproc unlimited

[root@zxw6 config]# bash /root/sysctl.sh

[root@zxw6 config]# sysctl -p

vm.max_map_count = 655360

第五步修改配置文件 

[root@zxw6 config]# cat elasticsearch.yml | egrep -v '(^#|^$)'
cluster.name: zxw                       #集群名称每个节点必须相同
node.name: node-zxw6            #每个节点呢名称
node.attr.rack: r1             #属性
path.data: /opt/elasticsearch/lib
path.logs: /opt/elasticsearch/log
network.host: 192.168.126.6        #本机ip
http.port: 9200                开发端口
discovery.seed_hosts: ["192.168.126.6", "192.168.126.7","192.168.126.8"]   #节点ip
cluster.initial_master_nodes: ["2"]                       #脑裂选举主

su zxw
 elasticsearch

启动

12-12 20:57