nacos集群部署docker-compose《微服务》
2023-05-09 05:58:09 阅读次数:340
docker,mysql,nacos
1.docker-compose.yaml
version: "3"
services:
nacos1:
hostname: nacos1
container_name: nacos1
image: nacos/nacos-server:2.0.2
volumes:
- ./cluster-logs/nacos1:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"
- "9555:9555"
env_file:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
nacos2:
hostname: nacos2
image: nacos/nacos-server:2.0.2
container_name: nacos2
volumes:
- ./cluster-logs/nacos2:/home/nacos/logs
ports:
- "8849:8848"
- "9849:9848"
env_file:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
nacos3:
hostname: nacos3
image: nacos/nacos-server:2.0.2
container_name: nacos3
volumes:
- ./cluster-logs/nacos3:/home/nacos/logs
ports:
- "8850:8848"
- "9850:9848"
env_file:
- ../env/nacos-hostname.env
restart: always
depends_on:
- mysql
mysql:
container_name: mysql
image: nacos/nacos-mysql:5.7
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
2.nacos-hostname.env
#nacos dev env
PREFER_HOST_MODE=hostname
NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848
MYSQL_SERVICE_HOST=mysql
MYSQL_SERVICE_DB_NAME=nacos_devtest
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
3.mysql.env
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=nacos_devtest
MYSQL_USER=nacos
MYSQL_PASSWORD=nacos
4. 启动
docker-compose up -d
# 停止所有up命令启动的容器,并移除数据卷
$ docker-compose down -v
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/liuyunshengsir/5998880,作者:liuyunshengsir,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:wagon-maven-plugin插件实现自动化构建部署到服务器
下一篇:openstack双节点部署