一、ES搭建
1. 搭建环境
# 1. 服务器
阿里云服务器
# 2. Linux版本
CentOS 7.6.1810
# 3. 安装docker
# 4. 拉取ElasticSearch镜像: 6.7.1版本
docker pull elasticsearch:6.7.1
# 5. 集群环境
3个节点,搭建在同一个服务器上
2. 服务启动配置
2.1 .yml映射文件
- docker中的具体配置文件不好修好,因此在服务器的home目录下创建该文件;
- 文件一: home/es/confi/es1.yml;
- 文件二: home/es/confi/es2.yml;
- 文件三: home/es/confi/es3.yml;
es1.yml
cluster.name: elasticsearch-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 60.205.229.31 # 服务器ip
http.port: 9200 # 前台端口
transport.tcp.port: 9300 # 后台端口
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
# 全部节点的信息: 服务器ip:后台端口
discovery.zen.ping.unicast.hosts: ["60.205.229.31:9300","60.205.229.31:9301","60.205.229.31:9302"]
# 其他节点数目
discovery.zen.minimum_master_nodes: 2
es2.yml
cluster.name: elasticsearch-cluster
node.name: es-node2
network.bind_host: 0.0.0.0
network.publish_host: 60.205.229.31
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["60.205.229.31:9300","60.205.229.31:9301","60.205.229.31:9302"]
discovery.zen.minimum_master_nodes: 2
es3.yml
cluster.name: elasticsearch-cluster
node.name: es-node3
network.bind_host: 0.0.0.0
network.publish_host: 60.205.229.31
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["60.205.229.31:9300","60.205.229.31:9301","60.205.229.31:9302"]
discovery.zen.minimum_master_nodes: 2
2.2 .系统配置修改
- 调高jvm线程数限制;;
- 必须进行修改,不然会报错;
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案
# 修改线程数限制
sysctl -w vm.max_map_count=262144
# 执行生效
sysctl -p
2.3 启动三台ES
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /home/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES01 e2667f5db289
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /home/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES02 e2667f5db289
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /home/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES03 e2667f5db289
2.4 验证
# 1. 启动成功后,通过下面地址验证
http://60.205.229.31:9200/_cat/nodes
二、kibana搭建
# 1. 拉取镜像 6.7.1版本
docker pull kibana:6.7.1
# 2. 启动镜像 其中的ip为ES所在的主节点的ip
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://60.205.229.31:9200 -e SERVER_PORT=5601 -e SERVER_HOST=0.0.0.0 -p 5601:5601 -d 860831fbf9e7
# 3. 开放阿里云的5601端口
# 4. 验证地址
http://60.205.229.31:5601/