elasticsearch-5.6.16.deb   elasticsearch-5.6.16.rpm   elasticsearch-5.6.16.tar.gz   elasticsearch-5.6.16.zip  
elasticsearch-6.8.2.deb   elasticsearch-6.8.2.rpm   elasticsearch-6.8.2.tar.gz   elasticsearch-6.8.2.zip 
elasticsearch-7.2.0-amd64.deb   elasticsearch-7.2.0-darwin-x86_64.tar.gz   elasticsearch-7.2.0-linux-x86_64.tar.gz   elasticsearch-7.2.0-windows-x86_64.zip   elasticsearch-7.2.0-x86_64.rpm 
elasticsearch-7.2.1-amd64.deb   elasticsearch-7.2.1-darwin-x86_64.tar.gz   elasticsearch-7.2.1-linux-x86_64.tar.gz   elasticsearch-7.2.1-windows-x86_64.zip   elasticsearch-7.2.1-x86_64.rpm 
elasticsearch-7.3.0-amd64.deb   elasticsearch-7.3.0-darwin-x86_64.tar.gz   elasticsearch-7.3.0-linux-x86_64.tar.gz   elasticsearch-7.3.0-windows-x86_64.zip   elasticsearch-7.3.0-x86_64.rpm 
elasticsearch-7.3.1-amd64.deb   elasticsearch-7.3.1-darwin-x86_64.tar.gz   elasticsearch-7.3.1-linux-x86_64.tar.gz   elasticsearch-7.3.1-windows-x86_64.zip   elasticsearch-7.3.1-x86_64.rpm   elasticsearch-7.3.1.msi 

1、将安装包复制到服务器/tmp目录下,解压后移动到/usr/local/目录下:

tar -zxvf elasticsearch-7.2.1-linux-x86_64.tar.gz

mv elasticsearch-7.2.1 /usr/local/

2、因为ElasticSearch不能使用root用户启动,所以需要创建一个用户,下面创建一个名为es的用户,并将密码修改为a:
[root@localhost local]# useradd es
[root@localhost local]# passwd es

3、将elasticsearch目录的所有者改为es用户:
[root@localhost local]# chown -R es:es elasticsearch-7.2.1/

4、设置elasticsearch.yml文件:
[root@localhost local]# vim config/elasticsearch.yml

#集群名字

cluster.name: my-application

#节点名

node.name: node-master

#设置为主节点

node.master: true

#设置存储数据

node.data: true

#数据存储路径

path.data: /test/es/data

#日志存储路径

path.logs: /test/es/logs

#网络绑定,这里绑定局域网IP,用来内网访问(也可以绑定0.0.0.0,支持外网访问)

network.host: 0.0.0.0

#端口

http.port: 9200

#内部节点之间沟通端口

transport.tcp.port: 9300

#在集群完全重新启动后阻止初始恢复,直到n个节点启动

gateway.recover_after_nodes: 3

#开启跨域访问

http.cors.enabled: true

#允许所有域名访问

http.cors.allow-origin: "*"

#

discovery.seed_hosts: ["127.0.0.1:9300"]

# 手动指定可以成为 mater 的所有节点的 name 或者 ip,这些配置将会在第一次选举中进行计算

cluster.initial_master_nodes: ["127.0.0.1"]

5、创建数据存储目录和日志存储目录,并将所有者修改为es用户:
[root@localhost local]# mkdir -p /test/es/data
[root@localhost local]# mkdir -p /test/es/logs
[root@localhost local]# chown -R es:es /test/es/logs
[root@localhost local]# chown -R es:es /test/es/data

6、切换至es用户,启动elasticsearch:
[root@localhost local]# su es
[es@localhost elasticsearch-7.2.1]# ./bin/elasticsearch

7、成功启动ElasticSearch后,浏览器输入 http://100.70.10.128:9200:显示如下内容:
{"name": "master","cluster_name": "my-application","cluster_uuid": "_na_","version": {"number": "7.2.1","build_flavor": "default","build_type": "tar","build_hash": "fe6cb20","build_date": "2019-07-24T17:58:29.979462Z","build_snapshot": false,"lucene_version": "8.0.0","minimum_wire_compatibility_version": "6.8.0","minimum_index_compatibility_version": "6.0.0-beta1"},"tagline": "You Know, for Search"}


参考elasticsearch.yml,下面是实际设置:
cluster.name: my-application
node.name: master
node.master: true
node.data: true
path.data: /test/es/data
path.logs: /test/es/logs
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
gateway.recover_after_nodes: 3
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["127.0.0.1:9300"]
cluster.initial_master_nodes: ["127.0.0.1"]


注意:非本机访问需要关闭防火墙,或者开放端口:
1、输入开放端口命令:firewall-cmd --zone=public --add-port=9200/tcp --permanent
2、输入重载防火墙命令:firewall-cmd --reload