Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22121
  • 博文数量: 3
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2014-05-25 00:03
个人简介

爱技术,爱生活。

文章分类

分类: Oracle

2014-12-01 23:04:26

Oracle数据库:    11.2.0.3
OS版本:            CentOS 6.6

注:                    由于CentOS 6.3以后oracle不再提供oracleasm包,所以使用了raw。


点击(此处)折叠或打开

 
  1. #!/bin/bash
  2. ###################################################################################
  3. # params & functions define
  4. function f_arch {
  5. for v_flist in $*
  6. do
  7. cp $v_flist ${v_flist}'.'$(date "+%Y%m%d%H%M%S")
  8. done
  9. }
  10. v_oracle_release='11.2.0.4'
  11. v_iso_path='mnt' #OS DVD path
  12. v_oracle_mountpoint='opt'
  13. v_oracle_pwd='oracle'
  14. v_grid_pwd='grid'
  15. v_oracle_sid='linora'
  16. v_verify_log="/root/ora_setup.$(date '+%Y%m%d%H%M%S')"
  17. v_display='192.168.36.1:0.0' #Display define
  18. v_votedisk_raw='sdc1'
  19. v_datadisk_raw='sdb1'
  20. v_rpmlist='ntp
  21. sysstat
  22. binutils
  23. compat-libcap1
  24. compat-libstdc++-33
  25. gcc
  26. gcc-c++
  27. glibc
  28. glibc-devel
  29. ksh
  30. libgcc
  31. libstdc++
  32. libstdc++-devel
  33. libaio
  34. libXp
  35. libaio-devel
  36. make
  37. man
  38. elfutils-libelf-devel
  39. unzip
  40. bc'
  41. ###################################################################################
  42. # raw configuration

  43. f_arch /etc/udev/rules.d/60-raw.rules

  44. if [ $(grep AddForOracle /etc/udev/rules.d/60-raw.rules | wc -l) -eq 0 ]
  45. then
  46. cat >> /etc/udev/rules.d/60-raw.rules <
  47. # AddForOracle
  48. ACTION=="add", KERNEL=="${v_votedisk_raw}", RUN+="/bin/raw /dev/raw/raw1 %N"
  49. ACTION=="add", KERNEL=="${v_datadisk_raw}", RUN+="/bin/raw /dev/raw/raw2 %N"
  50. ACTION=="add", KERNEL=="raw*", OWNER=="oracle", GROUP=="oinstall", MODE=="0664"
  51. EOF

  52. fi
  53. start_udev
  54. # host modify
  55. v_ipaddr=$(awk -F'=' '{if($0 ~ "(ipaddr|IPADDR)") {print $2}}' /etc/sysconfig/network-scripts/ifcfg-eth0)
  56. f_arch /etc/hosts
  57. cat > /etc/hosts <
  58. 127.0.0.1 localhost
  59. ${v_ipaddr} $(hostname)
  60. EOF
  61. # kernel params modify
  62. v_totalmem_kb=$(free -k | grep Mem | awk '{print $2}')
  63. v_orashmmem=$(awk "BEGIN{printf(\"%.0f\",${v_totalmem_kb}* 1024 * 0.8)}")
  64. if [ $(grep 'AddForOracle' /etc/sysctl.conf|wc -l) -eq 0 ]
  65. then
  66. f_arch /etc/sysctl.conf
  67. cat >> /etc/sysctl.conf <
  68. #AddForOracle
  69. kernel.shmmni = 4096
  70. kernel.sem = 250 32000 100 128
  71. kernel.shmall = 62500000
  72. kernel.shmmax = ${v_orashmmem}
  73. fs.file-max = 6815744
  74. net.ipv4.ip_local_port_range = 9000 65500
  75. fs.aio-max-nr = 1048576
  76. net.core.rmem_default = 4194304
  77. net.core.wmem_default = 262144
  78. net.core.rmem_max = 4194304
  79. net.core.wmem_max = 2097152
  80. EOF
  81. fi
  82. sysctl -p
  83. # install rpms
  84. cat > /etc/yum.repos.d/CentOS-Media.repo <
  85. [localyum]
  86. name=localyum
  87. baseurl=file:///${v_iso_path}/
  88. gpgcheck=1
  89. enabled=0
  90. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  91. EOF
  92. for idx_rpm in $v_rpmlist
  93. do
  94. yum --disablerepo=\* --enablerepo=localyum install -y $idx_rpm
  95. done
  96. # close iptables
  97. service iptables stop
  98. chkconfig iptables off
  99. # groupadd
  100. \userdel oracle
  101. \userdel grid
  102. v_grp_list='oinstall dba oper asmadmin asmoper asmdba'
  103. v_start_gid=1000
  104. for idx_grp_list in $v_grp_list
  105. do
  106. \groupdel ${idx_grp_list}
  107. \groupadd -g ${v_start_gid} ${idx_grp_list}
  108. v_start_gid=$((${v_start_gid}+1))
  109. done
  110. # useradd
  111. \useradd -u 1000 -g oinstall -G dba,asmdba,oper oracle
  112. \useradd -u 1001 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
  113. # user permissions configuration
  114. if [ $(grep grid /etc/security/limits.conf|wc -l) -eq 0 ]
  115. then
  116. echo "grid soft nproc 2047" >> /etc/security/limits.conf
  117. echo "grid hard nproc 16384" >> /etc/security/limits.conf
  118. echo "grid soft nofile 1024" >> /etc/security/limits.conf
  119. echo "grid hard nofile 65536" >> /etc/security/limits.conf
  120. fi
  121. if [ $(grep oracle /etc/security/limits.conf|wc -l) -eq 0 ]
  122. then
  123. echo "oracle soft nproc 2047" >> /etc/security/limits.conf
  124. echo "oracle hard nproc 16384" >> /etc/security/limits.conf
  125. echo "oracle soft nofile 1024" >> /etc/security/limits.conf
  126. echo "oracle hard nofile 65536" >> /etc/security/limits.conf
  127. fi
  128. if [ $(grep oracle /etc/profile|wc -l) -eq 0 ]
  129. then
  130. echo "if [ \$USER = \"oracle\" ] || [ \$USER = \"grid\" ]; then" >>/etc/profile
  131. echo " if [ \$SHELL = \"/bin/ksh\" ]; then" >>/etc/profile
  132. echo " ulimit -p 16384" >>/etc/profile
  133. echo " ulimit -n 65536" >>/etc/profile
  134. echo " else" >>/etc/profile
  135. echo " ulimit -u 16384 -n 65536" >>/etc/profile
  136. echo " fi" >>/etc/profile
  137. echo "fi" >>/etc/profile
  138. fi
  139. # create oracle install directory
  140. v_grid_home="/${v_oracle_mountpoint}/app/grid"
  141. mkdir -p ${v_grid_home}
  142. chown -R grid:oinstall ${v_grid_home}
  143. chmod -R 775 ${v_grid_home}
  144. v_invetory="/${v_oracle_mountpoint}/app/oraInventory"
  145. mkdir -p ${v_invetory}
  146. chown -R grid:oinstall ${v_invetory}
  147. chmod -R 775 ${v_invetory}
  148. v_crs_home="/${v_oracle_mountpoint}/app/$v_oracle_release"
  149. mkdir -p ${v_crs_home}
  150. chown -R grid:oinstall ${v_crs_home}
  151. chmod -R 775 ${v_crs_home}
  152. v_db_home="/${v_oracle_mountpoint}/app/oracle"
  153. mkdir -p ${v_db_home}
  154. chown -R oracle:oinstall ${v_db_home}
  155. chmod -R 775 ${v_db_home}
  156. # user env configuration
  157. if [ $(grep ORACLE /home/oracle/.bash_profile|wc -l) -eq 0 ]
  158. then
  159. echo "umask 022" >> /home/oracle/.bash_profile
  160. echo "export ORACLE_BASE=/${v_oracle_mountpoint}/app/oracle" >> /home/oracle/.bash_profile
  161. echo "export ORACLE_HOME=\$ORACLE_BASE/product/"$v_oracle_release >> /home/oracle/.bash_profile
  162. echo "export ORACLE_SID=${v_oracle_sid}" >> /home/oracle/.bash_profile
  163. echo "export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:\$ORACLE_HOME/rdbms/lib" >> /home/oracle/.bash_profile
  164. echo "export PATH=\$ORACLE_HOME/bin:\$CRS_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:\$PATH" >> /home/oracle/.bash_profile
  165. echo "export DISPLAY="$v_display >> /home/oracle/.bash_profile
  166. fi
  167. if [ $(grep ORACLE /home/grid/.bash_profile|wc -l) -eq 0 ]
  168. then
  169. echo "" >> /home/grid/.bash_profile
  170. echo "umask 022" >> /home/grid/.bash_profile
  171. echo "export ORACLE_BASE=/${v_oracle_mountpoint}/app/grid" >> /home/grid/.bash_profile
  172. echo "export ORACLE_HOME=/${v_oracle_mountpoint}/app/$v_oracle_release/grid" >> /home/grid/.bash_profile
  173. echo "export ORACLE_SID=+ASM"$NODE_ID >> /home/grid/.bash_profile
  174. echo "export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:\$ORACLE_HOME/rdbms/lib" >> /home/grid/.bash_profile
  175. echo "export PATH=\$ORACLE_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:\$PATH" >> /home/grid/.bash_profile
  176. echo "export DISPLAY="$v_display >> /home/grid/.bash_profile
  177. fi
  178. passwd oracle <
  179. ${v_oracle_pwd}
  180. ${v_oracle_pwd}
  181. EOF
  182. passwd grid <
  183. ${v_grid_pwd}
  184. ${v_grid_pwd}
  185. EOF
  186. echo '1.sysctl' >>${v_verify_log}
  187. sysctl -p >>${v_verify_log} 2>>${v_verify_log}
  188. echo '2.yum repos' >>${v_verify_log}
  189. cat /etc/yum.repos.d/CentOS-Media.repo >>${v_verify_log} 2>>${v_verify_log}
  190. echo '3.iptables status' >>${v_verify_log}
  191. service iptables status >>${v_verify_log} 2>>${v_verify_log}
  192. echo '4.oracle user info' >>${v_verify_log}
  193. id oracle >>${v_verify_log} 2>>${v_verify_log}
  194. echo '5.grid user info' >>${v_verify_log}
  195. id grid >>${v_verify_log} 2>>${v_verify_log}
  196. echo '6.grid user limits' >>${v_verify_log}
  197. grep grid /etc/security/limits.conf >>${v_verify_log} 2>>${v_verify_log}
  198. echo '7.oracle user limits' >>${v_verify_log}
  199. grep oracle /etc/security/limits.conf >>${v_verify_log} 2>>${v_verify_log}
  200. echo '8.oracle user configure info in /etc/profile' >>${v_verify_log}
  201. grep -A8 'oracle' /etc/profile >>${v_verify_log} 2>>${v_verify_log}
  202. echo '9.dir info' >>${v_verify_log}
  203. ls -l "/${v_oracle_mountpoint}/app" >>${v_verify_log} 2>>${v_verify_log}
  204. echo '10.oracle user env' >>${v_verify_log}
  205. grep ORACLE /home/oracle/.bash_profile >>${v_verify_log} 2>>${v_verify_log}
  206. echo '11.grid user env' >>${v_verify_log}
  207. grep ORACLE /home/grid/.bash_profile >>${v_verify_log} 2>>${v_verify_log}
  208. echo '12.hosts check' >>${v_verify_log}
  209. cat /etc/hosts >>${v_verify_log} 2>>${v_verify_log}
  210. echo >>${v_verify_log}
  211. echo >>${v_verify_log}
  212. echo 'Please ensure the 11 options is all correct.' >> ${v_verify_log}
  213. echo
  214. echo
  215. echo "All done,please check the ${v_verify_log} log file to verify."

阅读(1636) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:【转】Write-through VS Write-back

给主人留下些什么吧!~~