Notes for copying Oracle Home

Source: Internet
Author: User
Tags perl script

Recently, I encountered several problems when I copied the Oracle Home ($ ORACLE_HOME) directory to install Oracle.

First, the Oracle OS users, groups, kernel parameters, and environment variables (~ /. Bash_profile). For those who have installed Oracle, This is a float cloud.

If the Oracle Home Directory of the source and target machines is the same as that of the user and group, copy the Directory and run root. sh again, which is very simple.

If the Oracle Home Directory of the source and target machines is the same, the users and groups are different (mainly because the user IDs are different). After copying them, you need to reset the chown-R user to which the file belongs: group $ ORACLE_HOME, then relink all (relink all can refer to this Article), and then run root. sh is enough, but it's no big deal.

If the user, group, and Oracle Home Directories are different, it will be troublesome, that is, the key content of this article, to simulate this process.

First introduce the environment, source machine:

1 [oracle@test01 oracle]$ echo $ORACLE_BASE 
2 /u01/app/oracle
3 [oracle@test01 oracle]$ echo $ORACLE_HOME 
4 /u01/app/oracle/11.2.0.2
5 [oracle@test01 oracle]$ id
6 uid=1003(oracle) gid=501(oracle) groups=501(oracle)

Target machine:

1 [ora11g@test06 ora11g]$ echo $ORACLE_BASE 
2 /u01/app/ora11g
3 [ora11g@test06 ora11g]$ echo $ORACLE_BASE 
4 /u01/app/ora11g/product/11.2.0.2/db_1
5 [ora11g@test06 ora11g]$ id
6 uid=731(ora11g) gid=700(oradba) groups=700(oradba)

First, package Oracle Home on the source machine, run it as the root user, and retain relevant permissions to copy them to the target machine:

1 [oracle@test01 oracle]$ echo $ORACLE_HOME
2 /u01/app/oracle/11.2.0.2
3 [oracle@test01 oracle]$ exit
4 [oracle@test01 ~]$ cd /u01/app/oracle/
5 [root@test01 oracle]# tar zcvfp 11.2.0.2.tar.gz ./11.2.0.2/
6 [root@test01 oracle]# scp ./11.2.0.2.tar.gz 10.168.0.206:/u01/app/ora11g/product/11.2.0.2/

There is nothing to do with the source machine. decompress the compressed package on the target machine and replace the New Oracle Home Directory. Of course, the file ownership should be well done:

01 [root@test06 ~]# cd /u01/app/ora11g/product/11.2.0.2/
02 [root@test06 11.2.0.2]# tar zxvf 11.2.0.2.tar.gz 
03 [root@test06 11.2.0.2]# ll
04 total 2129880
05 drwxr-xr-x 75   1003 oradba       4096 Nov 20 22:19 11.2.0.2
06 -rw-r--r--  1 root   root   2178854174 Jan 21 09:35 11.2.0.2.tar.gz
07 drwxr-xr-x  2 ora11g oradba       4096 Jan 21 09:47 db_1
08 [root@test06 11.2.0.2]# rm -rf db_1/
09 [root@test06 11.2.0.2]# mv 11.2.0.2 db_1
10 [root@test06 11.2.0.2]# chown -R ora11g:oradba ./db_1/

Modify $ ORACLE_HOME/rdbms/lib/config. c to change the group name of the Oracle user, and relink all:

01 [root@test06 ~]# su - ora11g
02 [ora11g@test06 ~]$ cat $ORACLE_HOME/rdbms/lib/config.c
03   
04 /*  SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access.  */
05 /*  Refer to the Installation and User's Guide for further information.  */
06   
07 /* IMPORTANT: this file needs to be in sync with
08               rdbms/src/server/osds/config.c, specifically regarding the
09               number of elements in the ss_dba_grp array.
10  */
11   
12 #define SS_DBA_GRP "oradba"
13 #define SS_OPER_GRP "oradba"
14 #define SS_ASM_GRP "oradba"
15   
16 char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};   
17 [ora11g@test06 ~]$ relink all

To modify the oraInst. loc file in $ ORACLE_HOME, fill in the correct oraInventory directory. This oraInventory can not be created, but the parent directory must exist, and Oracle users can write (create directory ):

01 [ora11g@test06 ~]$ cd $ORACLE_HOME
02 [ora11g@test06 db_1]$ cp oraInst.loc{,.bak}
03 [ora11g@test06 db_1]$ vim oraInst.loc
04 [ora11g@test06 db_1]$ more oraInst.loc*   
05 ::::::::::::::
06 oraInst.loc
07 ::::::::::::::
08 inventory_loc=/u01/app/ora11g/oraInventory
09 inst_group=oradba
10 ::::::::::::::
11 oraInst.loc.bak
12 ::::::::::::::
13 inventory_loc=/u01/app/oracle/oraInventory
14 inst_group=oradba

Modify $ ORACLE_HOME/clone/config/cs. properties and add the parameter-invPtrLoc to indicate the path of oraInst. loc:

1 [ora11g@test06 db_1]$ cd $ORACLE_HOME/clone/config
2 [ora11g@test06 config]$ cat cs.properties 
3 # Copyright (c) 2005, Oracle. All rights reserved.  
4   
5 # clone command line
6 clone_command_line= -silent -noConfig -nowait -invPtrLoc "/u01/app/ora11g/product/11.2.0.2/db_1/oraInst.loc"

Go to the $ ORACLE_HOME/clone/bin directory and execute a perl script:

1 ./clone.pl \
2 ORACLE_HOME="/u01/app/ora11g/product/11.2.0.2/db_1" \
3 ORACLE_BASE="/u01/app/ora11g" \
4 OSDBA_GROUP="oradba" \
5 OSOPER_GROUP="oradba" \
6 OSASM_GROUP="oradba" \
7 ORACLE_HOME_NAME="OracleHome1"
 
01 [ora11g@test06 config]$ cd $ORACLE_HOME/clone/bin
02 [ora11g@test06 bin]$ ls
03 clone.pl  prepare_clone.pl
04 [ora11g@test06 bin]$ ./clone.pl \
05 [ora11g@test06 bin]> ORACLE_HOME="/u01/app/ora11g/product/11.2.0.2/db_1" \
06 [ora11g@test06 bin]> ORACLE_BASE="/u01/app/ora11g" \
07 [ora11g@test06 bin]> OSDBA_GROUP="oradba" \
08 [ora11g@test06 bin]> OSOPER_GROUP="oradba" \
09 [ora11g@test06 bin]> OSASM_GROUP="oradba" \
10 [ora11g@test06 bin]> ORACLE_HOME_NAME="OracleHome1"

Finally, run the $ ORACLE_HOME root. sh command as the root user as prompted.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.