您好,登錄后才能下訂單哦!
首先使用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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。