欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle11.2.0.1在Linux-X64下安装脚本-

程序员文章站 2023-12-23 10:54:16
...

Oracle在linux上安装前需要做一系列的配置;每次搭建环境如果都手动执行有点慢;这里写了两个脚本,实现自动化配置和安装,目前在

Oracle在linux上安装前需要做一系列的配置;每次搭建环境如果都手动执行有点慢;
这里写了两个脚本,实现自动化配置和安装,目前在自己的CentOS6.3的linux模板上安装成功;
在其他系统上未测试,使用前,要先理解脚本,配置好一个网卡的静态IP地址,适当修改后再操作;
脚本由一系列函数,顺序组成;

#!/bin/bash
#set -x
echo "Start Configure Oracle Environment For Install......................... "
time=`date +%Y%m%d_%H%M%S`
flag="####################################################################"


#备份配置文件,很简单,仅仅是复制一下将要修改的系统配置文件;复制了两份,便于恢复
backup_config(){
#echo "$flag"
echo "#########################Step 1:backup system config that will be modified###########################"
cp /etc/sysconfig/network /etc/sysconfig/network.bak${time}
cp /etc/sysctl.conf /etc/sysctl.conf.bak${time}
cp /etc/security/limits.conf /etc/security/limits.conf.bak${time}
cp /etc/pam.d/login /etc/pam.d/login.bak${time}
cp /etc/profile /etc/profile.bak${time}
cp /home/oracle/.bash_profile /home/oracle/.bash_profile.bak${time}
cp /etc/selinux/config /etc/selinux/config.bak${time}

cp /etc/sysconfig/network /etc/sysconfig/network.bak
cp /etc/sysctl.conf /etc/sysctl.conf.bak
cp /etc/security/limits.conf /etc/security/limits.conf.bak
cp /etc/pam.d/login /etc/pam.d/login.bak
cp /etc/profile /etc/profile.bak
cp /home/oracle/.bash_profile /home/oracle/.bash_profile.bak
cp /etc/selinux/config /etc/selinux/config.bak
}


#获取当前系统信息,配置hostname,关闭selinux
sys_info()
{
#echo "$flag"
echo "check system space and version";
echo "#########################Step 2:check system space and versio#########################################"
uname -a
cat /etc/*release
df -h
hostname
ip_add=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' |cut -d: -f2 | awk '{ print $1}'`
ip_code=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' |cut -d: -f2 | awk '{ print $1}'|cut -d. -f4`
echo "$ip_add oraserver${ip_code}" >> /etc/hosts
sed -i '/HOSTNAME=/s/localhost.localdomain/oraserver'"${ip_code}"'/' /etc/sysconfig/network
sed -i '/SELINUX=/s/enforcing/disabled/' /etc/selinux/config
hostname oraserver${ip_code}
}


#安装需要的依赖包,,不同的系统当然定制的RPM不一样,这一步大可手工检查
rpm_info()
{
echo "#########################Step 2:install oracle rpms ###################################################"
rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ make numactl-devel sysstat unixODBC unixODBC-devel elfutils-libelf-devel-static kernel-headers libgomp
rpm -ivh /root/rpm-centos/lrzsz-0.12.20-27.1.el6.x86_64.rpm
rpm -ivh /root/rpm-centos/compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
rpm -ivh /root/rpm-centos/unixODBC*
rpm -ivh /root/rpm-centos/libaio*
rpm -ivh /root/rpm-centos/numactl*
rpm -ivh /root/rpm-centos/sysstat*
rpm -ivh /root/rpm-centos/unzip-6.0-1.el6.x86_64.rpm
rpm -ivh /root/rpm-centos/ksh-20100621-16.el6.x86_64.rpm
rpm -ivh /root/rpm-centos/elfutils-libs-0.152-1.el6.x86_64.rpm
rpm -ivh /root/rpm-centos/elfutils-libelf-devel*
echo "##########After Install essential rpms"
rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ make numactl-devel sysstat unixODBC unixODBC-devel elfutils-libelf-devel-static kernel-headers libgomp
}


#创建oracle用户、相关目录、允许oracle以sudo来以root用户执行脚本
oracle_user()
{
echo "#########################Step 3:add oracle user and group,create directory #############################"
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba -d /home/oracle -m -s /bin/bash -c "ORACLE" oracle
echo "oracle:oracle" > /root/oracle_pass
chpasswd rm -rf /root/oracle_pass
id oracle;
id nobody;
echo "";
echo "##########create oracle directory"
mkdir -p /oracle;
mkdir -p /oracle/oraInventory;
chown -R oracle:oinstall /oracle;
chmod -R 775 /oracle/;
echo "##########Add Oracle to sudu user "
chmod u+w /etc/sudoers
echo "oracle ALL=(ALL) ALL" >>/etc/sudoers
chmod u-w /etc/sudoers
}

上一篇:

下一篇: