迁移 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;

迁移 MySQL 数据到 OceanBase 集群_第1张图片

迁移 MySQL 数据到 OceanBase 集群_第2张图片

    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

迁移 MySQL 数据到 OceanBase 集群_第3张图片

查看集群名称:

你可能感兴趣的:(OceanBase专栏,oceanbase)