elasticsearch 7.0 集群搭建

elastic search 7.0.0 集群搭建

step0: 简介

环境: centos 7.x

      jdk1.8+

机器:

node0 172.16.2.240 9200

node1 172.16.2.241 9200

node2 172.16.2.242 9200

 

关闭防火墙

 

step1:下载安装包

下载安装包:elasticsearch-7.0.0-linux-x86_64.tar.gz

( https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz)

解压到 /usr/local/elasticsearch-7.0.0

step2初始化账号

 

创建启动es的账号及组(每个机器执行)

         groupadd elastic

         useradd -g elastic elasticsearch

         设置密码:

         passwd elasticsearch elasticsearch

        

         修改 /etc/sudoers文件,加入该账号

         chmod 777  sudoers   (note: sudoers 只有只读权限,先授权)

         vi  sudoers,在 "root    ALL=(ALL)       ALL"  下新增一行: "elasticsearch    ALL=(ALL)  ALL"

     chmod 440  sudoers  恢复到最初的权限

        

         将 /usr/local/elasticsearch-7.0.0 授权给 elasticsearch用户:

         chown  -R elasticsearch.elastic /usr/local/elasticsearch-7.0.0

step 3 修改配置文件 (每个实例都需要修改)

打开 elasticsearch.yml配置文件,修改以下配置项:

   cluster.name: dev-es-cluister  // 集群名

   ode.name: node-1               //节点名称(每个节点的name)

   path.data: /var/data/es        //数据文件存放路径

   path.logs: /var/log/es         // 日志文件存放路径

   bootstrap.memory_lock: true

   network.host: 0.0.0.0          //监听网段

   http.port: 9200                // http 暴露端口

   discovery.seed_hosts: ["172.16.2.240","172.16.2.241","172.16.2.242"]   // 配置集群机器

   cluster.initial_master_nodes: ["node-1","node-2","node-0"]

   使用 header插件时需要新增以下两个参数:

   http.cors.enabled: true

   http.cors.allow-origin: "*"

 

将目录/var/data/es 和/var/log/es授权给账户elasticsearch

chown   –R elasticsearch.elastic   /var/data/es

chown   –R elasticsearch.elastic   /var/log/es

 

step4 修改系统配置(每个机器)

  1. vim /etc/security/limits.conf

 

新增以下4行:

* soft nofile 65536
* hard nofile 131072
ela soft memlock unlimited
ela hard memlock unlimited

 

2. vim /etc/sysctl.conf

新增:

vm.max_map_count = 655360

执行 sysctl –p

 

 

##以上都在 root下操作

Step5  启动(每个机器)

 

切换账号: su elasticsearch

进入 /usr/local/elasticsearch-7.0.0 下的bin 目录:

启动:./ elasticsearch –d          (-d 后台启动)

 

---------------------------------------------------------------------------------------------------------------------------------

附:

es 集群原理介绍:

https://segmentfault.com/a/1190000015256970?utm_source=tag-newest

单机es搭建参考:

https://www.linuxidc.com/Linux/2018-08/153718.htm

配置文件参考: elasticsearch.yml

 

 

猜你喜欢

转载自blog.csdn.net/qq_33498504/article/details/89515596