使用 docker swarm 起了两个服务:一个是 go 写的 web 服务,另外一个是 db ( cockroach )。现在想在 web 服务中使用 cockroach 的 dump 去备份数据,但是 web 服务中调用不了 cockroach 的指令,这种情况一般要怎么去做备份。 docker compose 文件如下:
version: '3.3'
services:
web:
image: 192.168.0.54:5000/airsunweb:v1.0
environment:
- MICRO_REGISTRY=etcd
- MICRO_REGISTRY_ADDRESS=etcd:2379
- MICRO_SERVER_ADDRESS=0.0.0.0:8080
- MICRO_LOG_LEVEL=debug
ports:
- 7777:8080
configs:
- source: web_config
target: /config.yaml
- source: web_base_data_config
target: /base_data_config.json
- source: web_param_running_config
target: /param_running_config.json
sqldb:
image: swr.cn-east-3.myhuaweicloud.com/langmy/cockroach:latest
volumes:
- sql-data:/cockroach/cockroach-data
command: start-single-node --insecure
deploy:
placement:
constraints:
- node.labels.db-data == true
1
XSG 2020-10-26 14:10:16 +08:00
再起一个数据库客户端服务,专门用来备份
|
2
godcc OP 请问一下具体该怎么做
|
3
XSG 2020-10-30 11:19:52 +08:00
```yaml
version: '3.3' services: web: image: 192.168.0.54:5000/airsunweb:v1.0 environment: - MICRO_REGISTRY=etcd - MICRO_REGISTRY_ADDRESS=etcd:2379 - MICRO_SERVER_ADDRESS=0.0.0.0:8080 - MICRO_LOG_LEVEL=debug ports: - 7777:8080 configs: - source: web_config target: /config.yaml - source: web_base_data_config target: /base_data_config.json - source: web_param_running_config target: /param_running_config.json sqldb: image: swr.cn-east-3.myhuaweicloud.com/langmy/cockroach:latest volumes: - sql-data:/cockroach/cockroach-data command: start-single-node --insecure deploy: placement: constraints: - node.labels.db-data == true backup: image: 数据库客户端:latest environment: - USER=xxx - PASSED=xxx ... ``` backup 服务里面自己写个脚本做个镜像,就可以执行备份了呀 |