首页 > 代码库 > Oracle 11.2.4.0 ACTIVE DATAGUARD 单实例安装(COPY创建备库)
Oracle 11.2.4.0 ACTIVE DATAGUARD 单实例安装(COPY创建备库)
Oracle 11.2.4.0 ADG 单实例安装(COPY创建备库)
规划:
主:
OS: Linux Centos 6.5 X64
hostname:ORA11G-DG1
ipaddress:192.168.213.199
db_unique_name=netdata_pd
db_name=netdata
备:
OS: Linux Centos 6.5 X64
hostname:ORA11G-DG2
ipaddress:192.168.213.200
db_unique_name=netdata_sd
db_name=netdata
注OS平台一致
1.主库安装oracle软件(参照文档)
2.创建监听,可以用netca,也可以直接用文件创建
listener.ora如下
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORA11G-DG1)(PORT = 51518))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC51518))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = netdata)
(SID_NAME = netdata)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
2.主库dbca建库,注意生产环境的一些参数SGA,PGA,PROCESS,归档位置,open_cursor,flash_recovery位置等等,如果要使用EM开始的时候需要建端口1521监听
3.主库tnames.ora配置
NETDATA_SD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.200)(PORT = 51518))
)
(CONNECT_DATA = http://www.mamicode.com/
(SERVICE_NAME = netdata)
)
)
NETDATA_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.199)(PORT = 51518))
)
(CONNECT_DATA = http://www.mamicode.com/
(SERVICE_NAME = netdata)
)
)
4.备库安装oracle软件仅安装软件(请参照之前安装软件)
5.备库配置listener.ora,tnames.ora
listener.ora如下:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ORA11G-DG2)(PORT = 51518))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC51518))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = netdata)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = netdata)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
tnames.ora如下:
NETDATA_SD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.200)(PORT = 51518))
)
(CONNECT_DATA = http://www.mamicode.com/
(SERVICE_NAME = netdata)
)
)
NETDATA_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.199)(PORT = 51518))
)
(CONNECT_DATA = http://www.mamicode.com/
(SERVICE_NAME = netdata)
)
)
6.主库参数文件配置
主库强制forceloing
SQL> ALTER DATABASE FROCE LOGGING;
SQL> select FORCE_LOGGING from v$database;
YES
参数文件配置
alter system set DB_UNIQUE_NAME=netdata_pd scope=spfile;
alter system set LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(netdata_pd,netdata_sd)‘ scope=both;
alter system set LOG_ARCHIVE_DEST_1=‘LOCATION=/oradata/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=netdata_pd‘ scope=both;
alter system set LOG_ARCHIVE_DEST_2=‘SERVICE=netdata_sd LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=netdata_sd‘;
alter system set standby_file_management=‘AUTO‘ sid=‘*‘ scope=both;
alter system set fal_client=‘netdata_pd‘;
alter system set fal_server=‘netdata_sd‘;
alter system set db_file_name_convert=‘/oradata/netdata‘,‘/oradata/netdata‘ SCOPE=SPFILE;
alter SYSTEM SET log_file_name_convert=‘/oradata/netdata‘,‘/oradata/netdata‘ SCOPE=SPFILE;
7.为备库创建参数文件
create pfile=‘/oradata/standby.ora‘ from spfile
编辑standby.ora
修改
*.db_unique_name=‘NETDATA_PD‘
*.log_archive_config=‘DG_CONFIG=(netdata_pd,netdata_sd)‘
*.log_archive_dest_1=‘LOCATION=/oradata/archive
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=netdata_pd‘
*.log_archive_dest_2=‘SERVICE=netdata_sd ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=netdata_sd‘
*.fal_client=‘NETDATA_PD‘
*.fal_server=‘NETDATA_SD‘
*.log_file_name_convert=‘/oradata/netdata‘,‘/oradata/netdata‘
*.standby_file_management=‘AUTO‘
*.db_file_name_convert=‘/oradata/netdata‘,‘/oradata/netdata‘
8.为备库创建控制文件
alter database create standby controlfile as ‘/oradata/control01.ctl‘;
9.关闭主库将数据文件,参数文件,密码文件($ORACLE_HOME/dbs/orapwnetdata linux为orapw$ORACLE_SID),admin文件
注:备库创建所需要目录 用oracle用户创建
--数据文件目录
mkdir -p /oradata/netdata
--recovery目录
mkdir -p /oradata/recovery_area
--归档目录
mkdir -p /oradata/archive
--admin目录
mkdir -p /u01/app/oracle/admin/
拷贝数据文件及redo文件
scp -r /oradata/netdata/*.log oracle@192.168.213.200:/oradata/netdata/
scp -r /oradata/netdata/*.dbf oracle@192.168.213.200:c
拷贝admin目录
scp -r /u01/app/oracle/admin/* oracle@192.168.213.200:/u01/app/oracle/admin/
拷贝参数文件
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/control01.ctl
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/control02.ctl
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/recovery_area/control03.ctl
注意一定要copy全不然启动备库会报错的
拷贝密码文件
scp -r $ORACLE_HOME/dbs/orapwnetdata oracle@192.168.213.200:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwnetdata
10.为主备库创建standbylog
主:
startup
ALTER DATABASE ADD STANDBY LOGFILE group 4(‘/oradata/netdata/stredo01.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 5(‘/oradata/netdata/stredo02.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 6(‘/oradata/netdata/stredo03.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 7(‘/oradata/netdata/stredo04.log‘) SIZE 50M;
注意这里大小要跟redolog一致,比redolog多一组
备:
sqlplus /nolog
create spfile from pfile=‘/oradata/netdata/standby.ora‘;
startup mount;
ALTER DATABASE ADD STANDBY LOGFILE group 4(‘/oradata/netdata/stredo01.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 5(‘/oradata/netdata/stredo02.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 6(‘/oradata/netdata/stredo03.log‘) SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 7(‘/oradata/netdata/stredo04.log‘) SIZE 50M;
11.检验主库是否同步
备操作:
shutdown immediate;
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
检验主备是否一致
archive log list;
col name format A50;
col dest_name format A40
col error format A20
set line 200;
select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log);
col dest_name format A40
select dest_name,status,error from v$archive_dest where rownum<3;
启动ADG:
alter database recover managed standby database cancel;
alter database open read only;
alter database recover managed standby database using current logfile disconnect from session;
Oracle 11.2.4.0 ACTIVE DATAGUARD 单实例安装(COPY创建备库)