首先使用dbca建立一个数据库,db_name=primary 。 2. 为两个数据库准备静态监听。及连接彼此的TNSNAME11gdg1-> cat&nb
首先使用dbca建立一个数据库,db_name=primary 。
2. 为两个数据库准备静态监听。及连接彼此的TNSNAME
11gdg1-> cat listener.ora tnsnames.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = primary)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = primary)
)
(SID_DESC =
(GLOBAL_DBNAME = standby)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = standby)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = 11gdg1.localdomain.com)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.216)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = primary)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.199.216)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)
11gdg1->
3. 为从库创建一个简单的pfile
11gdg1-> echo "db_name=whatever" > initstandby.ora
4. 为从库创建口令文件
11gdg1-> cp orapwprimary orapwstandby
5. 建立从库需要的目录
11gdg1->mkdir -p /u01/app/oracle/admin/standby/adump
11gdg1->mkdir -p /u01/app/oracle/oradata/standby
11gdg1->mkdir -p /u01/app/oracle/fast_recovery_area/standby
6. 启动从数据库到mount
7. 将主库改为FORCE LOGGING
sql> alter database force logging;
Database altered.
8. 开启主库归档
SQL> arcHive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 2
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2233000 bytes
Variable Size 494931288 bytes
Database Buffers 339738624 bytes
Redo Buffers 2379776 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
9. 创建standby log
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/primary/sredo01.log' size 50M;
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/primary/sredo02.log' size 50M;
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/primary/sredo03.log' size 50M;
ALTER DATABASE ADD STANDBY LOGFILE '/u01/app/oracle/oradata/primary/sredo04.log' size 50M;
10. 创建standby数据库
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate channel prmy5 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'primary','standby'
set 'db_unique_name'='standby'
set control_files='/u01/app/oracle/oradata/standby/control01.ctl'
set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
set DB_RECOVERY_FILE_DEST_SIZE='4G'
set log_file_name_convert='/primary/','/standby/'
set db_file_name_convert='/primary/','/standby/'
set fal_server='primary'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(primary,standby)'
set log_archive_dest_2='service=primary LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=primary'
nofilenamecheck;
sql channel prmy1 "alter system set log_archive_config=''dg_config=(primary,standby)''";
sql channel prmy1 "alter system set log_archive_dest_2=''service=standby LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=standby''";
sql channel prmy1 "alter system set log_archive_max_processes=5";
sql channel prmy1 "alter system set fal_server=standby";
sql channel prmy1 "alter system set standby_file_management=AUTO";
sql channel prmy1 "alter system archive log current";
allocate auxiliary channel stby type disk;
sql channel stby "alter database recover managed standby database using current logfile disconnect";
}
11. 验证数据同步
主库
SQL> conn / as sysdba
Connected.
SQL> alter user scott account unlock;
User altered.
SQL> alter user scott identified by tiger;
User altered.
SQL> conn scott/tiger
Connected.
SQL> create table t1 as select * from emp;
Table created.
从库
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open;
Database altered.
SQL> conn scott/tiger
Connected.
SQL> select count(*) from t1;
COUNT(*)
----------
14
--结束END--
本文标题: Oracle学习之DATAGUARD(十) 在同台机器上使用11g rman新特性创建DG
本文链接: https://lsjlt.com/news/35018.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0