Architecture.pngserver_list.png

前置知识

  1. 后台启动容器:docker-compose up -d
  2. 查看容器运行情况:docker-compose ps
  3. 停止容器:docker-compose stop
  4. 启动容器:docker-compose start
  5. 停止并删除容器:docker-compose down
  6. 停止并删除容器并删除volumedocker-compose down --volumes

0、给应用宿主机eth0网卡共新增3个内网IP

  1. 参考:https://cloud.tencent.com/document/product/1199/43866
  2. 10.0.0.10
  3. 10.0.0.4
  4. 10.0.0.14
  5. 设置完之后,一定要重启服务器!
  6. 验证是否设置成功:ping ip1/ip2/ip3 or ip address
  7. 设置多内网IP的原因:
  8. 每个应用都会启动多个实例,每个实例注册到eureka上的IP使用内网IP,否则默认注册的IPdocker分配的IP

1、创建应用集群专用docker网段

  1. docker network create --driver bridge --subnet 172.18.0.0/16 --gateway 172.18.0.1 app-net

2、apollo环境配置,及应用配置

  1. 1apollo环境配置
  2. 首先在宿主机上创建apollo的环境配置文件:
  3. vim /opt/settings/server.properties
  4. 内容:
  5. env=DEV
  6. 编写docker-compose.yml时,将宿主机该文件所在目录映射docker容器中相同目录:
  7. - /opt/settings:/opt/settings
  8. 注:apollo客户端启动时默认会去读/opt/settings/server.properties中的环境配置
  9. 2、各个应用的配置文件内容
  10. https://github.com/xlvchao/spartacus/tree/main/docs/config/article-application.properties
  11. https://github.com/xlvchao/spartacus/tree/main/docs/config/auth-application.properties
  12. https://github.com/xlvchao/spartacus/tree/main/docs/config/chat-application.properties
  13. https://github.com/xlvchao/spartacus/tree/main/docs/config/comment-application.properties
  14. https://github.com/xlvchao/spartacus/tree/main/docs/config/datasyner-application.properties
  15. https://github.com/xlvchao/spartacus/tree/main/docs/config/discovery-application.properties
  16. https://github.com/xlvchao/spartacus/tree/main/docs/config/friday-application.properties
  17. https://github.com/xlvchao/spartacus/tree/main/docs/config/gateway-application.properties
  18. https://github.com/xlvchao/spartacus/tree/main/docs/config/gateway-resourceRoles.properties
  19. https://github.com/xlvchao/spartacus/tree/main/docs/config/monitor-application.properties
  20. https://github.com/xlvchao/spartacus/tree/main/docs/config/resource-application.properties
  21. https://github.com/xlvchao/spartacus/tree/main/docs/config/sunday-application.properties
  22. https://github.com/xlvchao/spartacus/tree/main/docs/config/system-application.properties
  23. #举个栗子,article-application.properties对应apollo上的应用名称是spartacus-article,对应的namespace是application

QQ截图20220208044710.png
所有应用的截图

QQ截图20220208044829.png
记得给各个应用创建秘钥,并启用!

3、部署sentinel-dashboard

  1. 重要说明:这里使用的是我自己构建的镜像,因为官方没有提供docker镜像!
  2. docker run -d --net app-net -p 8848:8848 --name sentinel-dashboard -e PARAMS='-Dserver.port=8848 -Dcsp.sentinel.dashboard.server=10.0.0.10:8848 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=root -Dsentinel.dashboard.auth.password=Pwd@123' xlvchao/sentinel-dashboard:1.8.1
  3. #sentinel-dashboard的服务端口(记得云主机要开放该端口,才远程能访问sentinel控制台)
  4. -Dserver.port=8848
  5. #向客户端指定控制台的地址(这里sentinel本身也作为客户端)
  6. -Dcsp.sentinel.dashboard.server=10.0.0.10:8848
  7. #客户端的应用名称
  8. -Dproject.name=sentinel-dashboard
  9. #sentinel-dashboard登录用户名
  10. -Dsentinel.dashboard.auth.username=root
  11. #sentinel-dashboard登录密码
  12. -Dsentinel.dashboard.auth.password=Pwd@123
  13. 注意:--net app-net,所有应用必须也要使用该网段,必须保证应用、sentinel.dashboard都在同一网段!

开放sentinel-dashboard节点所在云主机的端口8848:
image.png
登陆验证:http://云主机公网IP:8848/#/login
账号密码:即是上面配置的账号密码

4、初始化系统数据库

先执行:https://github.com/xlvchao/spartacus/tree/main/db/spartacus.sql
再执行:https://github.com/xlvchao/spartacus/tree/main/db/init_data.sql

如果搞不定,请加群讨论,扫码关注,发送“加群”
mp_qrcode.jpg