1. es 安装
docker pull elasticsearch:7.12.0
2.创建对应的映射文件目录
mkdir -p /root/tools/elasticsearch/config
mkdir -p /root/tools/elasticsearch/data
mkdir -p /root/tools/elasticsearch/plugins
3. 修改配置文件让其他机器可以访问
[root@basenode ~]# echo "http.host: 0.0.0.0" >> /root/tools/elasticsearch/config/elasticsearch.yml
[root@basenode ~]#
3.1 增加跨域配置
/root/tools/elasticsearch/config
[root@basenode config]# vi elasticsearch.yml
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
4. 创建容器
docker run --name elasticsearch -p 9200:9200 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /root/tools/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /root/tools/elasticsearch/data:/usr/share/elasticsearch/data \
-v /root/tools/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.12.0
[root@basenode ~]# docker run --name elasticsearch -p 9200:9200 \
> -e "discovery.type=single-node" \
> -e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
> -v /root/tools/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
> -v /root/tools/elasticsearch/data:/usr/share/elasticsearch/data \
> -v /root/tools/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
> -d elasticsearch:7.12.0
95ee90ad2096eab048fd14f154041852689fb8bf1cb8b00bd327bb21f482a2e2
[root@basenode ~]#
5. 赋值权限
[root@basenode elasticsearch]# chmod -R 777 /root/tools/elasticsearch
不赋值权限会报错
ncaught exception in thread [main]
ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];
Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:388)
at java.base/java.nio.file.Files.createDirectory(Files.java:694)
at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:801)
at java.base/java.nio.file.Files.createDirectories(Files.java:787)
at org.elasticsearch.env.NodeEnvironment.lambda$new$0(NodeEnvironment.java:265)
at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:202)
at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:262)
at org.elasticsearch.node.Node.<init>(Node.java:352)
at org.elasticsearch.node.Node.<init>(Node.java:278)
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:217)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:217)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:397)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
at org.elasticsearch.cli.Command.main(Command.java:79)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
For complete error details, refer to the log at /usr/share/elasticsearch/logs/elasticsearch.log
6. 访问
http://192.168.1.180:9200/
7. kibana 的安装
[root@basenode ~]# docker pull kibana:7.12.0
7.1 创建文件夹
mkdir -p /root/tools/kibana/config
7.2 创建文件
[root@basenode ~]# cd /root/tools/kibana/config/
[root@basenode config]# ll
总用量 0
[root@basenode config]# vi kibana.yml
#Kibana的映射端口
server.port: 5601
#网关地址
server.host: "0.0.0.0"
#Kibana实例对外展示的名称
server.name: "kibana-180"
#Elasticsearch的集群地址,也就是说所有的集群IP
elasticsearch.hosts: ["http://192.168.1.180:9200"]
#设置页面语言,中文使用zh-CN,英文使用en
i18n.locale: "zh-CN"
xpack.monitoring.ui.container.elasticsearch.enabled: true
7.3 创建网络映射
[root@basenode config]# docker network create es-net
7.4 创建容器
docker run -d -p 5601:5601 -v /root/tools/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml --network es-net --name kibana kibana:7.12.0
7.5 访问地址
192.168.1.180:5601/app/home
es-elastic.png
8. 安装 head
docker pull mobz/elasticsearch-head:5
8.1 启动head 容器
docker run -d --name elasticsearch-head -p 9100:9100 mobz/elasticsearch-head:5
网友评论