searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

各种数据库CDC开启指导手册

2024-06-03 09:18:01
3
0

MySQL cdc

1. 执行语句 show grants for 'user'查询MySQL账号权限

2. 检查是否包含以下权限:SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT

3. 若权限缺失,用root账号登录MySQL(root账号可能只允许在服务器上登录)

4. 登录语句 mysql -P{port} -u{username} -p

5. 执行语句

(1) GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';

(2) FLUSH PRIVILEGES;

Oracle cdc

1. 登录oracle机器,docker exec -it oracle11g /bin/bash 进入容器,su - root 密码helowin,然后 su - oracle

2. 新建sql脚本 vi exesql.sql,脚本内容如下

shutdown immediate;

startup mount;

3. 执行sqlplus /nolog,切换到管理员用户 conn /as sysdba

4. 执行sql脚本 @ /home/oracle/exesql.sql

5. 执行alter database archivelog; alter database open;

6. 检查日志归档是否开启:archive log list;

7. 设置数据库启用补充日志记录;

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

 

-- 查看是否开启归档模式

select name,log_mode from v$database;

 

Pgsql cdc

1. 登录pgsql的机器,进入容器docker exec -it postgresql13 /bin/bash

2. 修改/var/lib/postgresql/postgresql.conf,将wal_level属性改成logical

3. docker restart postgresql13

4.  ALTER TABLE tablename REPLICA IDENTITY FULL;

Sqlserver cdc

1.执行开启代理语句:

sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'Agent XPs', 1;

GO

RECONFIGURE

2. 登录sqlserver机器,docker exec -it sqlserver /bin/bash

3. 启用 SQL Server 代理:

执行/opt/mssql/bin/mssql-conf set sqlagent.enabled true 

5. 退出容器,重启sqlserver:docker restart sqlserver

6. sqlserver客户端运行:

 

-- 开启数据库CDC

USE 库名;

GO

EXEC sys.sp_cdc_enable_db;

USE tlsoft;

GO

EXEC sys.sp_cdc_help_change_data_capture

GO

 

-- 开启表CDC

USE 库名

GO

EXEC sys.sp_cdc_enable_table

@source_schema = N'dbo',

@source_name   = N'表名',

@role_name     = N'MyRole',

@filegroup_name = N'PRIMARY',

@supports_net_changes = 0

GO

-- 查询开启cdc的库

select is_cdc_enabled, name from sys.databases;

-- 查看表cdc开启状态

SELECT name, is_tracked_by_cdc FROM sys.tables WHERE name like '%表名%';

0条评论
0 / 1000
l****n
7文章数
0粉丝数
l****n
7 文章 | 0 粉丝
原创

各种数据库CDC开启指导手册

2024-06-03 09:18:01
3
0

MySQL cdc

1. 执行语句 show grants for 'user'查询MySQL账号权限

2. 检查是否包含以下权限:SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT

3. 若权限缺失,用root账号登录MySQL(root账号可能只允许在服务器上登录)

4. 登录语句 mysql -P{port} -u{username} -p

5. 执行语句

(1) GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';

(2) FLUSH PRIVILEGES;

Oracle cdc

1. 登录oracle机器,docker exec -it oracle11g /bin/bash 进入容器,su - root 密码helowin,然后 su - oracle

2. 新建sql脚本 vi exesql.sql,脚本内容如下

shutdown immediate;

startup mount;

3. 执行sqlplus /nolog,切换到管理员用户 conn /as sysdba

4. 执行sql脚本 @ /home/oracle/exesql.sql

5. 执行alter database archivelog; alter database open;

6. 检查日志归档是否开启:archive log list;

7. 设置数据库启用补充日志记录;

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

 

-- 查看是否开启归档模式

select name,log_mode from v$database;

 

Pgsql cdc

1. 登录pgsql的机器,进入容器docker exec -it postgresql13 /bin/bash

2. 修改/var/lib/postgresql/postgresql.conf,将wal_level属性改成logical

3. docker restart postgresql13

4.  ALTER TABLE tablename REPLICA IDENTITY FULL;

Sqlserver cdc

1.执行开启代理语句:

sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'Agent XPs', 1;

GO

RECONFIGURE

2. 登录sqlserver机器,docker exec -it sqlserver /bin/bash

3. 启用 SQL Server 代理:

执行/opt/mssql/bin/mssql-conf set sqlagent.enabled true 

5. 退出容器,重启sqlserver:docker restart sqlserver

6. sqlserver客户端运行:

 

-- 开启数据库CDC

USE 库名;

GO

EXEC sys.sp_cdc_enable_db;

USE tlsoft;

GO

EXEC sys.sp_cdc_help_change_data_capture

GO

 

-- 开启表CDC

USE 库名

GO

EXEC sys.sp_cdc_enable_table

@source_schema = N'dbo',

@source_name   = N'表名',

@role_name     = N'MyRole',

@filegroup_name = N'PRIMARY',

@supports_net_changes = 0

GO

-- 查询开启cdc的库

select is_cdc_enabled, name from sys.databases;

-- 查看表cdc开启状态

SELECT name, is_tracked_by_cdc FROM sys.tables WHERE name like '%表名%';

文章来自个人专栏
大数据平台
7 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0