暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
Mysql迁移LightDB用例.pdf
1682
5页
6次
2021-09-03
免费下载
MySQL迁移LightDB用例
1.py-mysql2pgsql简介
2.py-mysql2pgsql自动化迁移过程
工具运行后,整个过程可以分为三个阶段:
3.py-mysql2pgsql工具安装及使用案例
3.1 下载源码安装包
下载地址
https://pypi.org/project/py-mysql2pgsql/#description
3.2 迁移存量数据
如下将MySQL中的test.tab_testtext表存量迁移到LightDB中pg的public下面。
1、编辑迁移配置文件
MySQLLightDBpy-mysql2pgsqlpython使MySQL
LightDBLightDB
-- LightDB
-- LightDBloading;
-- LightDB
l
2
pythontermcolormysql-pythonpsycopg2argparse
3mysql2pgsql
[root@123 ]# pwd
/data/tools/py-mysql2pgsql-0.1.5
[root@123 ]# python setup.py install
4help
[root@123 /data/tools/py-mysql2pgsql-0.1.5]# py-mysql2pgsql -h
usage: py-mysql2pgsql [-h] [-v] [-f FILE] [-V]
Tool for migrating/converting data from mysql to LightDB.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Show progress of data migration.
-f FILE, --file FILE Location of configuration file (default:mysql2pgsql.yml). If none exists at that path, one
will be created for you.
-V, --version Print version and exit.
https://github.com/philipsoutham/py-mysql2pgsql
vi mysql2pgsql.yml
#source
# if a socket is specified we will use that
# if tcp is chosen you can use compression
mysql:
hostname: 100.66.66.66
3.3 执行数据迁移
执行导入数据后,自动执行过程分3个阶段:
-- 自动在PostgreSQL创建表结构;
-- 自动加载数据(约1w rows/sec);
-- 自动在PostgreSQL创建索引。
port: 15140
socket:
username: dbmgr
password: 520DBA
database: test
compress: false
destination:
# if file is given, output goes to file, else postgres.
file:
postgres:
hostname: 100.88.88.88
port: 11005
username: hs
password: hs123
database: pg
# databaseif only_tables is given, only the listed tables will be converted. leave
empty to convert all tables.
only_tables:
#- table1
#- table2
tab_testtext
# if exclude_tables is given, exclude the listed tables from the conversion.
#exclude_tables:
#- table3
#- table4
# turedllif supress_data is true, only the schema definition will be
exported/migrated, and not the data
supress_data: false
# trueif supress_ddl is true, only the data will be exported/imported, and not the
schema
supress_ddl: false
# trueif force_truncate is true, forces a table truncate before table loading
force_truncate: false
# if timezone is true, forces to append/convert to UTC tzinfo mysql data
timezone: false
# if index_prefix is given, indexes will be created whith a name prefixed with index_prefix
index_prefix:
[root@123]# py-mysql2pgsql -v -f mysql2pgsql.yml
>>>>>>>>>> STARTING <<<<<<<<<<
START CREATING TABLES
START - CREATING TABLE tab_testtext
FINISH - CREATING TABLE tab_testtext
DONE CREATING TABLES
of 5
免费下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