前置条件
下载
[root@es es]
[root@es es]
总用量 338668
-rw-r--r--. 1 root root 346793931 5月 20 2019 elasticsearch-7.1.0-linux-x86_64.tar.gz
[root@es es]
[root@es es]
总用量 338668
drwxr-xr-x. 9 root root 154 5月 16 2019 elasticsearch-7.1.0
-rw-r--r--. 1 root root 346793931 5月 20 2019 elasticsearch-7.1.0-linux-x86_64.tar.gz
[root@es es]
[root@es local]
总用量 480
drwxr-xr-x. 2 root root 4096 5月 16 2019 bin
drwxr-xr-x. 2 root root 148 5月 16 2019 config
drwxr-xr-x. 8 root root 96 5月 16 2019 jdk
drwxr-xr-x. 3 root root 4096 5月 16 2019 lib
-rw-r--r--. 1 root root 13675 5月 16 2019 LICENSE.txt
drwxr-xr-x. 2 root root 6 5月 16 2019 logs
drwxr-xr-x. 29 root root 4096 5月 16 2019 modules
-rw-r--r--. 1 root root 447478 5月 16 2019 NOTICE.txt
drwxr-xr-x. 2 root root 6 5月 16 2019 plugins
-rw-r--r--. 1 root root 8478 5月 16 2019 README.textile
服务配置
- es无法以root用户启动,需要新增elasticsearch用户并修改目录权限为elasticsearch
添加账户
[root@es elasticsearch-7.1.0]
[root@es elasticsearch-7.1.0]
uid=997(elasticsearch) gid=995(elasticsearch) 组=995(elasticsearch)
[root@es local]
[root@es local]
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 10 elasticsearch root 166 5月 4 22:32 elasticsearch-7.1.0
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 12月 11 12:16 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
修改配置
[root@es es]
vm.max_map_count=262144
[root@es es]
* - nofile 65536
* - nproc 4096
[root@node01 elasticsearch-7.1.0]
cluster.name: zangh-es-cluster
node.name: node01
network.host: 172.16.4.101
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["172.16.4.101:9300","172.16.4.102:9300","172.16.4.103:9300"]
discovery.zen.minimum_master_nodes: 2
启动服务
[root@es elasticsearch-7.1.0]
[root@es elasticsearch-7.1.0]$ curl -X GET '172.16.4.101:9200/_cat/health?v'
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1653646432 10:13:52 zangh-es-cluster green 3 3 0 0 0 0 0 0 - 100.0%
[root@es elasticsearch-7.1.0]$ curl -X GET '172.16.4.101:9200/_cat/nodes?v'
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.16.4.103 11 93 0 0.00 0.06 0.14 mdi * node03
172.16.4.102 8 92 0 0.00 0.06 0.10 mdi - node02
172.16.4.101 8 93 3 0.00 0.07 0.11 mdi - node01
![启动成功截图](https://img-blog.csdnimg.cn/1ad71ae8e14b48ebbade752122441a26.png)
- 默认集群名称为elasticsearch,使用单播网络发现算法
![集群状态截图](https://img-blog.csdnimg.cn/3f5ea98393754f5bb47f418a24a8c773.png)
- 服务脚本