Docker 部署es,redis,rabbitmq,postgres, mysql
elasticsearch.yml 配置内容
http.host: 0.0.0.0
xpack.security.enabled: true
docker run -d --restart=always --restart=always --privileged=true --name=es7 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v /home/user/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -e ES_JAVA_OPTS="-Xms256m -Xmx256m" docker.elastic.co/elasticsearch/elasticsearch:7.8.0
docker run --name my my8020 -p 3307:3306 -e MYSQL_ROOT_PASSWORD='123456' -d mysql:8.0.20
PostgreSQL
-
安装
docker run -d --name pg --restart=always -e POSTGRES_PASSWORD=123456Aa -p 5432:5432 -v /mnt/data/postgres:/var/lib/postgresql/data postgres:latest
-
当需要恢复时可以启动相同命令的容器即可,测试有效
Rabbit MQ
-
运行docker镜像
docker run -d --restart=always --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management
-
修改rabbitmq密码
docker exec -it rabbitmq bash rabbitmqctl chanage_password guest 'xxx'
Elasticsearch
-
运行docker
docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name es7 -v /mnt/data/elasticsearch:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:7.13.4
-
设置密码
docker exec -it es bash cd config vi elasticsearch.yml # 修改内容 http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization xpack.security.enabled: true xpack.security.transport.ssl.enabled: true # 重启docker容器 cd bin elasticsearch-setup-passwords interactive
错误处理
-
docker elasticsearch挂载宿主机报 java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
赋予目标目录所有UID为1000即可解决问题