当前位置: 首页 > INSTALL > 正文

使用clone方式安装数据库

当我们在配置DG环境的时候,我们需要在备库主机上安装数据库软件,如果源库安装了很多PATCH,那么我们备库使用普通安装的方式+手动打PATCH,那样将消耗大量的时间,使用clone方式安装,那就简单很多,一个小时内就可以安装一套单机数据库软件。有些我们也有可能搭建一个测试环境,要求跟正式环境一样的版本(包括小版本),这里我们也有可能会使用到clone的方式来安装数据库。

    clone安装数据库的方式有很多,如何手动tar后再perl来手动安装,还有就是使用gc来clone安装,特别是使用gc的方式,相当的简单与直观,点点鼠标就可以完成。

    下面介绍的使用tar这种手动安装方式,

1、在源库上tar整个数据库软件

[root@rhel4 db_1]# set -o vi
[root@rhel4 db_1]# tar cvf /soft/10_2_0_4.tar /u01/app/oracle/product/10.2.0/db_1

2、传磅10_2_0_4.tar这个包到目标主机任意位置,要求使用binary的方式传输。

3、目标主机安装前准备工作

3.1 创建用户,可以和源库不一样
[root@test ~]# groupadd -g 211 dba
[root@test ~]# groupadd -g 210 oinstall 
[root@test ~]# useradd -u 211 -g dba -G oinstall oracle10g
echo "oracle"|passwd oracle10g --stdin[root@test ~]# echo "oracle"|passwd oracle10g --stdin
Changing password for user oracle10g.
passwd: all authentication tokens updated successfully.
3.2 修改内核参数
[root@test ~]# echo "kernel.shmmni = 4096 
> kernel.sem = 250 32000 100 128 
> fs.file-max = 65536 
> net.ipv4.ip_local_port_range = 1024 65000 
> net.core.rmem_default = 262144 
> net.core.rmem_max = 262144 
> net.core.wmem_default = 262144 
> net.core.wmem_max = 262144 
> net.ipv4.tcp_wmem = 262144 262144 262144
> net.ipv4.tcp_rmem = 262144 262144 262144">>/etc/sysctl.conf
[root@test ~]# 
3.3 修改ulimit
[root@test ~]# echo "oracle10g soft memlock 5242880
> oracle10g hard memlock 524280
> oracle10g soft nproc 2047 
> oracle10g hard nproc 16384
> oracle10g soft nofile 65536 
> oracle10g hard nofile 65536">> /etc/security/limits.conf
[root@test ~]# echo "session     required      pam_limits.so">>/etc/pam.d/login

4、目标主机解压文件

[root@test soft]# set -o vi
[root@test soft]# tar xvf 10_2_0_4.tar -C /

5、修改oracle用户的bash_profile文件

[oracle10g@test ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl10g
export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$CRS_HOME/lib32:$ORA_CRS_HOME/lib32
export DISPLAY=192.168.111.1:0.0
set -o vi
stty erase ^h
[oracle10g@test ~]$ 
[oracle10g@test ~]$ . ./.bash_profile

6、开始安装

6.1、修改config.c
[oracle10g@test ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle10g@test lib]$ mv config.
config.c  config.o  
[oracle10g@test lib]$ mv config.o config.o.back

/*  SS_DBA_GRP defines the UNIX group ID for adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

/*如果这里两台主机的oracle所属组不一样的时候请记住,修改一下这个地方*/
#define SS_DBA_GRP "dba"
#define SS_OPER_GRP "dba"

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP};
6.2 编译相当的文件
[oracle10g@test lib]$ make -f ins_rdbms.mk config.o
/usr/bin/gcc  -O3  -trigraphs -fPIC -I/u01/app/oracle/product/10.2.0/db_1/rdbms/demo -I/u01/app/oracle/product/10.2.0/db_1/rdbms/public -I/u01/app/oracle/product/10.2.0/db_1/plsql/public -I/u01/app/oracle/product/10.2.0/db_1/network/public -DLINUX -DORAX86_64 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS -DLONG_IS_64 -fno-strict-aliasing -DSS_64BIT_SERVER      -c -o config.o config.c
[oracle10g@test lib]$ make -f ins_rdbms.mk ioracle
chmod 755 /u01/app/oracle/product/10.2.0/db_1/bin

 - Linking Oracle 
