本文主要是介绍DG数据迁移方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 数据构造
- 检查数据构造之前主备的状态
主库: SQL> select name,open_mode,switchover_status from v$database; 备库: SQL> select name,open_mode,switchover_status from v$database; |
-
- 主库创建用户
创建表空间: CREATE TABLESPACE MYTBS DATAFILE '/opt/oracle/oradata/ITPUXDB/MYTBS.DBF' SIZE 500M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED; 创建用户配置文件 create profile zgcprofile limit password_life_time 10 failed_login_attempts 3 password_lock_time 1; 创建用户 create user zgc identified by 123456 default tablespace MYTBS Quota 20m on MYTBS Profile zgcprofile; 权限授予: GRANT CONNECT TO zgc; GRANT CREATE TABLE,CREATE INDEXTYPE TO zgc; GRANT DBA TO zgc; |
-
- 数据构造
见《oracle数据库验证数据构造方案》 |
-
- 创建一览
查看学生表 select * from students; 查看教师表 select * from teachers; 查看班级表 select * from classes; |
- 主备切换
- 主库切备库(在主库中操作)
sqlplus / as sysdba SQL>startup SQL> select name,open_mode,switchover_status from v$database; SQL> alter system switch logfile; SQL> alter system archive log current; SQL> alter database commit to switchover to physical standby with session shutdown; SQL> shutdown abort SQL> startup mount SQL> select switchover_status from v$database; SQL> alter database open; SQL> select switchover_status from v$database; |
-
- 备库切主库(在备库中操作)
在主库启动时,备库在mount状态 记得在之前: 开启数据同步 sqlplus / as sysdba SQL>startup mount SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; SQL> alter database commit to switchover to primary with session shutdown; SQL> alter database open; SQL> select name,open_mode,switchover_status from v$database; |
-
- 新备库(原主库)启用实时日志应用
SQL> alter database recover managed standby database using current logfile disconnect from session; SQL> select name,open_mode,switchover_status from v$database; |
-
- 新主库切换日志
SQL> alter system switch logfile; |
-
- 分别查看当前主备库切换后当前日志序列
主库: SQL> archive log list 备库: SQL> archive log list |
-
- 查看当前主备库状态
主库: SQL> select name,open_mode,switchover_status from v$database; 备库: SQL> select name,open_mode,switchover_status from v$database; |
- 数据验证(展示一部分)
- 查看表和数据
select * from students; select * from teachers; select * from classes; |
完成
这篇关于DG数据迁移方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!