蓝鲸持续集成平台(蓝盾)是一个免费并开源的 CI 服务。本文档旨在提供蓝鲸智云 7.1 版本蓝盾的存储服务梳理及数据迁移方案。
1. 存储服务梳理
存储服务 | CPU/内存/磁盘 | 部署方式 | 实际资源配置 | 所需版本 | 连接串配置 |
---|
mysql | 1C/2G/50Gi | 云服务 | 2core4G 100G | 5.7.26 (utf8字符集) | values文件中配置 |
redis | 1C/1G/20Gi | 云服务 | 2分片4G | 6.2.5-debian-10-r63 | |
redis-cluster | -/-/20Gi | 云服务 | - | 6.2.6-debian-10-r178 | |
mongodb | -/-/20Gi | 云服务 | 4C8G | 4.4.x | |
elastic | 2C/4G | 云服务 | 2c4g 20GiB | 7.16.2-debian-10-r0 | |
rabbitmq | -/-/20Gi | 自建 | | 3.8.21-debian-10-r0 | |
zookeeper | -/-/20Gi | 自建 | | bitnami/zookeeper:3.8.0-debian-10-r20 | |
etcd | -/-/20Gi | 自建 | | bitnami/etcd:3.5.4-debian-11-r31 | |
influxdb | -/-/20Gi | 自建 | | influxdb:1.8.6-alpine | |
基础存储服务包含:mysql、redis、mongodb、rabbitmq、elastic、zookeeper、etcd。
蓝盾存储服务包含:mysql、redis、mongodb、rabbitmq、elastic、influxdb。
其中 mysql、redis、mongodb、rabbitmq、elastic 可以复用。
2. 基础存储服务
包含:mysql、redis、mongodb、rabbitmq、elastic、zookeeper、etcd。
2.1 mysql
镜像: hub.bktencent.com/bitnami/mysql:5.7.26
resources: limits: cpu: "1" memory: 2Gi requests: cpu: 200m memory: 512Mi
mysql: host: "bk-mysql-mysql" port: 3306 rootPassword: blueking size: 50Gi
|
2.2 rabbitmq
rabbitmq: host: "bk-rabbitmq" port: 5672 username: admin password: blueking erlangCookie: bluekingcookie size: 20Gi
|
2.3 redis
resources: limits: memory: 1024Mi cpu: 1000m requests: memory: 64Mi cpu: 100m
redis: size: 20Gi host: bk-redis-master port: 6379 password: "blueking"
|
2.4 redis-cluster
redisCluster: persistence: size: 20Gi host: bk-redis-cluster port: 6379 password: "blueking"
|
2.5 mongodb
mongodb: host: bk-mongodb-headless port: 27017 host_port: bk-mongodb-headless:27017 rootUsername: root rootPassword: blueking rsName: rs0 replicaCount: 1 replicaSetKey: xEfhjshh3APP0arf size: 20Gi
|
2.6 elastic
master: replicas: 1 heapSize: 512m resources: limits: cpu: 2000m memory: 2048Mi requests: memory: 256Mi cpu: 500m persistence: size: 10Gi data: replicas: 1 resources: limits: cpu: 2000m memory: 4096Mi requests: memory: 256Mi cpu: 500m persistence: size: 40Gi
coordinating: replicas: 1 resources: limits: cpu: 2000m memory: 2048Mi requests: memory: 256Mi cpu: 200m
elasticsearch: host: bk-elastic-elasticsearch-master.blueking.svc.cluster.local port: 9200 username: elastic password: blueking size: 40Gi master: size: 20Gi
|
2.7 zookeeper
resources: requests: cpu: 250m memory: 256Mi
|
2.8 etcd
3. 蓝盾存储服务
包含:mysql、redis、mongodb、rabbitmq、elastic、influxdb。
3.1 自建存储服务
mysql: primary: persistence: size: 20Gi redis: replica: persistence: size: 20Gi master: persistence: size: 20Gi elasticsearch: master: persistence: size: 20Gi data: persistence: size: 20Gi rabbitmq: persistence: size: 20Gi influxdb: persistence: size: 20Gi mongodb: persistence: size: 20Gi
|
3.2 外部数据库
externalMysql: host: localhost port: 3306 username: bkci password: bkci externalRedis: host: localhost port: 6379 password: bkci externalElasticsearch: host: localhost port: 9200 username: bkci password: bkci externalRabbitmq: host: localhost username: bkci password: bkci vhost: bkci externalInfluxdb: host: localhost port: 8086 username: bkci password: bkci externalMongodb: turbo: turboUrl: mongodb://bkci:bkci@localhost:27017/db_turbo quartzUrl: mongodb://bkci:bkci@localhost:27017/db_quart
|
4. 数据迁移(Mysql)
4.1 数据备份
1.备份脚本准备
#!/bin/bash MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PASSWD= ignoredblist='information_schema|mysql|test|db_infobase|performance_schema|sys' dblist="$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWD -Nse"show databases;"|grep -Ewv "$ignoredblist" | xargs echo)"
mysqldump -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWD --skip-opt --create-options --default-character-set=utf8mb4 -R -E -q -e --single-transaction --no-autocommit --max-allowed-packet=1G --hex-blob -B $dblist > /tmp/bk_mysql_alldata.sql
|
将其中的MYSQL_USER、MYSQL_HOST、MYSQL_PASSWORD更换成需要备份的数据库及用户名密码。存为 dbbackup_mysql.sh
文件。
2.将脚本拷贝到容器内执行
以自建的蓝盾mysql为例
kubectl cp -n blueking /data/dbbackup_mysql.sh bk-ci-mysql-0:/tmp/dbbackup_mysql.sh
kubectl exec -it -n blueking bk-mysql-mysql-master-0 -- bash /tmp/dbbackup_mysql.sh
kubectl cp -n blueking bk-ci-mysql-0:/tmp/bk_mysql_alldata.sql /data/bkmysql_bak/bk_mysql_alldata.sql
|
最后一步数据拷贝可以不做,直接在这个pod里进行后续的数据导入操作。
4.2 数据导入
上一步的数据备份是用root
用户进行操作,备份中涉及存储过程函数和赋权。
注意:如果导入到阿里云mysql服务中需要处理导出的sql文件,因为阿里云提供的mysql服务,root
作为保留字段,不能由用户自由创建,但允许创建拥有root
权限的账户,所以需要修改备份数据中相关的内容,更换成实际使用的数据库用户,以替换成 superuser
为例执行如下命令:
grep -o '`root`@' bk_mysql_alldata.sql | wc -l
sed -i 's/`root`@/`superuser`@/g' bk_mysql_alldata.sql
grep -o '`superuser`@' bk_mysql_alldata.sql | wc -l
|
导入
mysql -h $NEW_MYSQL_HOST -usuperuser -p$YOUR_PASSWORD --force < bk_mysql_alldata.sql
|
检查
mysql -h$MYSQL_HOST -usuperuser -p$MYSQL_PASSWD -Nse"show databases like 'devops_ci%';"
|
4.3 Helmfile更新
变更 bkci\environments\default\bkci\bkci-custom-values.yaml.gotmpl 文件后执行 helmfile 相关命令更新服务。