rm -f /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle
gcc  -o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle -L/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/stubs/   -Wl,-E `test -f /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/sskgpsmti.o && echo /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/sskgpsmti.o` /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/opimai.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ssoraed.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ttcsoi.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/defopt.o  -Wl,--whole-archive -lperfsrv10 -Wl,--no-whole-archive /u01/app/oracle/product/10.2.0/db_1/lib/nautab.o /u01/app/oracle/product/10.2.0/db_1/lib/naeet.o /u01/app/oracle/product/10.2.0/db_1/lib/naect.o /u01/app/oracle/product/10.2.0/db_1/lib/naedhs.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/config.o  -lserver10 -lodm10 -lnnet10 -lskgxp10 -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lhasgen10 -lcore10 -lskgxn2 -locr10 -locrb10 -locrutl10 -lhasgen10 -lcore10 -lskgxn2   -lclient10  -lvsn10 -lcommon10 -lgeneric10 -lknlopt `if /usr/bin/ar tv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/libknlopt.a | grep xsyeolap.o > /dev/null 2>&1 ; then echo "-loraolap10" ; fi` -lslax10 -lpls10  -lplp10 -lserver10 -lclient10  -lvsn10 -lcommon10 -lgeneric10 `if [ -f /u01/app/oracle/product/10.2.0/db_1/lib/libavserver10.a ] ; then echo "-lavserver10" ; else echo "-lavstub10"; fi` `if [ -f /u01/app/oracle/product/10.2.0/db_1/lib/libavclient10.a ] ; then echo "-lavclient10" ; fi` -lknlopt -lslax10 -lpls10  -lplp10 -ljox10 -lserver10 -lclsra10 -ldbcfg10 -locijdbcst10 -lwwg  `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lmm -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10   -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `if /usr/bin/ar tv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/libknlopt.a | grep "kxmnsd.o" > /dev/null 2>&1 ; then echo " " ; else echo "-lordsdo10"; fi` -lctxc10 -lctx10 -lzx10 -lgx10 -lctx10 -lzx10 -lgx10 -lordimt10 -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lsnls10 -lunls10  -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -laio    `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/10.2.0/db_1/lib -lm    `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/10.2.0/db_1/lib
/u01/app/oracle/product/10.2.0/db_1/lib//libcore10.a(lcd.o)(.text+0xb71): In function `lcdprm':
: warning: the `gets' function is dangerous and should not be used.
mv -f /u01/app/oracle/product/10.2.0/db_1/bin/oracle /u01/app/oracle/product/10.2.0/db_1/bin/oracleO
mv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/oracle /u01/app/oracle/product/10.2.0/db_1/bin/oracle
chmod 6751 /u01/app/oracle/product/10.2.0/db_1/bin/oracle

6.3 、创建/etc/oraInst.loc  
这个文件也可以不用创建,后面会自动创建

[root@test db_1]# cat /etc/oraInst.loc 
inventory_loc=/u01/app/oracle/oraInventory

6.4、开始安装

 [oracle10g@test lib]$  cd $ORACLE_HOME/clone/bin
[oracle10g@test bin]$ perl clone.pl ORACLE_HOME="$ORACLE_HOME" ORACLE_HOME_NAME="Oracle10g2204" 
./runInstaller -silent -clone -waitForCompletion  "ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1" "ORACLE_HOME_NAME=Oracle10g2204" -noConfig -nowait 
You do not have sufficient permissions to access the inventory '/u01/app/oracle/oraInventory'. Installation cannot continue. Make sure that you have read/write permissions to the inventory directory and restart the installer.: Permission denied
[oracle10g@test bin]$ perl clone.pl ORACLE_HOME="$ORACLE_HOME" ORACLE_HOME_NAME="Oracle10g2204"
[root@test app]# chown oracle10g:oinstall oracle

[oracle10g@test bin]$ perl clone.pl ORACLE_HOME="$ORACLE_HOME" ORACLE_HOME_NAME="Oracle10g2204" 
./runInstaller -silent -clone -waitForCompletion  "ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1" "ORACLE_HOME_NAME=Oracle10g2204" -noConfig -nowait 
Starting Oracle Universal Installer...

No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-04-16_07-28-13PM. Please wait ...Oracle Universal Installer, Version 10.2.0.4.0 Production
Copyright (C) 1999, 2008, Oracle. All rights reserved.

You can find a log of this install session at:
 /u01/app/oracle/oraInventory/logs/cloneActions2013-04-16_07-28-13PM.log
....................................................................................................

这里没有输出了。
[root@test OraInstall2013-04-16_07-28-13PM]# strace -p 10395
Process 10395 attached - interrupt to quit
wait4(10396, 
[oracle10g@test bin]$ perl clone.pl ORACLE_HOME="$ORACLE_HOME" ORACLE_HOME_NAME="Oracle10g2204" 
./runInstaller -silent -clone -waitForCompletion  "ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1" "ORACLE_HOME_NAME=Oracle10g2204" -noConfig -nowait 
Starting Oracle Universal Installer...

No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-04-16_08-02-12PM. Please wait ...Oracle Universal Installer, Version 10.2.0.4.0 Production
Copyright (C) 1999, 2008, Oracle. All rights reserved.

You can find a log of this install session at:
 /u01/app/oracle/oraInventory/logs/cloneActions2013-04-16_08-02-12PM.log
.................................................................................................... 100% Done.

Installation in progress (Tuesday, April 16, 2013 8:02:23 PM CST)
..........................................................................                                                      74% Done.
Install successful

Linking in progress (Tuesday, April 16, 2013 8:02:30 PM CST)
Link successful

Setup in progress (Tuesday, April 16, 2013 8:04:12 PM CST)
Setup successful

End of install phases.(Tuesday, April 16, 2013 8:04:14 PM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root script to run
/u01/app/oracle/product/10.2.0/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 Oracle10g2204 was successful.
Please check '/u01/app/oracle/oraInventory/logs/cloneActions2013-04-16_08-02-12PM.log' for more details.

6.5、执行root.sh文件
[root@test ~]# /u01/app/oracle/product/10.2.0/db_1/root.sh
Running Oracle10 root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle10g
    ORACLE_HOME=  /u01/app/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
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.
[root@test ~]#

到此,安装成功,下面的工作就是配置监听,搭建DG或者创建相应的数据库了。

 



 

本文固定链接: http://www.htz.pw/2013/04/17/%e4%bd%bf%e7%94%a8clone%e6%96%b9%e5%bc%8f%e5%ae%89%e8%a3%85%e6%95%b0%e6%8d%ae%e5%ba%93.html | 认真就输

该日志由 huangtingzhong 于2013年04月17日发表在 INSTALL 分类下, 通告目前不可用,你可以至底部留下评论。
原创文章转载请注明: 使用clone方式安装数据库 | 认真就输
关键字: , , ,