重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

rhel6.4自动安装oracle11g客户端


1、安装过程

点击(此处)折叠或打开

创新互联公司秉承实现全网价值营销的理念,以专业定制企业官网,成都网站设计、做网站,微信小程序,网页设计制作,手机网站制作成都全网营销帮助传统企业实现“互联网+”转型升级专业定制企业官网,公司注重人才、技术和管理,汇聚了一批优秀的互联网技术人才,对客户都以感恩的心态奉献自己的专业和所长。

  1. [root@localhost ~]# cd /tmp/client/
  2. [root@localhost client]# ll
  3. total 640676
  4. -rw-r--r--. 1 root root 5554 Dec 13 16:24 auto_install_oracle_client.sh #主脚本
  5. -rw-r--r--. 1 root root 12062 Dec 13 16:24 client_install.rsp #静默安装配置文件
  6. -rw-r--r--. 1 root root 656026876 Dec 13 16:22 p13390677_112040_Linux-x86-64_4of7.zip #安装包
  7. [root@localhost client]# chmod u+x auto_install_oracle_client.sh #赋权
  8. [root@localhost client]# ./auto_install_oracle_client.sh #在文件所在路径使用root用户执行
  9. tmp is.................................................... [ok] #检查/tmp目录,需要大于120 MB
  10. swap is.................................................... [ok] #检查swap空间,需要大于150 MB
  11. finding sqlplus #通过find查找sqlplus,此处需要等待
  12. env is.................................................... [ok] #环境ok
  13. pkg is.................................................... [ok] #安装包ok
  14. rsp is.................................................... [ok] #静默安装配置文件ok
  15. please input which user to install oracle client:oracle #可以是已经存在的用户,也可以是新用户
  16. please input ip addr:192.168.1.222 #输入该系统ip地址
  17. unziping p13390677_112040_Linux-x86-64_4of7.zip #正在解压安装包,此处需要等待
  18. starting install,may be take a minutes,you can see log:/tmp/install_client.log #需要等待
  19. starting orainstRoot.sh,you can see /tmp/orainstRoot.sh.log
  20. The execution of the script is complete.
  21. #######################################################################
  22. #########please use root to run /tmp/del_client.sh to deinstall####### #卸载脚本
  23. #########dba oinstall oracle need your check################### #若需要,用户和组需手动删除
  24. #######################################################################
2、验证过程

点击(此处)折叠或打开

  1. [root@localhost client]# su - oracle
  2. [oracle@localhost ~]$ cd $ORACLE_HOME/network/admin/
  3. [oracle@localhost admin]$ vi tnsnames.ora
  4. [oracle@localhost admin]$ cat tnsnames.ora
  5. ORCL =
  6.     (DESCRIPTION =
  7.         (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.42)(PORT = 1521))
  8.         (CONNECT_DATA =
  9.             (SERVER = DEDICATED)
  10.             (SERVICE_NAME = orcl)
  11.         )
  12.      )
  13. [oracle@localhost admin]$ sqlplus scott/tiger@orcl
  14. SQL>
3、卸载过程(需根据实际需求手动删除用户组和用户)

点击(此处)折叠或打开

  1. [root@localhost client]# /tmp/del_client.sh
  2. [root@localhost client]# su - oracle
  3. [oracle@localhost ~]$ sqlplus
  4. -bash: sqlplus: command not found

