搭建 elasticsearch 7.4.1
- 安装es (一般es集群至少配置三台机器)
[root@node01 ~]# yum localinstall elasticsearch-7.4.1-x86_64.rpm -y
- 修改启动参数
[root@node01 ~]# cd /etc/elasticsearch/
[root@node01 elasticsearch]# cp elasticsearch.yml{,.bak}
[root@node01 elasticsearch]# vim jvm.options
-Xms1g
-Xmx1g
注释 ##-XX:+UseConcMarkSweepGC
改为:-XX:+UseG1GC
- 创建数据跟日志目录并授权
[root@node01 elasticsearch]# mkdir data logs
[root@node01 etc]# chown -R elasticsearch:elasticsearch elasticsearch/
- 主节点配置文件
[root@node01 elasticsearch]# vim elasticsearch.yml
cluster.name: mason-cluster
node.name: master
path.data: /etc/elasticsearch/data
path.logs: /etc/elasticsearch/logs
network.host: 192.168.255.11
http.port:9200
discovery.seed_hosts: ["192.168.255.11:9300", "192.168.255.12:9300"]
cluster.initial_master_nodes: ["master"]
gateway.recover_after_nodes: 2
# 主节点相关配置
node.master: true
node.data: false
node.ingest: false
node.ml: false
cluster.remote.connect: false
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
- 从节点配置文件
[root@node02 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: mason-cluster
node.name: slave01
network.host: 192.168.255.12
http.port: 9200
discovery.seed_hosts: ["192.168.255.11:9300", "192.168.255.12:9300"]
cluster.initial_master_nodes: ["slave01"]
gateway.recover_after_nodes: 2
# 从主节点相关配置
node.master: false
node.data: true
node.ingest: false
node.ml: false
cluster.remote.connect: false
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
- 启动es
[root@node01 etc]#