KFS数据集中场景(多对一)部署
一、环境信息
1、软件版本
KFS版本:Kingbase FlySync V001R006C003B20220107
源端1:oracle 11.2.0.4.0
源端2:Mysql 8.0.26
源端3:sqlserver 2017
目标端:KingbaseES V008R006C003B0071
2、部署拓扑
KFS与数据库集中部署,部署在同一台服务器上。
3、IP地址
源端1(oracle):192.168.100.111
源端2(mysql):192.168.100.112
源端3(sqlserver):192.168.100.113
目标端(kes):192.168.100.114
二、源端1(oracle) KFS部署
源端oracle采用redo方式解析。
(一)、环境配置
1、创建安装用户
groupadd flysync
useradd flysync -g flysync -G mysql
passwd flysync
2、上传安装文件包和license文件到服务器/home/flysync目录下,并解压
tar -xzvf KingbaseFlySync-V001R006C003B20220107-replicator.tar.gz
3、配置将hosts文件,将源端和目标端服务器都加上去
vi /etc/hosts
192.168.100.111 oracle
192.168.100.114 kes
192.168.100.112 mysql
192.168.100.113 sqlserver
4、配置/etc/security/limits.conf文件【可选】
vi /etc/security/limits.conf
flysync - nofile 65535
flysync - nproc 8096
mssql - nofile 65535
mssql - nproc 8096
5、开启时间同步服务【可选】
yum install ntp
systemctl start ntpd
systemctl enable ntpd
6、在/etc/sysctl.conf配置swappiness参数【可选】
vi /etc/sysctl.conf
vm.swappiness = 10
sysctl -p
7、检查依赖软件jdk和ruby【必须】
--jdk
java -version
版本小于1.8的,可以使用yum安装1.8版本
yum install java-1.8.0-openjdk.x86_64
也可以下载oracle的1.8版本的JDK包手动上传安装
--ruby
可以使用yum方式安装
yum install ruby
也可以使用KFS控制台服务器里自带的ruby包进行替换,位置在:/opt/KFS/console/media/rbenv,
将压缩包解压到/usr/local,然后配置/etc/profile文件里$PATH环境变量,将ruby的bin目录添加进去
vi /etc/profile
export PATH=$PATH:/usr/local/ruby/bin
配置完成后,使用source命令应用
source /etc/profile
(二)、数据库配置
1、配置数据库时间格式:
ALTER SYSTEM SET NLS_DATE_FORMAT='YYYY-MM-DD' SCOPE=SPFILE;
2、创建连接用户并授予相关权限:
create user flysync identified by 123456;
alter user flysync default tablespace users;
alter user flysync quota unlimited on users;
GRANT CONNECT, RESOURCE TO FLYSYNC;
GRANT EXECUTE_CATALOG_ROLE TO FLYSYNC;
GRANT CREATE SESSION TO FLYSYNC;
GRANT SELECT ANY TRANSACTION TO FLYSYNC;
GRANT SELECT ANY TABLE TO FLYSYNC;
GRANT UNLIMITED TABLESPACE TO FLYSYNC;
GRANT DBA TO FLYSYNC;
3、开启 Oracle 数据库的归档日志(必须开启)了,具体步骤如下:
(1).查看当前归档模式
SQL>select log_mode from v$database;
(2).创建归档目录
[oracle@zjtmp-db oracle]$ mkdir -p $ORACLE_BASE/archivelog
[oracle@zjtmp-db oracle]$ sqlplus / as sysdba
SQL> alter system set log_archive_dest_1="location=/data/oracle/archivelog" scope=both;
(3).将数据库重启到mount状态
SQL>shutdown immediate
SQL>startup mount
(4).将数据库更改为归档模式
SQL>alter database archivelog;
(5).打开数据库
SQL>alter database open;
(6).查看归档模式是否开启
SQL>select log_mode from v$database;
4、开启补全日志:
(1).检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk,supplemental_log_data_all FROM v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
(2).开启补全日志 (建议在 MOUNT 模式下执行)
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
(3).再次检查补全日志的状态
SQL> SELECT supplemental_log_data_min, supplemental_log_data_pk, supplemental_log_data_all FROM v$database;
SUPPLEME SUP SUP
-------- --- ---
YES YES YES
必须3项都为YES
5、切换日志文件
SQL> ALTER SYSTEM SWITCH LOGFILE;
(三)、KFS安装
1、配置flysync.ini文件
在安装用户的家目录下配置flysync.ini文件
vi /home/flysync/flysync.ini
输入以下内容:
[defaults]
user=flysync
install-directory=/home/flysync/kfsrep
profile-script=~/.bash_profile
rmi-port=11000
[oracle11g]
role=master
master=oracle
members=oracle
kufl-port=3112
replication-host=192.168.100.111
replication-port=1521
#连接数据库的用户名必须为大写
replication-user=FLYSYNC
replication-password=123456
datasource-type=oracle
oracle-extractor-method=redo
datasource-oracle-service=orcl
svc-extractor-filters=dropstatementdata,ignoreddl
property=replicator.extractor.dbms.tablePatterns=FLYSYNC.*,TEST.*
property=replicator.extractor.dbms.keepMixDML=false
property=replicator.filter.ignoreddl.ignore=CREATE;ALTER;DROP;TURNCATE
2、安装
切换到安装包目录下的tools子目录
cd /home/flysync/KingbaseFlySync-V001R006C003B20220107-replicator/tools
./fspm install
3、将license文件复制到安装目录下
cp license_8703_0.dat /home/flysync/kfsrep/license.dat
4、启动KFS
replicator start
查看KFS状态
replicator status
查看服务状态
fsrepctl status
查看KUFL列表
kufl list
三、源端2(mysql8)KFS部署
(一)、环境配置
1、创建安装用户
groupadd flysync
useradd flysync -g flysync -G mysql
passwd flysync
2、上传安装文件包和license文件到服务器/home/flysync目录下,并解压
tar -xzvf KingbaseFlySync-V001R006C003B20220107-replicator.tar.gz
3、配置将hosts文件,将源端和目标端服务器都加上去
vi /etc/hosts
192.168.100.111 oracle
192.168.100.114 kes
192.168.100.112 mysql
192.168.100.113 sqlserver
4、配置/etc/security/limits.conf文件【可选】
vi /etc/security/limits.conf
flysync - nofile 65535
flysync - nproc 8096
mssql - nofile 65535
mssql - nproc 8096
5、开启时间同步服务【可选】
yum install ntp
systemctl start ntpd
systemctl enable ntpd
6、在/etc/sysctl.conf配置swappiness参数【可选】
vi /etc/sysctl.conf
vm.swappiness = 10
sysctl -p
7、检查依赖软件jdk和ruby【必须】
--jdk
java -version
版本小于1.8的,可以使用yum安装1.8版本
yum install java-1.8.0-openjdk.x86_64
也可以下载oracle的1.8版本的JDK包手动上传安装
--ruby
可以使用yum方式安装
yum install ruby
也可以使用KFS控制台服务器里自带的ruby包进行替换,位置在:/opt/KFS/console/media/rbenv,
将压缩包解压到/usr/local,然后配置/etc/profile文件里$PATH环境变量,将ruby的bin目录添加进去
vi /etc/profile
export PATH=$PATH:/usr/local/ruby/bin
配置完成后,使用source命令应用
source /etc/profile
(二)、数据库配置
1、mysql系统参数配置
vi /etc/my.cnf
[mysqld]
character-set-server= utf8
binlog_format= ROW
default-time-zone= '+08:00'
server-id= 1
log-bin= mysql-bin
如果源端是mysql的从库,需要再添加以下参数,确保主库的binlog日志能传送到从库:
[mysqld]
log_slave_updates=1
如果含有大数据量表时,需修改临时表空间大小限制,添加下列参数
[mysqld]
tmp_table_size=256M #临时表大小
max_heap_table_size=256M #内存表大小
保存后重启数据库
systemctl restart mysqld
2、连接帐号配置
建立帐号并给予相应的权限
mysql>CREATE USER flysync@'%' IDENTIFIED BY '123456';
mysql>GRANT ALL ON *.* TO flysync@'%' WITH GRANT OPTION;
(三)、KFS安装
1、配置flysync.ini
[defaults]
install-directory=/home/flysync/kfsrep
profile-script=~/.bash_profile
rmi-port=11000
[mysql80]
skip_validation_check=MySQLDumpCheck,MySQLPermissionsCheck
role=master
master=mysql
members=mysql
kufl-port=3112
replication-host=192.168.100.112
replication-port=3306
replication-user=flysync
replication-password=123456
datasource-type=mysql
datasource-mysql-conf=/etc/my.cnf
enable-heterogeneous-master=true
svc-extractor-filters=dropstatementdata,replicate
property=replicator.filter.dbselector.db=test
property=replicator.filter.replicate.do=test.*,flysync_mysql80*
2、安装
cd /home/flysync/KingbaseFlySync-V001R005C002B20210524-replicator/tools
./fspm install
3、复到license文件到安装目录
cp license.dat /home/flysync/kesrep/license.dat
4、启动并初始化
/home/flysync/kesrep/flysync/cluster-home/bin/startall
source ~/.bash_profile
查看KFS状态
replicator status
查看服务状态
fsrepctl status
查看KUFL列表
kufl list
四、源端3(sqlserver2017)KFS部署
(一)、环境配置
1、创建安装用户
groupadd flysync
useradd flysync -g flysync -G mysql
passwd flysync
2、上传安装文件包和license文件到服务器/home/flysync目录下,并解压
tar -xzvf KingbaseFlySync-V001R006C003B20220107-replicator.tar.gz
3、配置将hosts文件,将源端和目标端服务器都加上去
vi /etc/hosts
192.168.100.111 oracle
192.168.100.114 kes
192.168.100.112 mysql
192.168.100.113 sqlserver
4、配置/etc/security/limits.conf文件【可选】
vi /etc/security/limits.conf
flysync - nofile 65535
flysync - nproc 8096
mssql - nofile 65535
mssql - nproc 8096
5、开启时间同步服务【可选】
yum install ntp
systemctl start ntpd
systemctl enable ntpd
6、在/etc/sysctl.conf配置swappiness参数【可选】
vi /etc/sysctl.conf
vm.swappiness = 10
sysctl -p
7、检查依赖软件jdk和ruby【必须】
--jdk
java -version
版本小于1.8的,可以使用yum安装1.8版本
yum install java-1.8.0-openjdk.x86_64
也可以下载oracle的1.8版本的JDK包手动上传安装
--ruby
可以使用yum方式安装
yum install ruby
也可以使用KFS控制台服务器里自带的ruby包进行替换,位置在:/opt/KFS/console/media/rbenv,
将压缩包解压到/usr/local,然后配置/etc/profile文件里$PATH环境变量,将ruby的bin目录添加进去
vi /etc/profile
export PATH=$PATH:/usr/local/ruby/bin
配置完成后,使用source命令应用
source /etc/profile
(二)、数据库配置
1、开启sqlserver agent(mssql用户)
/opt/mssql/bin/mssql-conf set sqlagent.enabled true
systemctl restart mssql-server.service
(1)、设置配置文件:
cd /home/flysync/KingbaseFlySync-V001R006C003B20220107-replicator/flysync-replicator/extractors/mssql-cdc
vi setupCDC.conf
添加以下内容
service=sqlserver2017
db_host=localhost,1433
db_name=test
sa_user=sa
sa_pass=123456
source_user=flysync_sqlserver2017 #同步用户名,命名规则:flysync_+service名称
source_password=Flysync1234 #同步用户密码,密码8位以上,必须有字母大小写,数字或者特殊字符。
delete_user=0
specific_path=
file_group_size=16GB
(2)、填写flysync.tables文件。Flysync.tables内容为需要同步的表。
vi flysync.tables
test #格式为<模式><空格><表><空格><列>
(3)、执行配置脚本:
./setupCDC.sh setupCDC.conf
(三)、KFS安装
1、配置flysync.ini
[defaults]
install-directory=/home/flysync/kfsrep
profile-script=~/.bash_profile
rmi-port=11000
[sqlserver2017]
role=master
master=sqlserver
Members=sqlserver
kufl-port=3112
replication-host=192.168.100.113
replication-port=1433
replication-user=flysync_sqlserver2017 #和cdc配置文件里的source_user一样
replication-password=123456
datasource-type=mssql
mssql-extractor-method=cdc
mssql-dbname=test
property=replicator.extractor.dbms.maxRowsByBlock=500
property=replicator.extractor.dbms.minSleepTime=5
property=replicator.extractor.dbms.sleepAddition=1
property=replicator.extractor.dbms.maxSleepTime=15
2、安装
cd /home/flysync/KingbaseFlySync-V001R005C002B20210524-replicator/tools
./fspm install
3、复到license文件到安装目录
cp license.dat /home/flysync/kesrep/license.dat
4、启动并初始化
/home/flysync/kesrep/flysync/cluster-home/bin/startall
source ~/.bash_profile
查看KFS状态
replicator status
查看服务状态
fsrepctl status
查看KUFL列表
kufl list
五、目标端(KES v8r6)KFS部署
(一)、环境配置
1、创建安装用户
groupadd flysync
useradd flysync -g flysync -G mysql
passwd flysync
2、上传安装文件包和license文件到服务器/home/flysync目录下,并解压
tar -xzvf KingbaseFlySync-V001R006C003B20220107-replicator.tar.gz
3、配置将hosts文件,将源端和目标端服务器都加上去
vi /etc/hosts
192.168.100.111 oracle
192.168.100.114 kes
192.168.100.112 mysql
192.168.100.113 sqlserver
4、配置/etc/security/limits.conf文件【可选】
vi /etc/security/limits.conf
flysync - nofile 65535
flysync - nproc 8096
mssql - nofile 65535
mssql - nproc 8096
5、开启时间同步服务【可选】
yum install ntp
systemctl start ntpd
systemctl enable ntpd
6、在/etc/sysctl.conf配置swappiness参数【可选】
vi /etc/sysctl.conf
vm.swappiness = 10
sysctl -p
7、检查依赖软件jdk和ruby【必须】
--jdk
java -version
版本小于1.8的,可以使用yum安装1.8版本
yum install java-1.8.0-openjdk.x86_64
也可以下载oracle的1.8版本的JDK包手动上传安装
--ruby
可以使用yum方式安装
yum install ruby
也可以使用KFS控制台服务器里自带的ruby包进行替换,位置在:/opt/KFS/console/media/rbenv,
将压缩包解压到/usr/local,然后配置/etc/profile文件里$PATH环境变量,将ruby的bin目录添加进去
vi /etc/profile
export PATH=$PATH:/usr/local/ruby/bin
配置完成后,使用source命令应用
source /etc/profile
(二)、数据库配置
创建连接数据库账号并授权:
ksql>CREATE USER FLYSYNC SUPERUSER PASSWORD '123456';
(三)、KFS安装
1、配置flysync.ini
[defaults]
install-directory=/home/flysync/kfsrep
profile-script=~/.bash_profile
rmi-port=11000
[oracle11g_kingbase8]
role=slave
master=oracle
master-kufl-port=3112
members=kes8
kufl-port=3112
replication-host=192.168.100.114
replication-port=54321
replication-user=flysync
replication-password=123456
datasource-type=kingbase
datasource-version=8
kingbase-dbname=TEST
svc-parallelization-type=none
svc-remote-filters=casetransform,rename
property=replicator.filter.casetransform.to_upper_case=false
property = replicator.filter.rename.definitionsFile=/home/flysync/kfsrep/filters-config/oracle11g_kingbase8_rename.csv
property=replicator.applier.dbms.optimizeRowEvents=true
property=replicator.applier.dbms.maxRowBatchSize=5000
[mysql80_kingbase8]
role=slave
master=mysql
master-kufl-port=3112
members=kes8
kufl-port=3113
replication-host=192.168.100.114
replication-port=54321
replication-user=flysync
replication-password=123456
datasource-type=kingbase
datasource-version=8
kingbase-dbname=TEST
svc-parallelization-type=none
svc-remote-filters=casetransform,rename
property=replicator.filter.casetransform.to_upper_case=false
property = replicator.filter.rename.definitionsFile=/home/flysync/kfsrep/filters-config/mysql80_kingbase8_rename.csv
property=replicator.applier.dbms.optimizeRowEvents=true
property=replicator.applier.dbms.maxRowBatchSize=5000
[sqlserver2017_kingbase8]
role=slave
master=sqlserver
master-kufl-port=3112
members=kes8
kufl-port=3114
replication-host=192.168.100.114
replication-port=54321
replication-user=flysync
replication-password=123456
datasource-type=kingbase
datasource-version=8
kingbase-dbname=TEST
svc-parallelization-type=none
svc-remote-filters=casetransform,rename
property=replicator.filter.casetransform.to_upper_case=false
property = replicator.filter.rename.definitionsFile=/home/flysync/kfsrep/filters-config/sqlserver2017_kingbase8_rename.csv
property=replicator.applier.dbms.optimizeRowEvents=true
property=replicator.applier.dbms.maxRowBatchSize=5000
2、安装
cd /home/flysync/KingbaseFlySync-V001R005C002B20210524-replicator/tools
./fspm install
3、复到license文件到安装目录
cp license.dat /home/flysync/kesrep/license.dat
4、修改rename文件
(1)、oracle11g_kingbase8服务的rename文件
vi /home/flysync/kfsrep/filters-config/oracle11g_kingbase8_rename.csv
FLYSYNC,trep_commit_seqno,*,flysync_oracle11g_kingbase8,-,-
FLYSYNC,consistency,*,flysync_oracle11g_kingbase8,-,-
FLYSYNC,heartbeat,*,flysync_oracle11g_kingbase8,-,-
FLYSYNC,trep_shard,*,flysync_oracle11g_kingbase8,-,-
FLYSYNC,trep_shard_channel,*,flysync_oracle11g_kingbase8,-,-
test,*,*,test1,-,-
(2)、mysql80_kingbase8服务的rename文件
vi /home/flysync/kfsrep/filters-config/mysql80_kingbase8_rename.csv
flysync_mysql80,*,*,flysync_mysql80_kingbase8,-,-
test,*,*,test2,-,-
(3)、sqlserver2017_kingbase8服务的rename文件
vi /home/flysync/kfsrep/filters-config/sqlserver2017_kingbase8_rename.csv
flysync_sqlserver2017,*,*,flysync_sqlserver2017_kingbase8,-,-
test,*,*,test3,-,-
6、启动并初始化
/home/flysync/kesrep/flysync/cluster-home/bin/startall
source ~/.bash_profile
查看KFS状态
replicator status
查看服务状态
fsrepctl status
查看KUFL列表
kufl list
六、数据搬迁
(一)、表结构迁移
表结构迁移使用极速搬迁模式,在目标端执行,每个目标端服务执行一次。
ddlscan -target.service oracle11g_kingbase8 -source.user FLYSYNC -source.pass 123456 -source.db orcl -source.dbtype oracle -source.host 192.168.100.111 -source.port 1521 -source.schema TEST -target.db test -mgType 0
ddlscan -target.service mysql80_kingbase8 -source.user flysync -source.pass 123456 -source.db test -source.dbtype mysql -source.host 192.168.100.112 -source.port 3306 -source.schema test -target.db test -mgType 0
ddlscan -target.service sqlserver2017_kingbase8 -source.user flysync_sqlserver2017 -source.pass 123456 -source.db test -source.dbtype mssql -source.host 192.168.100.113 -source.port 1433 -source.schema test -target.db test -mgType 0
(二)、存量数据迁移
数据集中场景,数据迁移可以使用极速模式(目标端流水线快速搬迁),在目标端执行,迁移速度更快,KFS replicator可以不用启动。
loader -source.user FLYSYNC -source.pass 123456 -source.db orcl -source.dbtype oracle -source.host 192.168.100.111 -source.port 1521 -source.schema TEST -target.service oracle11g_kingbase8
loader -source.user flysync -source.pass 123456 -source.db test -source.dbtype mysql -source.host 192.168.100.112 -source.port 3306 -source.schema test -target.service mysql80_kingbase8
3、目标端3(sqlserver2017_kingbase8)
loader -source.user flysync -source.pass 123456 -source.db test -source.dbtype mssql -source.host 192.168.100.113 -source.port 1433 -source.schema test -target.service sqlserver2017_kingbase8