auto_install_oracle_client.sh的内容:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. #检查/tmp空间
  3. if [ `df -m /tmp|wc -l` -eq 2 ];then
  4.     tmp=`df -m /tmp|tail -1|awk '{print $4}'`
  5. else
  6.     tmp=`df -m /tmp|tail -1|awk '{print $3}'`
  7. fi
  8. if [ $tmp -gt 120 ];then
  9.     echo "tmp is.................................................... [ok]"
  10. else
  11.     echo "[fail]====>/tmp must more than 120MB"
  12. exit 5
  13. fi
  14. #检查swap空间
  15. if [ `free -m|grep Swap|awk '{print $2}'` -gt 150 ];then
  16.     echo "swap is.................................................... [ok]"
  17. else
  18.     echo "[fail]====>swap must more than 150MB"
  19. exit 5
  20. fi
  21. #检查该主机是否已经安装了sqlplus
  22. echo "finding sqlplus"
  23. if [ `find / -name "sqlplus"|grep sqlplus|wc -l` -gt 0 ]
  24. then
  25.     echo "this system has installed oracle client.install process exit!"
  26.     echo "install process stop!"
  27.     exit 0
  28. else
  29.     echo "env is.................................................... [ok]"
  30. fi
  31. #检查客户端安装包是否已经上传
  32. LOCALDIR=`pwd`
  33. if [ `ls -l $LOCALDIR|grep "p13390677_112040_Linux-x86-64_4of7.zip" |wc -l` -gt 0 ]
  34. then
  35.     echo "pkg is.................................................... [ok]"
  36. else
  37.     echo "please upload p13390677_112040_Linux-x86-64_4of7.zip in $LOCALDIR"
  38.     echo "install process stop!"
  39.     exit 0
  40. fi
  41. #检查配置文件是否已经上传
  42. LOCALDIR=`pwd`
  43. if [ `ls -l $LOCALDIR|grep client_install.rsp|wc -l` -gt 0 ]
  44. then
  45.     echo "rsp is.................................................... [ok]"
  46. else
  47.     echo "please upload client_install.rsp in $LOCALDIR"
  48.     echo "install process stop!"
  49.     exit 0
  50. fi
  51. #获取用户名、ORACLE_BASE、ip地址信息
  52. echo -e "please input which user to install oracle client:\c"
  53. read USERNAME
  54. ORACLE_BASE=/home/$USERNAME/oracle_client
  55. echo -e "please input ip addr:\c"
  56. read ip_addr
  57. #备份和修改/etc/hosts文件
  58. cp /etc/hosts /etc/hosts_lihbbak
  59. echo "$ip_addr `hostname`">>/etc/hosts
  60. #备份oraInst.loc文件
  61. mv -f /etc/oraInst.loc /etc/oraInst.loc_lihbbak >/dev/null 2>&1
  62. #创建dba、oinstall用户组,创建用户
  63. /usr/sbin/groupadd dba >/dev/null 2>&1
  64. /usr/sbin/groupadd oinstall >/dev/null 2>&1
  65. /usr/sbin/useradd -m -g oinstall -G dba $USERNAME >/dev/null 2>&1
  66. #创建目录并附权
  67. mkdir -p $ORACLE_BASE >/dev/null 2>&1
  68. cd $ORACLE_BASE
  69. mkdir oraInventory
  70. chown -R $USERNAME:oinstall $ORACLE_BASE
  71. #解压安装包并附权
  72. echo "unziping p13390677_112040_Linux-x86-64_4of7.zip"
  73. cd $LOCALDIR
  74. /usr/bin/unzip p13390677_112040_Linux-x86-64_4of7.zip >/dev/null 2>&1
  75. chown -R $USERNAME:oinstall client
  76. chown $USERNAME:oinstall client_install.rsp
  77. #备份并修改配置文件
  78. cp client_install.rsp client_install.rsp_lihbbak
  79. sed -i "s|/u01/app|$ORACLE_BASE|g" client_install.rsp
  80. #配置用户环境并安装软件
  81. echo "starting install,may be take a minutes,you can see log:/tmp/install_client.log"
  82. su - $USERNAME
  83.     echo "export ORACLE_BASE=$ORACLE_BASE" >>/home/$USERNAME/.bash_profile
  84.     echo "export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0.4/client_1" >>/home/$USERNAME/.bash_profile
  85.     echo 'export PATH=\$ORACLE_HOME/bin:\$PATH' >>/home/$USERNAME/.bash_profile
  86.     echo 'export LD_LIBRARY_PATH=$ORACLE_BASE/oracle/product/11.2.0.4/client_1/lib' >>/home/$USERNAME/.bash_profile
  87.     source ~/.bash_profile >/dev/null 2>&1
  88.     cd $LOCALDIR/client
  89.     ./runInstaller -silent -showProgress -ignorePrereq -waitforcompletion -responseFile $LOCALDIR/client_install.rsp
  90. EOF
  91. #执行root.sh脚本
  92. sleep 2s
  93. echo "starting orainstRoot.sh,you can see /tmp/orainstRoot.sh.log"
  94. $ORACLE_BASE/oraInventory/orainstRoot.sh >/tmp/orainstRoot.sh.log 2>&1
  95. tail -1 /tmp/orainstRoot.sh.log
  96. #修改ORACLE_HOME/bin的权限
  97. chmod 755 $ORACLE_BASE/oracle/product/11.2.0.4/client_1/bin/*
  98. #配置tnsnames.ora文件用于测试
  99. su - $USERNAME
  100.     source ~/.bash_profile
  101.     cd $ORACLE_BASE/oracle/product/11.2.0.4/client_1/network/admin
  102.     touch tnsnames.ora
  103.     echo 'ORATEST1 ='>>tnsnames.ora
  104.     echo ' (DESCRIPTION = ' >>tnsnames.ora
  105.     echo ' (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.75.249)(PORT = 1521)) ' >>tnsnames.ora
  106.     echo ' (CONNECT_DATA = ' >>tnsnames.ora
  107.     echo ' (SERVER = DEDICATED) ' >>tnsnames.ora
  108.     echo ' (SERVICE_NAME = oratest1) ' >>tnsnames.ora
  109.     echo ' ) ' >>tnsnames.ora
  110.     echo ' ) ' >>tnsnames.ora
  111. EOF
  112. #生成卸载脚本
  113. touch /tmp/del_client.sh >/dev/null 2>&1
  114. echo "#!/bin/bash" >/tmp/del_client.sh
  115. echo "cd $LOCALDIR" >>/tmp/del_client.sh
  116. echo 'rm -rf client' >>/tmp/del_client.sh
  117. echo 'mv -f /etc/hosts_lihbbak /etc/hosts >/dev/null 2>&1' >>/tmp/del_client.sh
  118. echo 'mv -f client_install.rsp_lihbbak client_install.rsp >/dev/null 2>&1' >>/tmp/del_client.sh
  119. echo "rm -rf $ORACLE_BASE" >>/tmp/del_client.sh
  120. echo "mv -f /etc/oraInst.loc_lihbbak /etc/oraInst.loc >/dev/null 2>&1 " >>/tmp/del_client.sh
  121. chmod u+x /tmp/del_client.sh
  122. echo '#########################################################################'
  123. echo '###########please use root to run /tmp/del_client.sh to deinstall#######'
  124. echo "###########dba oinstall $USERNAME need your check################"
  125. echo '#########################################################################'
client_install.rsp 的内容:

点击(此处)折叠或打开

  1. [root@localhost client]# cat client_install.rsp |grep -v ^# |grep -v ^$
  2. oracle.install.responseFileVersion=/oracle/install/rspfmt_clientinstall_response_schema_v11_2_0
  3. ORACLE_HOSTNAME=
  4. UNIX_GROUP_NAME=oinstall
  5. INVENTORY_LOCATION=/u01/app/oraInventory
  6. SELECTED_LANGUAGES=en
  7. ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/client_1
  8. ORACLE_BASE=/u01/app/oracle
  9. oracle.install.client.installType=Administrator
  10. oracle.install.client.upgrading=false
  11. oracle.install.client.customComponents="oracle.sqlj:11.2.0.4.0","oracle.rdbms.util:11.2.0.4.0","oracle.javavm.client:11.2.0.4.0","oracle.sqlplus:11.2.0.4.0","oracle.dbjava.jdbc:11.2.0.4.0","oracle.ldap.client:11.2.0.4.0","oracle.rdbms.oci:11.2.0.4.0","oracle.precomp:11.2.0.4.0","oracle.xdk:11.2.0.4.0","oracle.network.aso:11.2.0.4.0","oracle.assistants.oemlt:11.2.0.4.0","oracle.oraolap.mgmt:11.2.0.4.0","oracle.network.client:11.2.0.4.0","oracle.network.cman:11.2.0.4.0","oracle.network.listener:11.2.0.4.0","oracle.ordim.client:11.2.0.4.0","oracle.odbc:11.2.0.4.0","oracle.has.client:11.2.0.4.0","oracle.dbdev:11.2.0.4.0","oracle.rdbms.scheduler:11.2.0.4.0"
  12. oracle.install.client.schedulerAgentHostName=
  13. oracle.install.client.schedulerAgentPortNumber=
  14. oracle.installer.autoupdates.option=SKIP_UPDATES
  15. oracle.installer.autoupdates.downloadUpdatesLoc=
  16. AUTOUPDATES_MYORACLESUPPORT_USERNAME=
  17. AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
  18. PROXY_HOST=
  19. PROXY_PORT=
  20. PROXY_USER=
  21. PROXY_PWD=
  22. PROXY_REALM=







分享标题:rhel6.4自动安装oracle11g客户端
链接URL:http://cqcxhl.com/article/geispd.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP