現有環境已經有一台作為 production 的 Oracle DB,且該 DB 已有最後的 Patchset,此篇教學應用為:
注意:
從一台已安裝有最新 patchset 且很穩定的 DB 裡,在不用停機狀態下,直接將 $ORACLE_HOME 目錄,以 tar 方式複製
echo $ORACLE_HOME /opt/oracle/product/10.2.0/db_1 cd /opt/oracle/product/ tar czf Oracle_Home_102054_Clone.tar 10.2.0/
以下步驟要在另一部準備安裝 DB 的 Linux 機器上執行,並將 OracleHome 複製檔 Oracle_Home_102054_Clone.tar 上傳至機器上。
環境變數為
ORACLE_BASE=/opt/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/10.2.0.5.4/db_1; export ORACLE_HOME ORACLE_SID=win; export ORACLE_SID
安裝步驟
用 root 執行
mkdir -p /opt/oracle/product/10.2.0.5.4/db_1 chown -R oracle:dba /opt/oracle
用 oracle 執行
su - oracle cd /opt/oracle/product mkdir clone_oracle/ cd clone_oracle/ tar xf /mnt/nas_na/alang/Oracle_Home_102054_Clone.tar mv 10.2.0/* ../10.2.0.5.4/db_1/ cd $ORACLE_HOME/network/admin/ rm *.ora cd $ORACLE_HOME/dbs rm -rf * cd $ORACLE_HOME/oui/bin/ ./runInstaller -silent -clone ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME=ora_102054
Setup in progress (Thursday, March 20, 2014 5:28:40 PM CST) Setup successful End of install phases.(Thursday, March 20, 2014 5:28:44 PM CST) WARNING: The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root script to run /opt/oracle/product/10.2.0.5.4/db_1/root.sh To execute the configuration scripts: 1. Open a terminal window 2. Log in as "root" 3. Run the scripts The cloning of ora_102054 was successful. Please check '/opt/oracle/oraInventory/logs/cloneActions2014-03-20_05-27-04PM.log' for more details.
TIP:
如果出現 oraInventory 路徑錯誤,檢查檔案 /etc/oraInst.loc 內容
su - /opt/oracle2/product/10.2.0.5.4/db_1/root.sh
任一種方式
原 DB 的環境變數
ORACLE_BASE=/opt/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
用 oracle 執行
su - oracle cd /opt/oracle/product mkdir -p 10.2.0.5.4/db_1 mkdir clone_oracle/ cd clone_oracle/ tar xf /mnt/nas_na/alang/Oracle_Home_102054_Clone.tar mv 10.2.0/* ../10.2.0.5.4/db_1/ export ORACLE_HOME=/opt/oracle/product/10.2.0.5.4/db_1 cd $ORACLE_HOME/network/admin/ rm *.ora cd $ORACLE_HOME/dbs rm -rf * cd $ORACLE_HOME/oui/bin/ ./runInstaller -silent -clone ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME=ora_102054
...
Setup in progress (Friday, March 21, 2014 9:22:17 AM CST)
Setup successful
End of install phases.(Friday, March 21, 2014 9:22:22 AM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root script to run
/opt/oracle/product/10.2.0.5.4/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
The cloning of ora_102054 was successful.
Please check '/opt/oracle/oraInventory/logs/cloneActions2014-03-21_09-20-37AM.log' for more details.
以 root 執行
/opt/oracle/product/10.2.0.5.4/db_1/root.sh
Running Oracle 10g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/10.2.0.5.4/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying dbhome to /usr/local/bin ...
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying oraenv to /usr/local/bin ...
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: y
Copying coraenv to /usr/local/bin ...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
以 oracle 執行
停止原 DB 服務
su - oracle echo $ORACLE_HOME /opt/oracle/product/10.2.0/db_1 lsnrctl stop ps -ef | grep -i listener sqlplus / as sysdba SQL> shutdown immediate SQL> exit
開始對 DB 作升級
cp -a .bash_profile bash_profile.bak vi .bash_profile
將 ORACLE_HOME 改成新的
...
ORACLE_HOME=$ORACLE_BASE/product/10.2.0.5.4/db_1; export ORACLE_HOME
...
exit su - oracle which sqlplus /opt/oracle/product/10.2.0.5.4/db_1/bin/sqlplus <== 必須是新的路徑 cp -a /opt/oracle/product/10.2.0/db_1/dbs/* /opt/oracle/product/10.2.0.5.4/db_1/dbs/ cp -a /opt/oracle/product/10.2.0/db_1/network/admin/* /opt/oracle/product/10.2.0.5.4/db_1/network/admin/ sqlplus / as sysdba SQL> startup upgrade