直播系统搭建,docker Elasticsearch 7.16.1 设置密码
1、启动容器
docker run -d -p 9200:9200 -p 9300:9300 --hostname es --network seata_default -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" --name es -v es_config:/usr/share/elasticsearch/config -v es_data:/usr/share/elasticsearch/data elasticsearch:7.16.1
2、修改配置文件
vim /var/lib/docker/volumes/es_config/_data/elasticsearch.yml
cluster.name: "docker-cluster" #集群名称
network.host: 0.0.0.0 #设置允许其他ip访问,解除ip绑定
#安全配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
3、生成ca: elastic-stack-ca.p12
#进入容器
docker exec -it es /bin/bash
#容器内生成 一路回车就行
./bin/elasticsearch-certutil ca
4、生成cert: elastic-certificates.p12
# 容器内生成
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
# 生成后需要移到config下面
mv elastic-certificates.p12 ./config
5、生成密码
#容器内生成
./bin/elasticsearch-setup-passwords auto
6、再次修改配置
vim /var/lib/docker/volumes/es_config/_data/elasticsearch.yml
cluster.name: "docker-cluster" #集群名称
network.host: 0.0.0.0 #设置允许其他ip访问,解除ip绑定
#安全配置 最终配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.keystore.type: PKCS12
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
xpack.security.transport.ssl.truststore.type: PKCS12
xpack.security.audit.enabled: true
7、重启容器
8、java连接配置
spring:
elasticsearch:
rest:
username: elastic
password: rrqgVK9DGRg43jz1YJkR
uris:
- http://ll129.com:9200
以上就是 直播系统搭建,docker Elasticsearch 7.16.1 设置密码,更多内容欢迎关注之后的文章
标签:7.16,elastic,ssl,elasticsearch,Elasticsearch,security,docker,transport From: https://www.cnblogs.com/yunbaomengnan/p/17122601.html