docker搭建Elasticsearch集群
注意:spring-boot-starter-data-elasticsearch必须为集群方式连接,否则情况下会报一下错误None of the configured nodes are available我这里虚拟机的ip是:192.168.128.130建好文件夹cd /usr/localmkdir -p es/configcd esmkdir data1mk...
注意:spring-boot-starter-data-elasticsearch必须为集群方式连接,否则情况下会报一下错误None of the configured nodes are available
我这里虚拟机的ip是:192.168.128.130
建好文件夹
cd /usr/local
mkdir -p es/config
cd es
mkdir data1
mkdir data2
firewall-cmd --add-port=9300/tcp
firewall-cmd --add-port=9301/tcp
mkdir plugins1
mkdir plugins2
在es/config分别新建es1.yml、es2.yml配置文件
cd config
vi es1.yml
es1.yml
#集群名称
cluster.name: elasticsearch-cluster
# 节点名称
node.name: es-node1
# 设置绑定的ip地址,可以使ipv4或者ipv6
# 绑定这台机器的任何一个ip
network.bind_host: 0.0.0.0
# 设置其他节点和该节点交互的ip地址,如果不设置它会自动判断,值必须是个真是的ip地址
network.publish_host: 192.168.128.130
# 设置对外服务的http端口,默认为9200
http.port: 9200
# 设置节点之间的tcp端口,默认是9300
transport.tcp.port: 9300
# 是否允许跨域REST请求
http.cors.enabled: true
# 允许REST请求来自何处
http.cors.allow-origin: "*"
# 节点角色设置
node.master: true
node.data: true
# 集群的节点列表
discovery.zen.ping.unicast.hosts: ["192.168.128.130:9300","192.168.128.130:9301"]
# 集群中一直正常运行的,有成为master节点资格的最少节点数,默认为1
# (total number of master-eligible nodes / 2 + 1)
discovery.zen.minimum_master_nodes: 1
es2.yml
#集群名称
cluster.name: elasticsearch-cluster
# 节点名称
node.name: es-node2
# 设置绑定的ip地址,可以使ipv4或者ipv6
# 绑定这台机器的任何一个ip
network.bind_host: 0.0.0.0
# 设置其他节点和该节点交互的ip地址,如果不设置它会自动判断,值必须是个真是的ip地址
network.publish_host: 192.168.128.130
# 设置对外服务的http端口,默认为9200
http.port: 9201
# 设置节点之间的tcp端口,默认是9300
transport.tcp.port: 9301
# 是否允许跨域REST请求
http.cors.enabled: true
# 允许REST请求来自何处
http.cors.allow-origin: "*"
# 节点角色设置
node.master: true
node.data: true
# 集群的节点列表
discovery.zen.ping.unicast.hosts: ["192.168.128.130:9300","192.168.128.130:9301"]
# 集群中一直正常运行的,有成为master节点资格的最少节点数,默认为1
# (total number of master-eligible nodes / 2 + 1)
discovery.zen.minimum_master_nodes: 1
启动容器1
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d -p 9200:9200 -p 9300:9300 -p 5601:5601 -v /usr/local/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/es/plugins1:/usr/share/elasticsearch/plugins -v /usr/local/es/data1:/usr/share/elasticsearch/data --name ES01 elasticsearch
启动容器2
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d -p 9201:9201 -p 9301:9301 -v /usr/local/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/es/plugins2:/usr/share/elasticsearch/plugins -v /usr/local/es/data2:/usr/share/elasticsearch/data --name ES02 elasticsearch
启动报错:
ERROR:[1] bootstrap checks failed[1]:
maxvirtual memory areas vm.max_map_count [65530] istoo low, increase to at least [262144]
(1)切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
(2)添加下面配置
vm.max_map_count=262144
(3)并执行命令
sysctl -p
(4)重新启动elasticsearch,查看vm.max_map_count是否设置成功:
cat /proc/sys/vm/max_map_count
测试集群效果
http://192.168.128.130:9200/_cat/nodes?pretty
Kiaba连接ES集群
docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana --network=container:ES01 kibana
更多推荐
所有评论(0)