如果你需要安装的数据库服务器比较多,使用图形化方式安装数据库软件的速度还是很慢,而且也比较麻烦。Oracle 11g 提供了Clone安装的方法。

步骤如下:

使用正常方法在服务器A上安装好Oracle。

将A机器上的$ORACLE_HOME打包,db_home1.zip 。

将B机器的环境准备好,如建立用户、建立用户、修改内核参数,修改环境变量等等。

将zip包copy到B服务器,解压到任意目录。

执行Clone命令


A机器上打包

[root@localhostoracle]#zip-rdb_1.zip/u01/app/oracle/product/11.2.0/db_1/

2. 准备B机器环境

[root@localhostinst_env_scripts]#./1preusers.sh[root@localhostinst_env_scripts]#./2predir.sh[root@localhostinst_env_scripts]#./3prelimits.sh[root@localhostinst_env_scripts]#./4presysctl.sh

脚本内容如下

[root@localhostinst_env_scripts]#cat1preusers.sh#!/bin/bash#Purpose:Create3groupsnamed'oinstall','dba','oper',plus1usersnamed'oracle'.#AlsosettingtheEnvironment#variablefororacleuser.#variableforgriduser.#Usage:Logonasthesuperuser('root'),andthenexecutethecommand:#./1preusers.sh#Author:dingliqingecho"Nowcreate3groupsnamed'oinstall','dba','oper'"echo"Plus1usersnamed'oracle',AlsosettingtheEnvironment"groupadd-g1000oinstallgroupadd-g1300dbagroupadd-g1301operuseradd-u1101-goinstall-Gdba,oper-d/home/oracle-s/bin/bash-c"OracleSoftwareOwner"oracleecho"oracle"|passwd--stdinoracleecho"exportTMP=/tmp">>/home/oracle/.bash_profileecho'exportTMPDIR=$TMP'>>/home/oracle/.bash_profileecho"exportORACLE_SID=orcl">>/home/oracle/.bash_profileecho"exportORACLE_BASE=/u01/app/oracle">>/home/oracle/.bash_profileecho'exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1'>>/home/oracle/.bash_profileecho'exportTNS_ADMIN=$ORACLE_HOME/network/admin'>>/home/oracle/.bash_profileecho'exportPATH=/usr/sbin:$PATH'>>/home/oracle/.bash_profileecho'exportPATH=$ORACLE_HOME/bin:$PATH'>>/home/oracle/.bash_profileecho'exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib'>>/home/oracle/.bash_profileecho'exportCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib'>>/home/oracle/.bash_profileecho"exportEDITOR=vi">>/home/oracle/.bash_profileecho"exportLANG=en_US">>/home/oracle/.bash_profileecho"exportNLS_LANG=american_america.AL32UTF8">>/home/oracle/.bash_profileecho"exportNLS_DATE_FORMAT='yyyy/mm/ddhh34:mi:ss'">>/home/oracle/.bash_profileecho"umask022">>/home/oracle/.bash_profileecho"TheGroupsandusershasbeencreated"echo"TheEnvironmentfororaclealsohasbeensetsuccessfully"

[root@localhostinst_env_scripts]#cat2predir.sh#!/bin/bash#Purpose:Createthenecessarydirectoryfororacleusersandchangetheauthentiontooracleusers.#Usage:Logonasthesuperuser('root'),andthenexecutethecommand:#./2predir.sh#Author:dingliqingecho"Nowcreatethenecessarydirectoryfororacleusersandchangetheauthentiontooracleusers..."mkdir-p/u01/app/oraclechown-Roracle:oinstall/u01chmod-R775/u01echo"Thenecessarydirectoryfororacleusersandchangetheauthentiontooracleusershasbeenfinished"

[root@localhostinst_env_scripts]#cat3prelimits.sh#!/bin/bash#Purpose:Changethe/etc/security/limits.conf.#Usage:Logonasthesuperuser('root'),andthenexecutethecommand:#./3prelimits.sh#Author:dinglqecho"Nowmodifythe/etc/security/limits.conf,butbackupitnamed/etc/security/limits.conf.bakbefore"cp/etc/security/limits.conf/etc/security/limits.conf.bakecho"oraclesoftnproc2047">>/etc/security/limits.confecho"oraclehardnproc16384">>/etc/security/limits.confecho"oraclesoftnofile1024">>/etc/security/limits.confecho"oraclehardnofile65536">>/etc/security/limits.confecho"Modifingthe/etc/security/limits.confhasbeensucceed."

