迁移 MySQL 数据到 OceanBase 集群

    1. 使用 mysqldump 将 mysql的表结构和数据同步到 OceanBase 的MySQL 租户中
      1. Mysql数据库导出

mysqldump -h127.0.0.1 -P3306 -uroot –p '' --single-transaction --hex-blob --routines --events --triggers --set-gtid-purged=OFF --databases teller >teller.sql

mysql> use tell;

mysql> show tables;

…………192 rows

      1. oceanbase数据库导入

##使用之前的test租户登录,导入

obclient -h10.64.8.28 -P2883 -uroot@test#admin -p -A

source teller.sql;

obclient> show tables;

    1. datax 配置至少一个表的 MySQL 到 OceanBase 的 MySQL 租户的离线同步
      1. datax安装

wget http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz

tar -xf datax.tar.gz -C /usr/local/

cd /usr/local/datax

yum install -y python2 java

##生成模板文件

python2 /usr/local/datax/bin/datax.py -r mysqlreader -w oceanbasev10writer > /usr/local/datax/job/my2ob.json

      1. datax配置参数

##根据实际环境修改

vi /usr/local/datax/job/my2ob.json

[root@iZm5e08jeuiuif0rds45vvZ log]# cat /usr/local/datax/job/my2ob.json

{   

"job": {

        "setting": {

            "speed": {

                "channel": 2,

            },

            "errorLimit": {

                "record": 10

            }

        },

        "content": [

            {

                "reader": {

                    "name": "mysqlreader",

                    "parameter": {

                        "username": "root",

                        "password": "xxxxx",

                        "splitPk": "id",

                        "column": ["*"],

                        "connection": [

                            {

                                "jdbcUrl": [

                                    "jdbc:mysql://xxx.xxx.xxx.xxx:3306/teller"

                                ],

                                "table": [

                                    "*"

                                ]

                            }

                        ]

                    }

                },

                "writer": {

                    "name": "oceanbasev10writer",

                    "parameter": {

                        "writeMode": "insert",

                        "username": "root",

                        "password": "root123",

                        "writerThreadCount": 5,

                        "column": [

                            "*"

                        ],

                        "connection": [

                           {

                                "jdbcUrl": "jdbc:oceanbase://192.168.0.26:2883/teller?useUnicode=true&characterEncoding=utf-8mb4",

                                "table": [

                                    "*"

                                ]

                            }

                        ]

                    }

                }

            }

        ]

    }

}

      1. datax执行

python2 /usr/local/datax/bin/datax.py /usr/local/datax/job/my2ob.json

查看集群名称:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值