• rbd-db数据迁移至外部数据库


    部署外部数据库

    • 安装Docker
     export VERSION=19.03 && curl -fsSL http://rainbond-pkg.oss-cn-shanghai.aliyuncs.com/releases/docker/install-docker.sh | bash -s docker
     systemctl start docker
    
    • 运行数据库
    mkdir -p /opt/rainbond/rbd-db/data/ && docker run --name rbd-db --restart=always -p 3306:3306  -e MYSQL_ALLOW_EMPTY_PASSWORD="yes" -v /opt/rainbond/rbd-db/data:/var/lib/mysql -i registry.cn-hangzhou.aliyuncs.com/goodrain/rbd-db:8.0.19
    

    数据库部署过程仅供参考,可根据自身需求选择数据库部署方式。

    相关要求

    外部数据库版本要求:MySQL5.7/8.0

    Rainbond数据库需要一些特殊配置,配置文件参考如下

    [mysqld]
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    datadir         = /var/lib/mysql
    secure-file-priv= NULL
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    # 服务端默认utf8编码
    character-set-server=utf8mb4
    # 默认存储引擎
    default-storage-engine=INNODB
    
    # Compatible with versions before 8.0
    default_authentication_plugin=mysql_native_password
    skip-host-cache
    skip-name-resolve
    
    [client]
    #设置客户端编码
    default-character-set=utf8mb4
    [mysql]
    # 设置mysql客户端默认编码
    default-character-set=utf8mb4
    

    迁移数据

    注意:数据备份之后请勿在平台上继续进行操作,以免造成数据不一致

    • 获取原来的数据库密码
    kubectl exec -it -n rbd-system rbd-db-0 -- env|grep MYSQL_ROOT_PASSWORD
    
    • 替换变量 MYSQL_ROOT_PASSWORD 后,备份数据库并确认数据是否完整(含有console及region两个库)
    kubectl exec  -it  rbd-db-0 -n rbd-system  --  mysqldump -p$MYSQL_ROOT_PASSWORD --all-databases > all.sql
    
    • 在新的数据库中导入数据

    示例命令

    mysql -uroot -p数据库密码 < all.sql
    

    修改数据库连接地址

    数据导入后,修改Rainbond组件连接数据库主机的IP即可。

    • rbd-app-ui
    kubectl edit -n rbd-system deploy rbd-app-ui
    
        spec:
          containers:
          - env:
            - name: MYSQL_HOST
              value: 172.24.206.76
    
    • rbd-api
    kubectl edit -n rbd-system deploy rbd-api
    
        spec:
          containers:
          - args:
            - --mysql=root:31771251@tcp(172.24.206.76:3306)/region
    
    • rbd-chaos
    kubectl edit -n rbd-system ds rbd-chaos
    
          containers:
          - args:
            - --hostIP=$(POD_IP)
            - --mysql=root:31771251@tcp(172.24.206.76:3306)/region
    
    • rbd-worker
    kubectl edit -n rbd-system deploy rbd-worker
        spec:
          containers:
          - args:
            - --mysql=root:31771251@tcp(172.24.206.76:3306)/region
    
    • rbd-eventlog
    kubectl edit -n rbd-system sts  rbd-eventlog
    
        spec:
          containers:
          - args:
            - --db.url=root:31771251@tcp(172.24.206.76:3306)/region
    

    验证

    1.查看Rainbond组件是否处于Running状态

    $ kubectl get pod -n rbd-system
    NAME                                         READY   STATUS      RESTARTS   AGE
    dashboard-metrics-scraper-754cdcbbb6-pckfj   1/1     Running     1          28h
    kubernetes-dashboard-57b897f8df-8hkrv        1/1     Running     1          28h
    nfs-provisioner-0                            1/1     Running     1          28h
    rainbond-operator-0                          2/2     Running     2          28h
    rbd-api-564f456468-4w9xj                     1/1     Running     1          28h
    rbd-app-ui-64c7c55995-svg56                  1/1     Running     1          28h
    rbd-app-ui-migrations-k5jwd                  0/1     Completed   0          28h
    rbd-chaos-htwr2                              1/1     Running     1          28h
    rbd-db-0                                     2/2     Running     2          28h
    rbd-etcd-0                                   1/1     Running     1          28h
    rbd-eventlog-0                               1/1     Running     1          28h
    rbd-gateway-sz7wf                            1/1     Running     1          28h
    rbd-hub-85b7b94846-kbffc                     1/1     Running     1          28h
    rbd-monitor-0                                1/1     Running     1          28h
    rbd-mq-989c5549c-8p8n4                       1/1     Running     1          28h
    rbd-node-5c887                               1/1     Running     1          23h
    rbd-node-bndzh                               1/1     Running     1          28h
    rbd-node-s2mnc                               1/1     Running     1          22h
    rbd-repo-0                                   1/1     Running     1          28h
    rbd-webcli-84969b7fc5-zm7tw                  1/1     Running     1          28h
    rbd-worker-78b6dc8fc4-rxd7p                  1/1     Running     1          28h
    

    2.登录平台查看应用数量,组件数量是否和迁移前一致

    数据迁移完毕删除rbd-db服务,到此完成数据迁移

     kubectl delete rbdcomponents.rainbond.io rbd-db -n rbd-system
    
  • 相关阅读:
    require笔札
    zepto_core
    2016年规划
    说说Q.js中的promise的历史
    jQuery.extend
    jQuery.core_02
    javascript之this指针
    javascript之闭包
    javascript之作用域链
    jvavascript之变量对象
  • 原文地址:https://www.cnblogs.com/Aaron-23/p/14120530.html
Copyright © 2020-2023  润新知