您好,登錄后才能下訂單哦!
Oracle用戶環境變量配置:
ORACLE_BASE=/orcl/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH
export PATH
export NLS_LANG=american_america.AL32UTF8
主庫:
1. 將primary數據庫設置為force logging模式
select force_logging from v$database;
alter database force logging;
2. 創建密碼文件(如果沒有)
orapwd file=$ORACLE_HOME/dbs/orapworcl password=syspassword entries=30;
3. 將主庫至于歸檔模式
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
4. disabled selinux
cat /etc/selinux/config | grep 'SELINUX'
5. 配置standby redo log
select GROUP#,BYTES/1024/1024 size_M,STATUS,ARCHIVED from v$log; # 查詢當前日志組大小
alter database add standby logfile group 4 ('/orcl/app/oracle/oradata/orcl/standbyrd01.log') size 200M;
alter database add standby logfile group 5 ('/orcl/app/oracle/oradata/orcl/standbyrd02.log') size 200M;
alter database add standby logfile group 6 ('/orcl/app/oracle/oradata/orcl/standbyrd03.log') size 200M;
alter database add standby logfile group 7 ('/orcl/app/oracle/oradata/orcl/standbyrd04.log') size 200M;
alter database drop standby logfile group 4; # 刪除
select group#,thread#,sequence#,archived,status from v$standby_log; # 驗證
6. 生成控制文件
alter database create standby controlfile as '/orcl/app/oracle/oradata/orcl/orcldg01.ctl';
7. 生成初始化參數文件
create pfile from spfile;
vi $ORACLE_HOME/dbs/initorcl.ora(添加以下內容)
*.log_file_name_convert='/orcl/app/oracle/oradata/orcl/','/orcl/app/oracle/oradata/orcl/'
*.db_unique_name='orcl1'
*.fal_client='orcl1'
*.fal_server='orcldg'
*.log_archive_config='DG_CONFIG=(orcl1,orcldg)'
*.log_archive_dest_1='LOCATION=/orcl/app/oracle/oradata/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl1'
*.log_archive_dest_2='SERVICE=orcldg LGWR ASYNC VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=orcldg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.standby_file_management='AUTO'
*.remote_login_passwordfile='EXCLUSIVE'
*.log_archive_format=%t_%s_%r.arc
create spfile from pfile='initorcl.ora'
8. 修改listener.ora文件
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
ADR_BASE_LISTENER=/orcl/app/oracle
9. 修改tnsnames.ora文件
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCLDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01-dg)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcldg)
)
)
10. shutdown immediate
11. 傳輸控制文件、初始化參數文件、監聽文件、密碼文件到備機
cd /orcl/app/oracle/product/12.2.0/db_1/network/admin
scp listener.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin
scp tnsnames.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin
scp sqlnet.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin
cd /orcl/app/oracle/oradata/orcl
scp orcldg01.ctl nginx01-dg:/orcl/app/oracle/oradata/orcl/
cd /orcl/app/oracle/product/12.2.0/db_1/dbs
scp initorcl.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora
scp orapworcl nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/dbs/orapworcl
12. 在主庫上RMAN備份恢復到standby:
1. 主庫啟動到mount狀態,備庫啟動到nomount狀態
2. rman target sys/abcd1234@orcl auxiliary sys/abcd1234@orcldg
3. duplicate target database for standby nofilenamecheck from active database; # 主備機目錄一致使用nofilenamecheck參數
備庫:
1. disabled selinux
cat /etc/selinux/config | grep 'SELINUX'
2. 創建目錄
mkdir -p /orcl/app/oracle/oradata/orcl/
mkdir -p /orcl/app/oracle/admin/orcl/adump
3. 修改主庫傳過來的初始化參數文件initorcl.ora文件
*.control_files='/orcl/app/oracle/oradata/orcl/orcldg01.ctl','/orcl/app/oracle/oradata/orcl/orcldg02.ctl'
*.log_file_name_convert='/orcl/app/oracle/oradata/orcl/','/orcl/app/oracle/oradata/orcl/'
*.db_unique_name='orcldg'
*.fal_client='orcldg'
*.fal_server='orcl1'
*.log_archive_config='DG_CONFIG=(orcl1,orcldg)'
*.log_archive_dest_1='LOCATION=/orcl/app/oracle/oradata/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcldg'
*.log_archive_dest_2='SERVICE=orcl1 LGWR ASYNC VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=orcl1'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.standby_file_management='AUTO'
*.log_archive_format=%t_%s_%r.arc
*.remote_login_passwordfile='EXCLUSIVE
4. listener.ora和tnsnames.ora文件不用做任何修改
5. 啟動(rman備份恢復完成后)
alter database mount standby database;
alter database open read only;
alter database recover managed standby database disconnect from session;
alter database set standby database to maximize availability;
6. 查詢驗證
select switchover_status,open_mode,database_role,db_unique_name,protection_mode,protection_level from v$database;
select SEQUENCE#,FIRST_TIME,NEXT_TIME ,APPLIED from v$archived_log order by 1;
select max(sequence#) from v$log;
7. 關機
alter database recover managed standby database cancel;
shutdown immediate;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。