#Usage:Logonasthesuperuser('root'),andthenexecutethecommand:#./4presysctl.sh#Author:dingliqingecho"Nowmodifythe/etc/sysctl.conf,butwithabackupnamed/etc/sysctl.bak"cp/etc/sysctl.conf/etc/sysctl.conf.bakecho"fs.aio-max-nr=1048576">>/etc/sysctl.confecho"fs.file-max=6815744">>/etc/sysctl.confecho"kernel.shmall=2097152">>/etc/sysctl.confecho"kernel.shmmax=1054472192">>/etc/sysctl.confecho"kernel.shmmni=4096">>/etc/sysctl.confecho"kernel.sem=25032000100128">>/etc/sysctl.confecho"net.ipv4.ip_local_port_range=900065500">>/etc/sysctl.confecho"net.core.rmem_default=262144">>/etc/sysctl.confecho"net.core.rmem_max=4194304">>/etc/sysctl.confecho"net.core.wmem_default=262144">>/etc/sysctl.confecho"net.core.wmem_max=1048586">>/etc/sysctl.confecho"net.ipv4.tcp_wmem=262144262144262144">>/etc/sysctl.confecho"net.ipv4.tcp_rmem=419430441943044194304">>/etc/sysctl.confecho"Modifingthe/etc/sysctl.confhasbeensucceed."echo"Nowmakethechangestakeeffect....."sysctl-p

3. 将A机器上的zip包copy到B机器上

[root@localhostinst_env_scripts]#scp192.168.199.163:/home/oracle/db_1.zip/home/oracle/Theauthenticityofhost'192.168.199.163(192.168.199.163)'can'tbeestablished.RSAkeyfingerprintiscc:d0:c3:de:37:33:a7:cb:91:40:c5:5f:18:07:06:9f.Areyousureyouwanttocontinueconnecting(yes/no)?yesWarning:Permanentlyadded'192.168.199.163'(RSA)tothelistofknownhosts.root@192.168.199.163'spassword:db_1.zip100%2366MB30.0MB/s01:19


4. 解压zip文件

[root@localhostoracle]#unzip-d/db_1.zip[root@localhostoracle]#chown-Roracle.oinstall/u01/

5.执行Clone命令

[oracle@localhost~]$cd/u01/app/oracle/product/11.2.0/db_1/clone/bin/[oracle@localhostbin]$$ORACLE_HOME/perl/bin/perlclone.plORACLE_BASE="/u01/app/oracle/"ORACLE_HOME="/u01/app/oracle/product/11.2.0/db_1"OSDBA_GROUP=dbaOSOPER_GROUP=oper-defaultHomeName

执行结果如下

./runInstaller-clone-waitForCompletion"ORACLE_BASE=/u01/app/oracle/""ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1""oracle_install_OSDBA=dba""oracle_install_OSOPER=oper"-defaultHomeName-defaultHomeName-silent-noConfig-nowaitStartingOracleUniversalInstaller...Checkingswapspace:mustbegreaterthan500MB.Actual1999MBPassedPreparingtolaunchOracleUniversalInstallerfrom/tmp/OraInstall2015-08-22_05-13-13AM.Pleasewait...OracleUniversalInstaller,Version11.2.0.4.0ProductionCopyright(C)1999,2013,Oracle.Allrightsreserved.Youcanfindthelogofthisinstallsessionat:/u01/app/oraInventory/logs/cloneActions2015-08-22_05-13-13AM.log....................................................................................................100%Done.Installationinprogress(Saturday,August22,20155:13:31AMCST)..............................................................................78%Done.InstallsuccessfulLinkinginprogress(Saturday,August22,20155:13:38AMCST)LinksuccessfulSetupinprogress(Saturday,August22,20155:13:41AMCST)SetupsuccessfulEndofinstallphases.(Saturday,August22,20155:14:06AMCST)WARNING:Anewinventoryhasbeencreatedinthissession.However,ithasnotyetbeenregisteredasthecentralinventoryofthissystem.Toregisterthenewinventorypleaserunthescript'/u01/app/oraInventory/orainstRoot.sh'withrootprivileges.Ifyoudonotregistertheinventory,youmaynotbeabletoupdateorpatchtheproductsyouinstalled.Thefollowingconfigurationscriptsneedtobeexecutedasthe"root"user./u01/app/oraInventory/orainstRoot.sh/u01/app/oracle/product/11.2.0/db_1/root.shToexecutetheconfigurationscripts:1.Openaterminalwindow2.Loginas"root"3.RunthescriptsThecloningofOraHome1wassuccessful.Pleasecheck'/u01/app/oraInventory/logs/cloneActions2015-08-22_05-13-13AM.log'formoredetails.

6. 使用root用户运行上面的两个脚本

[root@localhost~]#/u01/app/oraInventory/orainstRoot.sh[root@localhost~]#/u01/app/oracle/product/11.2.0/db_1/root.sh

安装完毕!