安装ogg软件
建立ogg软件目录
1 | [root@localhost oracle]# su - oracle |
复制ogg软件到目标机器
解压软件
1 | [oracle@localhost ogg]$ pwd |
软件安装
打开xmanager进入目标机器,进入目录/home/oracle/app/oracle/ogg/fbo_ggs_Linux_x64_shiphome/Disk1,运行runInstaller安装。
选择oracle11g点击下一步
配置后点击下一步
点击安装
主从库初始化设置
如果从库不做其他数据库的主库,那么supplemental log只需要在主库添加即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 [oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 5 12:40:45 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2217464 bytes
Variable Size 486541832 bytes
Database Buffers 293601280 bytes
Redo Buffers 2637824 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database add supplemental log data;
Database altered.
SQL> alter database open;
Database altered.
SQL> create user ogg identified by ogg;
User created.
SQL> grant connect,resource to ogg;
Grant succeeded.
SQL> grant execute on utl_file to ogg;
Grant succeeded.
SQL> grant select any dictionary,select any table to ogg;
Grant succeeded.
SQL> grant alter any table to ogg;
Grant succeeded.
SQL> grant flashback any table to ogg;
Grant succeeded.
SQL> grant execute on DBMS_FLASHBACK to ogg;
Grant succeeded.
SQL> grant dba to ogg;
Grant succeeded.
注意:如果想简单的设置ogg的权限,那么ogg用户只赋dba权限既可。
数据源(主库)设置
进入ogg即运行ggsci命令执行(执行./ggsci):
1 | > dblogin userid ogg password ogg |
目标端(从库)设置
进入ogg即运行ggsci命令执行(执行./ggsci):
1 | >create subdirs |
备份主库的ddl语句并还原到从库
ddl导出
可以使用工具导出ddl语句,这里使用toad,步骤如下:
选择add并点击load rows
选择需要导出的表
选择存储文件并点击导出
在从库创建用户并恢复主库的ddl
创建用户
1 | >CREATE USER SMARTECAP_NUMONE_XJ IDENTIFIED BY <password> ACCOUNT UNLOCK; |
恢复ddl语句
使用toad登录从库的用户SMARTECAP_NUMONE_XJ,执行主库导出的ddl文件。
通过toad工具使主从数据同步,并同步
在从库创建主库的dblink
1 | create database link "source" |
然后每张表都依次执行如下sql语句。为保证数据的一致性在导数过程中(ogg未同步前停止所有主库的应用)
ogg启动
首先在从库ggsci中执行
1 | GGSCI (localhost.localdomain) 1> info all |
然后在主库ggsci中执行
1 | GGSCI (oracle.domain) 23> info all |