Red Hat Enterprise Linux 6.2-32位下一键安装Oracle 11G软件(Shell)

Idea:刚刚在Linux上安装Oracle的时候,搞了好几遍,遇到的问题有:目录权限不足,/etc/hosts配置出错,缺失依赖包,显示不出图形界面等等……又看了看Oracle官方安装文档之后,觉得安装步骤太繁杂,就把他们的指令全部加到了shell里面,方便。下面全部用了If条件判断语句,程序设计鸡肋,大家对这个脚本有什么意见或者问题尽管提出来。也希望能学到更多的东西~


#!/bin/bash

# Program
#       Install Oracle 11G_r2 shell for self
# History:
# 2015/4/25     Kernelry        first release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/~/bin
export PATH


echo "#操作系统版本信息:
Linux linux2 2.6.32-220.el6.i686 #1 SMP Wed Nov 9 08:02:18 EST 2011 i686 i686 i#386 GNU/Linux


#两个ISO文件信息:
#1、redhat6.2_x32--挂载在/dev/sr1 2、Oracle_Linux 32--挂载在/dev/sr0


##检查硬件需求  Memory  ,Disk Space
#至少有1G的RAM,Swap是RAM的1.5倍左右
#/tmp所剩空间大于1G
#执行free -m 查询 RAM 和 Swap 大小,df -h 查询 /tmp大小"
free -m
echo -e "\n"
df -h
echo -e"
#yum 管理工具软件仓库文件的配置  /etc/yum.repos.d/server.repo
#[server]
#name=Red Hat Enterprise Linux 6.2
#baseurl=file:///media/CDROM/Server   ---方便后续安装依赖包
#enabled=1
#gpgcheck=0


#注释掉/etc/sysctl.conf文件里的 #kernel.shmmax 和 #kernel.shmall
#因为稍后我们将在此配置文件里增加一些参数,以免冲突。


#修改/etc/hosts 里面的 ip地址与主机名,主机名要对应IP,才能连上数据库
[root@linux2 Desktop]# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:0C:29:40:47:20  
          inet addr:183.47.65.163  Bcast:183.47.65.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe40:4720/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:195 errors:0 dropped:0 overruns:0 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17581 (17.1 KiB)  TX bytes:8028 (7.8 KiB)
          Interrupt:19 Base address:0x2024 


[root@linux2 Desktop]# hostname
linux2


[root@linux2 Desktop]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


183.47.65.163    linux2c


#以上工作准备好之后让我们开始安装Oracle    执行方法: sh 程序名.后缀名   
#     exp: sh Install_Oracle.sh"



echo -e "以下步骤共8步\n
#1、用root用户登陆操作系统\n
#注意:必须要以X窗口系统才能安装,执行xhost命令\n"
read -p " Please input 'y/n' excute the xhost command. : " xhost
if [ "$xhost" == "y" ]; then
xhost +
else
exit 0
fi






echo -e "#\n2、安装缺少依赖包,经测试,只需安装以下依赖包
---> Package compat-libcap1.i686 0:1.10-1 will be installed
---> Package compat-libstdc++-33.i686 0:3.2.3-69.el6 will be installed
---> Package elfutils-libelf-devel.i686 0:0.152-1.el6 will be installed
---> Package gc.i686 0:7.1-10.el6 will be installed
---> Package gcc-c++.i686 0:4.4.6-3.el6 will be installed
---> Package ksh.i686 0:20100621-12.el6 will be installed
---> Package libaio-devel.i686 0:0.3.107-10.el6 will be installed
---> Package libstdc++-devel.i686 0:4.4.6-3.el6 will be installed
---> Package unixODBC.i686 0:2.2.14-11.el6 will be installed
---> Package unixODBC-devel.i686 0:2.2.14-11.el6 will be installed
--> Finished Dependency Resolution
"
read -p "Please input 'y/n' excute the yum command. : " ym
if [ "$ym" == "y" ]; then
yum install binutils compat-libcap1 compat-libstdc++-33.i686 gcc gcc-c++ glibc glibc-devel ksh libgc libstdc++ libstdc++-devel libaio libaio-devel "make" sysstat pdksh unixODBC unixODBC-devel elfutils-libelf-devel.i686
rpm -ivh --nodeps /media/CDROM/Packages/pdksh-5.2.14-2.i386.rpm
else
exit 0
fi


echo -e "#\n3、建立操作系统组和用户"
read -p "Please input 'y/n' Creating Required Operating System Groups and Users. : " add
if [ "$add" == "y" ]; then
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
grep dba oinstall /etc/group
id oracle
passwd oracle
else
exit 0
fi


echo -e "#\n4、配置内核参数:注意注释掉kernel.shmmin 和kernel.shmmax"
read -p "Please input 'y/n' Configuring Kernel Parameters. :" kl
if [ "$kl" == "y" ]; then
echo "fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586 " >> /etc/sysctl.conf
/sbin/sysctl -p
else
exit 0
fi


echo -e "#\n5.为Oracle用户设置Shell限制"
read -p "Please input 'y/n' Setting Shell Limits the oracle User. :" lt
if [ "$lt" == "y" ]; then
echo "oracle           soft    nproc   2047
oracle           hard    nproc   16384
oracle           soft    nofile  1024
oracle           hard    nofile  65536" >> /etc/security/limits.conf
else
exit 0
fi


echo -e "#\n6.为 /etc/pam.d/login 添加限制文件"
read -p "Please input 'y/n'   the following changes to the default shell startup file :" sl
if [ "$sl" == "y" ]; then
echo "if [ "$USER" = "oracle" ]; then
if [ "$SHELL" = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
else
     ulimit -u 16384 -n 65536
fi
fi" >> /etc/pam.d/login
else
exit 0
fi




echo -e "\n7.#创建所需的目录"
read -p "Please input 'y/n'  Creating Required Directories:" dr
if [ "$dr" == "y" ]; then
mkdir -p /u01/app/
chown -R oracle:oinstall /u01
chmod -R 775 /u01
ls -l /u01
else
exit 0
fi


echo "\n8.#更改Oracle用户的环境"
read -p "Please input 'y/n' Configuring the oracle User's Environment:" ev
if [ "$ev" == "y" ]; then
echo "TMP=/u01/tmp
TMPDIR=/u01/tmp
export TMP  TMPDIR


ORACLE_BASE=/u01/app/oracle
ORACLE_SID=oracle
export ORACLE_BASE ORACLE_SID" >> /home/oracle/.bash_profile
else
exit 0
fi


echo -e "配置完成,用oracle用户登陆,并到database目录下执行install文件.
su - oracle
/media/MyCDROM/database/runInstaller"
su - oracle
sync;sync

你可能感兴趣的:(oracle,linux,数据库,shell,red,11g,hat)