cent os 6.6 x64 自動配置oracle 11gr2物理standby指令碼
前提:測試指令碼是根據上一篇cent os 6.6 x64 自動靜默安裝oracle 11gr2指令碼 安裝的兩臺db,比較乾淨,所以配置standby比較簡單
os:centos 6.6
oracle:11.2.0.4
primary ip:192.108.56.119
primary hostname:ct6602
standby ip:192.108.56.121
standby hostname:ct6604
----以下內容在primary DB上放在一個文字下,oracle使用者下sh執行即可:
#!/bin/bash
mkdir /u03/archivelog/ct6602
sqlplus / as sysdba << EOF
shutdown immediate;
startup mount;
alter database archivelog;
alter system set log_archive_dest_1='LOCATION=/u03/archivelog/ct6602 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=ct6602';
alter database open;
alter database force logging;
alter system set log_archive_config='DG_CONFIG=(ct6602,ct6602sb)';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=ct6602sb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,primary_ROLE) DB_UNIQUE_NAME=ct6602sb';
alter system set FAL_SERVER='ct6602sb';
alter system set FAL_CLIENT='ct6602';
alter system set db_file_name_convert='ct6602sb','ct6602' scope=spfile;
alter system set log_file_name_convert='ct6602sb','ct6602' scope=spfile;
alter system set standby_file_management=auto;
create pfile from spfile;
exit
EOF
mkdir /home/oracle/sbbackup
rman target / <<EOF
backup database format '/home/oracle/sbbackup/full_db_%U.dbfbk' plus archivelog format '/home/oracle/sbbackup/full_log_%U.logbk';
backup current controlfile for standby format '/home/oracle/sbbackup/sbctl.ctl';
exit
EOF
cat >> /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora << EOF
CT6602SB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.108.56.121)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ct6602sb)
)
)
EOF
cat > /home/oracle/scpbackup.sh <<EOF
set timeout -1
spawn scp -r /home/oracle/sbbackup oracle@192.108.56.121:/home/oracle/
expect "password:"
send "system\r"
interact
set timeout -1
spawn scp -r /u01/app/oracle/product/11.2.0/db_1/dbs/orapwct6602 oracle@192.108.56.121:/home/oracle/orapwct6602
expect "password:"
send "system\r"
interact
set timeout -1
spawn scp -r /u01/app/oracle/product/11.2.0/db_1/dbs/initct6602.ora oracle@192.108.56.121:/home/oracle/initct6602.ora
expect "password:"
send "system\r"
interact
EOF
expect /home/oracle/scpbackup.sh
----以下內容在standby DB上放在一個文字下,oracle使用者下sh執行即可:
#!/bin/bash
mv /home/oracle/orapwct6602 /u01/app/oracle/product/11.2.0/db_1/dbs/orapwct6602sb
mv /home/oracle/initct6602.ora $ORACLE_HOME/dbs/initct6602sb.ora
cp $ORACLE_HOME/dbs/initct6602sb.ora $ORACLE_HOME/dbs/initct6602sb.ora.bak
cat >> /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora << EOF
CT6602 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.108.56.119)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ct6602)
)
)
EOF
sed -i 's/ct6602sb/selectshen/g' $ORACLE_HOME/dbs/initct6602sb.ora
sed -i 's/ct6602/ct6602sb/g' $ORACLE_HOME/dbs/initct6602sb.ora
sed -i 's/selectshen/ct6602/g' $ORACLE_HOME/dbs/initct6602sb.ora
sed -i "s/db_name='ct6602sb'/db_name='ct6602'/" $ORACLE_HOME/dbs/initct6602sb.ora
echo "*.db_unique_name=ct6602sb" >> $ORACLE_HOME/dbs/initct6602sb.ora
mkdir -p /u01/app/oracle/admin/ct6602sb/adump /u02/oradata/ct6602sb /u01/app/oracle/fast_recovery_area/ct6602sb /u03/archivelog/ct6602sb
ORACLE_SID=ct6602sb
sqlplus / as sysdba <<EOF
create spfile from pfile;
startup nomount;
exit
EOF
rman target / <<EOF
restore standby controlfile from '/home/oracle/sbbackup/sbctl.ctl';
sql 'alter database mount';
restore database;
recover database;
exit;
EOF
sqlplus / as sysdba <<EOF
alter database open;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE disconnect;
select process,thread#,sequence#,status from v\$managed_standby;
exit;
EOF
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-1764041/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- cent os 6.6 x64 自動靜默安裝oracle 11gr2指令碼Oracle指令碼
- cent os 6.6 x64 自動原始碼安裝mysql 5.6指令碼原始碼MySql指令碼
- CENTOS 6.6 x64 自動化安裝Oracle Database 11g R2 RAC指令碼CentOSOracleDatabase指令碼
- 【[Oracle】-【安裝】-Cent OS安裝Oracle ClientOracleclient
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- Oracle物理DG自動切換——Dataguard Broker配置Oracle
- Cent OS 安裝 RedisRedis
- Oracle 11g Aix 雙機 物理Standby配置 01OracleAI
- Oracle 11g Aix 雙機 物理Standby配置 02OracleAI
- Oracle 11g Aix 雙機 物理Standby配置 03OracleAI
- Oracle 11g Aix 雙機 物理Standby配置 04OracleAI
- Oracle物理冷備份指令碼Oracle指令碼
- windows下oracle自動啟動指令碼WindowsOracle指令碼
- 巡檢指令碼OS+Oracle指令碼Oracle
- Cent OS 6升級核心
- Oracle 10g RAC 系統 OS啟動時CRS及例項自動啟動指令碼Oracle 10g指令碼
- oracle自動冷備份指令碼Oracle指令碼
- oracle 巡檢指令碼(自動化)Oracle指令碼
- ORACLE自動備份shell指令碼Oracle指令碼
- oracle報表自動FTP指令碼OracleFTP指令碼
- 自動配置php、mysql、nginx的指令碼PHPMySqlNginx指令碼
- Oracle物理熱備份指令碼(ZT)Oracle指令碼
- VNC cent OS 7操作工具,VNC cent OS 7 操作工具下載!VNC
- Cent os 6.3上安裝rlwrap
- Linux 下oracle自啟動指令碼LinuxOracle指令碼
- oracle 自動冷備份指令碼(轉)Oracle指令碼
- ORACLE10G 物理standby轉為邏輯standbyOracle
- 使用shell生成orabbix自動化配置指令碼指令碼
- 手工ftp拷貝歸檔及指令碼自動恢復Standby方式FTP指令碼
- 配置 Oracle 10g 單例項物理dataguard和邏輯standbyOracle 10g單例
- 配置簡單的linux 的幾個操作步驟(Cent OS)Linux
- ORACLE DUPLICATE建立物理standby資料庫Oracle資料庫
- oracle自帶指令碼Oracle指令碼
- 解剖Nginx·自動指令碼篇(1)解析配置選項指令碼 auto/optionsNginx指令碼
- LINUX 自動執行指令碼的命令配置Linux指令碼
- Oracle ADG 自動切換指令碼分享Oracle指令碼
- Oracle自動備份指令碼的實現Oracle指令碼
- 一個自動生成oracle job的指令碼Oracle指令碼