将tar.gz安装包解压三份,修改配置参数vi config/elasticsearch.yml
master节点 elasticsearch.yml
cluster.initial_master_nodes: ["node1"]
cluster.name: per_es_cluster
node.name: node1
node.master: true
node.attr.rack: r1
node.max_local_storage_nodes: 3 #这个配置限制了单节点上可以开启的ES存储实例的个数,我们需要开多个实例,因此需要把这个配置写到配置文件中,并为这个配置赋值为2或者更高
network.host: 10.4.56.105
http.port: 9200
transport.tcp.port: 9301
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"
data节点1 elasticsearch.yml
cluster.name: per_es_cluster
node.name: node2
node.master: false
node.attr.rack: r1
node.max_local_storage_nodes: 3
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 10.4.56.105
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["10.4.56.105:9301"] #候选主节点地址
data节点2 elasticsearch.yml
cluster.name: ictr_ElasticSearch
#换个节点名字
node.name: node3
node.master: false
node.attr.rack: r1
node.max_local_storage_nodes: 3
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 10.4.56.105
http.port: 9203
transport.tcp.port: 9303
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["10.4.56.105:9301"]
单机内存不足,启动不了3个节点可以调小内存占用修改jvm.options
将 -Xms512m -Xmx512m,设置为512m
管理es工具:cerebro
https://github.com/lmenezes/cerebro
集群错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
切换到root用户下面
vim /etc/security/limits.conf
在最后添加
- hard nofile 65536
- hard nofile 65536
重新登录用户
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
sysctl -w vm.max_map_count=262144
或
在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
即可永久修改
- tar zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz -C elastic
- 复制elastic三份,模仿三个节点es7-1,es7-2,es7-3
- 由于单机伪集群所以调小jvm,修改jvm.options
- 新建es用户,groupadd elsearch,useradd elsearch -g elsearch -p elasticsearch,chown -R elsearch:elsearch ./es7-1 用户目录权限
- ./bin/elasticsearch
- 开放端口,firewall-cmd --permanent --zone=public --add-port=80/tcp,firewall-cmd --reload,firewall-cmd --zone= public --query-port=80/tcp