oracle安装脚本

释放双眼,带上耳机,听听看~!

插2个脚本,安装oracle配置环境变量用得到,第一个是静默安装需要的配置。第二个需要图形化连接安装。

附:第一个脚本其实没写完,最后没时间写了。先放上来,免得忘记了,有时间在写。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
1#!/bin/bash
2#encoding:utf-8
3#auto install oralce
4oracle_env(){
5yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat
6}
7oracle_user(){
8read -t 5  -p "请输入安装oracle的用户名,默认的用户名是oracle:" user
9echo
10read -t 5 -s -p "请输入为了oracle用户设置的密码,默认的密码是oracle:" password
11if  test -z $user
12then
13        echo "开始创建ORACLE用户"
14        /usr/sbin/groupadd oinstall
15        /usr/sbin/groupadd dba
16        /usr/sbin/useradd -g oinstall -G dba oracle
17        echo "oracle" |passwd --stdin oracle
18else
19        echo "检测此用户是否被创建----------------------"
20        if cat /etc/passwd | awk -F: '{print $1}'| grep  $user >/dev/null 2>&1
21                then
22                        echo "用户已经存在--------------"
23        else
24                echo "用户不存在,检测用户组是否存在后创建!"
25                user_exist=0
26        fi
27        if cat /etc/group | awk -F: '{print $1}' | grep dba >/dev/null 2>&1
28                then
29                        echo "dba用户组已存在--------------"
30        else
31                echo "dba用户组不存在!"
32                dba_exist=0
33        fi
34        if cat /etc/group | awk -F: '{print $1}'| grep oinstall > /dev/null 2>&1
35                then
36                        echo "oinstall用户组已存在----------"
37        else
38                echo "oinstall 用户组不存在!"
39                oinstall_exist=0
40        fi
41        if [[ "$user_exist" -eq "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
42                then
43                        /usr/sbin/groupadd dba
44                        /usr/sbin/groupadd oinstall
45                        /usr/sbin/useradd -g oinstall -G dba $user
46        elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
47                then
48                        /usr/sbin/groupadd dba
49                        /usr/sbin/groupadd oinstall
50                        /usr/sbin/usermod -G dba,oinstall $user
51        elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -eq "0" ]] && [[ "$oinstall_exist" -eq "0" ]]
52                then
53                        /usr/sbin/groupadd dba
54                        /usr/sbin/groupadd oinstall
55                        /usr/sbin/usermod -G dba,oinstall $user
56        elif [[ "$user_exist" -eq "0" ]] && [[ "$dba_exist" -ne "0" ]] && [[ "$oinstall_exist" -ne "0" ]]
57                then
58                        /usr/sbin/useradd -g oinstall -G dba $user
59        elif [[ "$user_exist" -ne "0" ]] && [[ "$dba_exist" -ne "0" ]] && [[ "$oinstall_exist" -ne "0" ]]
60                then
61                        /usr/sbin/usermod -G oinstall,dba $user
62        fi
63fi
64}
65add_sysctl(){
66echo "添加内核参数!"
67cat >> /etc/sysctl.conf << "EOF"
68fs.aio-max-nr = 1048576
69fs.file-max = 6815744
70kernel.shmall = 2097152
71kernel.shmmax = 536870912
72kernel.shmmni = 4096
73kernel.sem = 250 32000 100 128
74net.ipv4.ip_local_port_range = 9000 65500
75net.core.rmem_default = 262144
76net.core.rmem_max = 4194304
77net.core.wmem_default = 262144
78net.core.wmem_max = 1048586
79EOF
80echo "添加完成,使生效!"
81sleep 3
82sysctl -p
83sleep 3
84echo "更改用户文件限制!"
85cat >> /etc/security/limits.conf << "EOF"
86oracle  soft    nproc   2047
87oracle  hard    nproc   16384
88oracle  soft    nofile  1024
89oracle  hard    nofile  65536
90oracle  soft    stack   10240
91EOF
92echo "更改完成!"
93}
94create_dir(){
95echo "创建oracle安装目录!"
96read -t 5 -p "请输入oracle的安装目录(默认安装在opt下):" dir
97if test -z $dir
98    then  
99        mkdir -p /opt/oracle /opt/oraInventory /opt/oradata/;
100        chown -R oracle:oinstall /opt/oracle /dopt/oraInventory /opt/oradata/;
101        chmod -R 775 /opt/oracle /opt/oraInventory /opt/oradata/;
102    else
103        mkdir -p $dir/oracle/ $dir/oraInventory/ $dir/oradata/;
104        chown -R $user.oinstall $dir/oracle $dir/oraInventory $dir/oradata;
105        chmod -R 775 $dir/oracle/$dir/oraInventory $dir/oradata/;
106fi
107su - $user -c "cat >> ~/.bash_profile << "EOF"
108export ORACLE_BASE=$dir/oracle
109export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
110export ORACLE_SID=orcl
111export ORALCE_OWNER=oracle
112export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
113EOF"
114su - $user -c "source ~/.bash_profile"
115}
116cd /usr/src
117unzip $1
118unzip -o  $2
119chmod 777 /data/database;
120chown -R oracle.oinstall /data/database
121#create oraInst file
122cat >> /etc/oraInst.loc << "EOF"
123inventory_loc=/data/oraInventory
124inst_group=oinstall
125EOF
126#End
127chown oracle.oinstall /etc/oraInst.loc
128chmod 664 /etc/oraInst.loc
129#create Response file
130#backup ResponseFile file
131cp $ResponseFile /data/database/response/db_install.bak;
132sed -i '32s/$/INSTALL_DB_AND_CONFIG/' $ResponseFile;
133sed -i '37s#$#oracledb#' $ResponseFile;
134sed -i '42s#$#oinstall#' $ResponseFile;
135sed -i '47s#$#/data/oraInventory#' $ResponseFile;
136sed -i '78s#$#en,zh_CN#' $ResponseFile;
137sed -i '83s#$#/data/oracle/product/11.2.0/db_1#' $ResponseFile
138sed -i '88s#$#/data/oracle#' $ResponseFile
139sed -i '99s/$/EE/' $ResponseFile
140sed -i '142s/$/oinstall/' $ResponseFile
141sed -i '147s/$/oinstall/' $ResponseFile
142sed -i '160s/$/GENERAL_PURPOSE/' $ResponseFile
143sed -i '165s/$/oracle/' $ResponseFile
144sed -i '170s/$/oracl/'  $ResponseFile
145sed -i '200s/$/512/' $ResponseFile
146sed -i '233s/$/Oracle123/' $ResponseFile
147sed -i '324s#$#FILE_SYSTEM_STORAGE#' $ResponseFile
148sed -i '332s#$#/data/oradata/ora11g/ORA11G#' $ResponseFile
149sed -i '385s/$/true/' $ResponseFile
150#End Edit
151echo -e "-------------------------------------------------------------------------------------------------------End Edit-----------------------------------------------------------------------------------------------------------------------"#Start install oracle
152echo -e "Start install oracle"
153su - oracle -c "/data/database/runInstaller -silent -responseFile /data/database/response/db_install.rsp"
154#installing
155echo -e "oracle is installing"
156#Run the oracle script
157echo -e "Run of the oracle script"
158sh /data/oracle/product/11.2.0/db_1/root.sh
159echo -e "Oracle is installed"
160echo -e "Please look the /etc/oratab file,have no SID!!!"
161


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
1#!/bin/bash
2function swapfile
3{
4dd if=/dev/zero of=/home/swap bs=1M count=$mem
5mkswap /home/swap
6echo "/home/swap         swap    swap    defaults        0 0">> /etc/fstab
7swapon -a
8}
9phymem=`free -m | grep Mem | awk  '{ printf $2 }'`
10swapmem=`free -m | grep Swap | awk  '{ printf $2 }'`
11if [ $phymem -lt 1024 ];then
12       {
13       echo "RAM is too small , oracle install faild !"
14       exit 1
15       }
16       else
17                if [ $phymem -lt 2048 ];then
18                   {
19#2swap
20                            mem=`expr $phymem \* 2 - $swapmem + 15`
21                            swapfile
22                   }
23                   else
24                            if [ $phymem -lt 16384 ];then
25                                     {
26                                               mem=`expr $phymem - $swapmem + 15`
27                                               swapfile $mem
28                                     }
29                            else
30                                     {
31                                               mem=`expr 16384 - $swapmem + 15`
32                                               swapfile $mem
33                                     }
34                            fi
35                   fi
36fi
37unzip linux_11gR2_database_1of2.zip
38unzip -o linux_11gR2_database_2of2.zip
39groupadd dba
40groupadd oinstall
41useradd -g oinstall -G dba oracle
42echo oracle | passwd oracle --stdin
43mkdir /opt/oracle
44chmod 777 /opt
45chmod 777 /opt/oracle/
46chmod 777 /var
47chmod 777 /var/opt
48mkdir -p /opt/oracle/product
49mkdir -p /opt/oracle/product/OraHome
50mkdir -p /opt/oraInventory                  
51mkdir -p /opt/oracle/oradata              
52mkdir -p /var/opt/oracle
53chown oracle:oinstall /opt
54chown -R oracle:oinstall /opt/oracle
55chown -R oracle:dba /opt/oraInventory
56chown oracle:dba /var/opt/oracle
57chmod -R 777 /opt/oracle
58chmod -R 777 /var/opt/oracle
59mkdir -p /oracle
60mv database /oracle/database
61chown oracle -R /oracle
62chown oracle.oinstall /oracle
63yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel ksh numactl-devel kernel-headers pdksh jre
64cat >> /home/oracle/.bash_profile <<EOF
65export ORACLE_BASE=/opt/oracle
66export ORACLE_HOME=/opt/oracle/product/OraHome
67export ORACLE_SID=orcl
68export ORACLE_OWNER=oracle
69export ORACLE_TERM=vt100
70export PATH=\$PATH:\$ORACLE_HOME/bin:\$HOME/bin
71export PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/Apache/Apache/bin:\$PATH
72LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
73export LD_LIBRARY_PATH
74CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
75CLASSPATH=\$CLASSPATH:\$ORACLE_HOME/network/jlib
76export CLASSPATH
77ORA_NLS33=\$ORACLE_HOME/nls/admin/data
78EOF
79cat >> /etc/security/limits.conf <<EOF
80oracle soft nofile 65536
81oracle hard nofile 65536
82oracle soft nproc 16384
83oracle hard nproc 16384
84EOF
85echo "session required /lib/security/pam_limits.so" >> /etc/pam.d/login
86echo "session required pam_limits.so" >> /etc/pam.d/login
87cat >> /etc/profile <<EOF        
88if [ \$USER = "oracle" ]; then
89if [ \$SHELL = "/bin/ksh" ];then
90                 ulimit -p 16384
91                 ulimit -n 65536
92         else
93                 ulimit -u 16384 -n 65536
94         fi
95fi
96EOF
97export DISPLAY=:0.0
98xhost +
99cat >> /etc/sysctl.conf <<EOF
100fs.aio-max-nr = 1048576
101kernel.shmall = 2097152
102kernel.shmmax = 536870912
103kernel.shmmni = 4096
104kernel.sem = 250 32000 100 128
105fs.file-max = 6815744
106net.ipv4.ip_local_port_range = 9000 65500
107net.core.rmem_default = 262144
108net.core.rmem_max = 4194304
109net.core.wmem_max = 1048576
110net.core.wmem_default = 262144
111EOF
112sysctl -p
113echo "IS OK! 10s will be reboot!"
114sleep 10
115reboot
116

给TA打赏
共{{data.count}}人
人已打赏
安全技术安全运维

Windows服务器如何发现被黑

2018-5-20 12:24:31

安全技术

Node.js + MongoDB + AngularJS - 5 在Node.js中处理数据I0-1

2021-12-21 16:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索