Elasticsearch集群安装部署

1.前提:安装好jdk

2.下载安装包:

3.上传到linux

4.解压

5.新建data,logs文件夹

1
2
3
4
5
cd /opt/module/elasticsearch-5.6.2

mkdir data

mkdir logs

新建目录

6.修改配置文件(root用户)三台机器都需要改

(1).修改elasticsearch.yml文件
1
2
vi /opt/module/elasticsearch-5.6.2/conf/elasticsearch.yml

修改内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# ---------------------------------- Cluster -------------------------------------
cluster.name: my-application
# ------------------------------------ Node --------------------------------------
node.name: JBS1
# ----------------------------------- Paths ---------------------------------------
path.data: /opt/module/elasticsearch-5.6.2/data
path.logs: /opt/module/elasticsearch-5.6.2/logs
# ----------------------------------- Memory -----------------------------------
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# ---------------------------------- Network ------------------------------------
network.host: 192.168.127.121
# --------------------------------- Discovery ------------------------------------
discovery.zen.ping.unicast.hosts: ["bigdata121"]

http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true

说明:

  • cluster.name :如果要配置集群需要两个节点上的 elasticsearch 配置的 cluster.name 相同,都启动可以自动组成集群,这里如果不改 cluster.name 则默认是 cluster.name=my-application。
  • nodename 随意取但是集群内的各节点不能相同
  • node.master:设置为主节点
  • node.data:

elasticsearch.yml

elasticsearch.yml

(2).修改limits.conf文件
1
2
3
4
5
6
7
8
vi /etc/security/limits.conf

//在文件末尾添加如下内容

* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096

limits.conf

(3).修改limits.d文件
1
2
3
4
5
6
vi /etc/security/limits.d/20-nproc.conf

//修改内容如下
//* soft nproc 1024
//改为
* soft nproc 4096

20-nproc.conf

(4).修改配置sysctl.conf
1
2
3
4
vi /etc/sysctl.conf

//添加内容
vm.max_map_count=655360

sysctl.conf

5.新建linux用户:es不能以root用户启动

1
2
3
4
5
6
7
8
9
10
11
useradd kai

passwd kai
输入密码


cd /opt/module/elasticsearch-5.6.2 //进入的elasticsearch目录

chown -R kai:users * //修改权限

su kai //切换到kai用户,启动es

新建用户

6.将elasticsearch发送到bigdata122,bigdata123

1
2
3
4
cd /opt/module
scp -r elasticsearch-5.6.2/ bigdata122:/opt/module

scp -r elasticsearch-5.6.2/ bigdata123:/opt/module

7.再在bigdata122,bigdata123中修改elasticsearch.yml

1
2
3
4
5
6
7
# ------------------------------------ Node --------------------------------------
node.name: JBS2
# ---------------------------------- Network ------------------------------------
network.host: 192.168.127.122 //bigdata123改为:192.168.127.123

node.master: false
node.data: true

其实和单节点安装差不多,只是elasticsearch.yml文件有细微不同

image.png

image.png

8.再在bigdata122,bigdata123中修改linux配置文件,和bigdata121一样,以及新建用户

9.重启bigdata121,bigdata122,bigdata123,因为修改linux配置文件后需要重启后才生效

10.启动ES集群:

(1)切换用户:
1
su kai
(2)先启动bigdata121,再启动bigdata122,bigdata123

bigdata121

1
2
3
cd /opt/module/elasticsearch-6.1.1/

bin/elasticsearch

bigdata122

1
2
3
cd /opt/module/elasticsearch-6.1.1/

bin/elasticsearch

bigdata123

1
2
3
cd /opt/module/elasticsearch-6.1.1/

bin/elasticsearch

11.集群安装参照:

【链接】手把手教你搭建一个Elasticsearch集群
https://cloud.tencent.com/developer/article/1189282

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2015-2021 Movle
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信