三人行必有我师

使用docker安装es环境

Elasticsearch | 作者 | 发布于2021年08月25日 | | 阅读数:3277

创建es账号并授权

# 创建账号
adduser es

# 修改密码
passwd es   

# 授权
chmod -v u+w /etc/sudoers
vim /etc/sudoers

#新增
es ALL=(ALL) ALL

# wq保存退出,这时候要记得将写权限收回
chmod -v u-w /etc/sudoers

创建docker网络

docker network create tx

安装Elasticsearch

docker pull elasticsearch:6.7.1
在/home/es 中创建 config,data,plugins目录
在plugins目录中下载es相关插件,如:ik,pinyin等
在config中创建elasticsearch.yml配置,创建analysis\synonym.txt 同义词
给data配置权限 sudo chmod 777 /home/es/data/
将/home/es 目录及其子目录的用户改为es:chown -R es:root /home/es/
# elasticsearch.yml
cluster.name: "my-docker-cluster"
node.name: "es-node1"
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: "Authorization,X-Requested-With,Content-Length,Content-Type"
node.master: true
reindex.remote.whitelist: ['other:9200']

xpack.security.enabled: true
xpack.security.authc.api_key.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate 
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
docker run -d --net tx --name my_elasticsearch -p 9201:9200 -p 9301:9300 -v /home/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/es/config/analysis:/usr/share/elasticsearch/config/analysis -v /home/es/config/elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12 -v /home/es/data:/usr/share/elasticsearch/data -v /home/es/plugins:/usr/share/elasticsearch/plugins -e "discovery.type=single-node" -i -t --privileged=true elasticsearch:6.7.1

安装kibana

docker pull kibana:6.7.1
# kibana.yml配置文件
server.name: kibana
server.host: 0.0.0.0
elasticsearch.hosts: ["http://my_elasticsearch:9200"]
i18n.locale: "zh-CN"
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
xpack.graph.enabled : true
xpack.ml.enabled : true
xpack.monitoring.enabled : true
xpack.reporting.enabled : true
xpack.security.enabled : true
xpack.watcher.enabled : true
docker run -d --name kibana --net tx -p 5601:5601 -v  /home/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:6.7.1

[尊重社区原创,转载请保留或注明出处]
本文地址:http://elasticsearch.cn/article/14371


0 个评论

要回复文章请先登录注册