修改配置
修改elasticsearch目录下 config/elasticsearch.yml文件
找到network和port字段,修改为你的ip和端口即可,重启es
然后发现启动报错
[1]: max file descriptors [65535] for elasticsearch process is too low
[2]: max number of threads [3805] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决错误[1]:
切换到root用户修改
vim /etc/security/limits.conf
在最后面追加下面内容, 其中es是我启动elasticsearch的用户
es hard nofile 65536
es hard nofile 65536
重启虚拟机 reboot (可能没必要)
解决错误[2]
vim /etc/security/limits.conf
末尾增加以下两行,其中es为启动ElasticSearch的用户
es soft nproc 5000
es hard nproc 5000
解决错误[3]
修改配置sysctl.conf
sudo vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
保存退出并执行命令:
sysctl -p
#修改config/elasticsearch.yml下约第23行,放开node.name注释,可更改名称
node.name: master
启动
主从配置
elasticsearch.yml文件主节点配置:
network.host: 192.168.109.11
http.port: 9200
node.name: master
node.master: true
cluster.name: yh-es #集群名称必须一致
discovery.zen.ping.unicast.hosts: ["192.168.109.11"]
从配置
解压一份elasticsearch.tar.gz
修改elasticsearch.yml
network.host: 192.168.109.11
http.port: 9201
node.name: slave1
cluster.name: yh-es #集群名称必须一致
discovery.zen.ping.unicast.hosts: ["192.168.109.11"]
xpack.ml.enabled: false
修改config/jvm.options。将堆内存大小1g改为512m
-Xms512m
-Xmx512m