Elasticsearch集群的简单搭建
发表于:2024-11-26 作者:热门IT资讯网编辑
编辑最后更新 2024年11月26日,环境说明:服务器(系统版本 centos7)elasticsearch版本: elasticsearch-6.2.2elasticsearch目录: /home/soft/ 192.168.33.10
环境说明:
服务器(系统版本 centos7)
elasticsearch版本: elasticsearch-6.2.2
elasticsearch目录: /home/soft/
192.168.33.10 master 192.168.33.11 master data 192.168.33.12 master data
一、创建es运行帐号 【三台机器都统一用户为es】
useradd es
passwd es
二、创建数据目录与日志目录【三台机器都一样】
mkdir -p /home/soft/elasticsearch-6.2.2/data/data/ mkdir -p /home/soft/elasticsearch-6.2.2/data/logs/
三、修改目录权限[三台机器都一样]
chown -R es:es /home/soft/elasticsearch-6.2.2
四、修改配置信息
一. 192.168.33.10 配置信息: cluster.name: my-application node.name: node-192-168-33-10 path.data: /home/soft/elasticsearch-6.2.2/esData/data path.logs: /home/soft/elasticsearch-6.2.2/esData/logs bootstrap.memory_lock: false bootstrap.system_call_filter: false network.host: 192.168.33.10 http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.33.10:9300","192.168.33.11:9300","192.168.33.12:9300"] discovery.zen.minimum_master_nodes: 2 gateway.recover_after_nodes: 3 node.master: true node.data: false node.ingest: false search.remote.connect: false二、192.168.33.11 配置信息: cluster.name: my-application **node.name: node-192-168-33-11** path.data: /home/soft/elasticsearch-6.2.2/esData/data/ path.logs: /home/soft/elasticsearch-6.2.2/esData/logs/ bootstrap.memory_lock: false bootstrap.system_call_filter: false **network.host: 192.168.33.11** http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.33.10:9300","192.168.33.11:9300","192.168.33.12:9300"] discovery.zen.minimum_master_nodes: 2 gateway.recover_after_nodes: 3 node.master: true ** node.data: true** node.ingest: false search.remote.connect: false三、192.168.33.12 配置信息 cluster.name: my-application **node.name: node-12** path.data: /home/soft/elasticsearch-6.2.2/esData/data/ path.logs: /home/soft/elasticsearch-6.2.2/esData/logs/ bootstrap.memory_lock: false bootstrap.system_call_filter: false ** network.host: 192.168.33.12** http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.33.10:9300","192.168.33.11:9300","192.168.33.12:9300"] discovery.zen.minimum_master_nodes: 2 gateway.recover_after_nodes: 3 node.master: true node.data: true node.ingest: false search.remote.connect: false四,用es用户的身份启动elasticsearch-6.2.2 [三台机器] ./bin/elasticsearch 启动成功之后,用CURL 请求测试集群是否搭建成功。 curl http://192.168.33.11:9200/_cat/nodes?v
此时,一个简单的集群已经搭建成功,现在是node-12为master节点。
说明:
3台机器的cluster.name值必须一样,node.name值必须不一样。
在启动过程中遇到的问题列表:
解决办法:
vim /etc/security/limits.conf,新加两行:
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
解决办法:
discovery.zen.ping.unicast.hosts配置信息时把端口加上
bootstrap.memory_lock: false
bootstrap.system_call_filter: false3.
解决办法 : su root
vim /etc/security/limits.d/90-nproc.conf- soft nproc 4096 [1024改为4096]
4.
解决办法:
vim /etc/sysctl.conf
添加: vm.max_map_count=655360
sysctl -p
- soft nproc 4096 [1024改为4096]