Cloning an Oracle Home

    版本為 22:55, 26 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    說明

    現有環境已經有一台作為 production 的 Oracle DB,且該 DB 已有最後的 Patchset,此篇教學應用為:

    1. 利用這一台 DB,複製成另一個一模一樣的 DB 環境,有完全一樣的 Oracle 主程式版本,包含所有 patchset
    2. 利用這一台 DB,對另一台尚未套用新 patchset 的 DB 作主程式更新

    注意:

    • 一個 Linux 系統可以有多個不同的 ORACLE_HOM,但 ORACLE_BASE 必須是同一個,因為 Central Inventory 只能有一個。預設路徑及設定檔為
      • /opt/oracle/oraInventory
      • /etc/oraInst.loc

    複製 OracleHome

    從一台已安裝有最新 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/ 
    

    應用一:安裝另一個全新的 Database

    以下步驟要在另一部準備安裝 DB 的 Linux 機器上執行,並將 OracleHome 複製檔 Oracle_Home_102054_Clone.tar 上傳至機器上。

    事前作業
    1. 檢查相依性套件是否已齊全。
    2. 編輯 /etc/hosts
    3. 調整 kernel 參數 /etc/sysctl.conf
    4. 調整 /etc/security/limits.conf
    5. 調整 /etc/pam.d/login
    6. 關閉 firewall, SELinux
    7. 建立 oracle 帳號及群組 dba
    8. 建立 profile 及環境變數,決定 SID
    開始安裝

    環境變數為

    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 
    
    建立資料庫

    任一種方式

    1. 使用 SQL
    2. 使用 dbca

    應用二:對一個現有 DB 作 patch

    原 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 的 Listener

    su - oracle
    echo $ORACLE_HOME
    /opt/oracle/product/10.2.0/db_1
    
    lsnrctl stop 
    

    開始對 DB 作升級

    export ORACLE_HOME=/opt/oracle/product/10.2.0.5.4/db_1
     
    Powered by MindTouch Core