init sys
#!/bin/bash
002 | # |
003 | # Script. Name: oracle_install.sh |
004 | # Description: This program is used for helping you install oracle10g automatically.Be used in Redhat 5 enterprise. |
005 | # |
006 | # Statment: Before installing oracle10g by this program,you should prepare oracle10g tar.gz file, rlwrap and redhat install CD path.If you have any question about this program,you could contact me by the following email address. |
007 | # |
008 | # Author: Xinggang Wang - OpsEye.com |
009 | # Create Date: 2009/11/21 |
010 | # Last Modified: 2009/11/24 |
011 |
012 | # Set trap,so you can interrupt the program when it is running. |
013 | trap 'echo;exit 0;' 2 |
014 |
015 | # Set the argument "shmmax" according to the memory size of your computer. |
016 | shmmax=$(($(free |awk 'NR==2{print $2}')*1024/2)) |
017 |
018 | read -p "Please input the oracle username that you want to create:" ooname |
019 | read -p "Please verify the oracle username:" oname |
020 |
021 | # Make judgment about if the variable $oname you given is null. |
022 | until [ ! -z "$oname" ] |
023 | do |
024 | read -p "Please verify the oracle username:" oname |
025 | done |
026 |
027 | username=$(awk -F: '{print $1}' /etc/passwd) |
028 | # Judge about if $oname already exists in your system. |
029 | for i in $username |
030 | do |
031 | if [ $oname = $i ] |
032 | then |
033 | echo "Error!The username you input is already exists in your system."; exit 1 |
034 | fi |
035 | done |
036 |
037 | # Make sure that the input is the very one which you want. |
038 | until [ ${oname}x = ${ooname}x ] |
039 | do |
040 | read -p "Please input the oracle username that you want to create:" ooname |
041 | read -p "Please verify the oracle username:" oname |
042 |
043 | # If $oname is still null,then exit this program. |
044 | if [ -z "$oname" ] |
045 | then |
046 | echo "Error!" |
047 | exit 1 |
048 | fi |
049 | done |
050 |
051 | read -p "Please input rlwrap path:" rlpath |
052 |
053 | read -p "Please input the path of CD:" cdpath |
054 |
055 | # Make sure the path that you given is right. |
056 | until [ -e "$cdpath"/Server ] |
057 | do |
058 | read -p "Wrong path of CD,please retry:" cdpath |
059 | done |
060 |
061 | read -p "Please input your oracle tar.gz package name(include path) :" opackage |
062 |
063 | if [ ! -f "$opackage" ] |
064 | then |
065 | echo "The package is wrong!" |
066 | exit 1 |
067 | fi |
068 |
069 | { |
070 | groupadd oinstall |
071 | groupadd dba |
072 | useradd -m -g oinstall -G dba $oname |
073 | mkdir -p /u01/app/$oname |
074 | chown -R $oname:oinstall /u01/app/$oname |
075 | chmod -R 775 /u01/app/$oname |
076 | }&>/dev/null |
077 |
078 | tar -zxf $opackage -C /home/$oname &>/dev/null |
079 |
080 | # Make sure that the package you given is absolutely right. |
081 | until [ "$?" -eq "0" ] |
082 | do |
083 | read -p "Wrong package,please retry:" opachage |
084 | tar -zxf $opackage -C /home/$oname &>/dev/null |
085 | done |
086 |
087 | pushd $cdpath/Server &>/dev/null |
088 | { |
089 | rpm -Uvh compat-db-4* |
090 | rpm -Uvh libaio-0* |
091 | rpm -Uvh compat-libstdc++-33-3* |
092 | rpm -Uvh compat-gcc-34-3* |
093 | rpm -Uvh compat-gcc-34-c++-3* |
094 | rpm -Uvh libXp-1* |
095 | rpm -Uvh openmotif-2* |
096 | rpm -Uvh gcc-4* |
097 | }&>/dev/null |
098 | #rpm -Uvh glibc-2.5-12.i686.rpm |
099 | popd &>/dev/null |
100 |
101 | flag=0 |
102 | { |
103 | pushd $rlpath |
104 | $rlpath/configure |
105 | make && make install |
106 | popd |
107 | }&>/dev/null |
108 |
109 | # Be used for judging if rlwrap was compiled successfully. |
110 | if [ "$?" -eq "1" ] |
111 | then |
112 | flag=1 |
113 | fi |
114 |
115 | grep 'fs.file-max' /etc/sysctl.conf &>/dev/null |
116 |
117 | # Make jugdement if the configure file was already configured. |
118 | if [ "$?" -eq "1" ] |
119 | then |
120 |
121 | # Delete the argument "kernerl.shmmax" in the configure file. |
122 | sed -i '/^kernel.shmmax/d' /etc/sysctl.conf |
123 | # Delete the argument "kernel.shmall" in the configure file |
124 | sed -i '/^kernel.shmall/d' /etc/sysctl.conf |
125 |
126 | cat >> /etc/sysctl.conf < |
127 | kernel.shmall = 2097152 |
128 | kernel.shmmax = $shmmax |
129 | kernel.shmmni = 4096 |
130 | kernel.sem = 250 32000 100 128 |
131 | fs.file-max = 65536 |
132 | net.ipv4.ip_local_port_range = 1024 65000 |
133 | net.core.rmem_default=262144 |
134 | net.core.rmem_max=262144 |
135 | net.core.wmem_default=262144 |
136 | net.core.wmem_max=262144 |
137 | #signaturelevin |
138 | EOF |
139 | fi |
140 |
141 | # Make the configured file come into effect immediately. |
142 | sysctl -p &>/dev/null |
143 |
144 | grep 'soft nproc' /etc/security/limits.conf &>/dev/null |
145 | if [ "$?" -eq "1" ] |
146 | then |
147 | cat >> /etc/security/limits.conf < |
148 | soft nproc 2047 |
149 | hard nproc 16384 |
150 | soft nofile 1024 |
151 | hard nofile 65536 |
152 | #signaturelevin |
153 | EOF |
154 | fi |
155 |
156 | grep 'pam_limits.so' /etc/pam.d/login &>/dev/null |
157 | if [ "$?" -eq "1" ] |
158 | then |
159 | cat >> /etc/pam.d/login < |
160 | session required pam_limits.so |
161 | #signaturelevin |
162 | EOF |
163 | fi |
164 |
165 | grep 'ORACLE_SID=orcl' /home/$oname/.bash_profile &>/dev/null |
166 | if [ "$?" -eq "1" ] |
167 | then |
168 | cat >>/home/$oname/.bash_profile < |
169 | export TMP=/tmp |
170 | export ORACLE_BASE=/u01/app/$oname |
171 | export ORACLE_HOME=\$ORACLE_BASE/product/10g |
172 | export ORACLE_SID=orcl |
173 | export PATH=\$ORACLE_HOME/bin:\$PATH |
174 | export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib |
175 | export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib |
176 | alias sqlplus="rlwrap sqlplus" |
177 | alias rman="rlwrap rman" |
178 | alias fox="firefox" |
179 | #signaturelevin |
180 | EOF |
181 | fi |
182 |
183 | . /home/$oname/.bash_profile |
184 |
185 | # Resovling the problems brought by the version of your system. |
186 | sed -i 's/5/4/' /etc/redhat-release |
187 |
188 | xhost + &>/dev/null |
189 |
190 | echo -e "\a" |
191 | if [ "$flag" -eq "1" ] |
192 | then |
193 | echo -e "Configure successful but the rlwrap was not compiled successfully.You should compile it by your own after finishing installs of oracle10g.Now,the following steps are your own work.\n \n 1.export LANG=C \n 2.cd database/\n 3../runInstaller\n 4.Configure according to the Oracle GUI information.\n" |
194 | else |
195 | echo -e "Configure successful!The following steps are your own work.Just do it.\n \n 1.export LANG=C \n 2.cd database/\n 3../runInstaller\n 4.Configure according to the Oracle GUI information.\n" |
196 | fi |
197 |
198 | su - $oname |
199 |
200 | exit 0 |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23757700/viewspace-721078/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 系統初始化之sys init
- Init
- 【Android】【init】解析init程式啟動過程Android
- git init 命令Git
- ora_init
- __init__.py
- OpenHarmony的init程式、init配置與啟動項配置
- Android系統啟動:init程式與init語言Android
- Go init 函式Go函式
- Golang init() 函式Golang函式
- clinit和init
- 47.6.Init.dScript
- OC alloc、init、new
- 10.2.0.2 init parameter
- 50-cloud-init.yaml 和80-cloud-init.yaml區別CloudYAML
- spring中的default-lazy-init引數和lazy-initSpring
- Linux init程式分析Linux
- git init命令詳解Git
- npx & yarn create & npm initYarnNPM
- 系統啟動, init
- vue init webpack報錯VueWeb
- python的__init__()Python
- Servlet的init注意點Servlet
- shutdown,halt,reboot,init(轉)boot
- Linux init詳解Linux
- Ubuntu移除cloud init元件UbuntuCloud元件
- [JVM]<clinit>和<init>JVM
- 理解 go mod init 命令Go
- 2788647047_init_multiprocessing
- Python--sysPython
- MySQL 5.7 SYS SCHEMAMySql
- SYS_CONTEXTContext
- sys.allocation_units與sys.system_internals_allocation_units的差別
- i_init_func_execute_data
- Linux基礎命令—initLinux
- __new()__ 與 __init()__的區別
- PVE Cloud-INIT 模板配置Cloud
- Python: __init__.py 作用Python