文章目录
centos 6上安装oracle 10g安装
环境准备:
- 网卡配置固定ip
- /etc/hosts里配置好主机名与ip的解析
- 防火墙和selinux关闭
第一步:一键准备环境脚本
脚本可以多次运行,主机名是oracle可以进行更改,有设置aliyun的epel源和yum源,内容如下:
#!/bin/bash
# create a auto-install oracle_10g-db
# Author: clc
# create data: 2017-04-28
# OS: CENTOS 6
# set hostname is oracle
function env_prepare(){
# stop iptables and selinux
/etc/init.d/iptables stop && chkconfig --level 35 iptables off
setenforce 0 && sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
#change hostname
hostname oracle
a=`grep -c "HOSTNAME=oracle" /etc/sysconfig/network`
if [ $a -lt 1 ]
then
echo "HOSTNAME=oracle">>/etc/sysconfig/network
fi
#add hostname to hosts
a_ip=`ifconfig |awk -F "[: ]+" '{if(NR==2)print $4}'`
a_host=`hostname`
bb=`grep -c "${a_host}" /etc/hosts`
if [ $bb -lt 1 ]
then
echo "${a_ip} ${a_host}" >>/etc/hosts
fi
#change repo and epel yum
ee=`ls /etc/yum.repos.d/|grep epel.repo|wc -l`
if [ $ee -lt 1 ]
then
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup\
&& wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo\
&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
fi
#software install
yum install gcc make binutils gcc-c++ compat-libstdc++-33 \
elfutils-libelf-devel elfutils-libelf libaio libaio-devel \
numactl-devel sysstat unixODBC unixODBC-devel glibc \
glibc-common glibc-devel glibc-headers libgcc libgomp\
libstdc++ libstdc++-devel pdksh unzip libXp -y
yum -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 \
libXt.i686 libXtst.i686 libXp.i686
cc=`rpm -aq|grep pdksh|wc -l`
dd=`ls |grep "pdksh"|wc -l`
if [ $cc -lt 1 -a $dd -lt 1 ]
then
wget ftp://ftp.linux.ro/centos/5.11/os/i386/CentOS/pdksh-5.2.14-37.el5_8.1.i386.rpm \
&& rpm -ivh pdksh-5.2.14-37.el5_8.1.i386.rpm
fi
#create user
b=`grep -c "oinstall" /etc/group`
c=`grep -c "dba" /etc/group`
d=`grep -c "oracle" /etc/passwd`
if [ $b -lt 1 ]
then
groupadd oinstall
fi
if [ $c -lt 1 ]
then
groupadd dba
fi
if [ $d -lt 1 ]
then
useradd -G dba,oinstall -g dba oracle
fi
#mkdir directory
mkdir /data/oracle -p
#change directory privileges
chown -R oracle:oinstall /data/oracle
#enviroment prepare
e=`egrep -c "2047|16384|1024|65536" /etc/security/limits.conf `
if [ $e -lt 4 ]
then
echo "oracle soft nproc 2047" >>/etc/security/limits.conf
echo "oracle hard nproc 16384" >>/etc/security/limits.conf
echo "oracle soft nofile 1024" >>/etc/security/limits.conf
echo "oracle hard nofile 65536" >>/etc/security/limits.conf
fi
#kernel set
f=`egrep -c "1048576|6815744|2097152|4096|9000|32000|262144|\
4194304|262144|1048576" /etc/sysctl.conf`
if [ $f -lt 10 ]
then
echo -e "kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=262144
vm.hugetlb_shm_group = 501" >>/etc/sysctl.conf && \
sysctl -p
fi
#pam.d _login增加
gg=`egrep -c "pam_limits.so" /etc/pam.d/login`
if [ $gg -lt 2 ]
then
echo -e "session required /lib64/security/pam_limits.so
session required pam_limits.so" >> /etc/pam.d/login
fi
#login 限制其他用户使用
hh=`egrep -c "16384" /etc/profile`
if [ $hh -lt 2 ]
then
echo -e "if [ $USER = "oracle" ]; then
if [ $SHELL = “/bin/ksh” ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi" >> /etc/profile
fi
#oracle env
g=`egrep -c "ORACLE_HOME|ORACLE_BASE" /home/oracle/.bash_profile`
if [ $g -lt 2 ]
then
echo 'export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=byxdb
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LC_CTYPE=en_US.UTF-8
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8" '>/tmp/oracle_env && \
su - oracle -c -l "cat /tmp/oracle_env >>/home/oracle/.bash_profile"
fi
#change redhat-relese
echo 'redhat-4' >/etc/redhat-release
#add swap space
ff=`ls /home|grep "swapfile"|wc -l `
if [ $ff -lt 1 ]
then
dd if=/dev/zero of=/home/swapfile bs=1M count=2048 && \
mkswap /home/swapfile && \
swapon /home/swapfile
fi
}
function main(){
env_prepare
}
main
安装过程中会跳出一个错,可以忽略,
最后配置开机启动,dbstart启动的时候会报错,因为dbstart文件中监听位置配置错了,配置成以下:
#ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle #这个是原来的配置,这里位置错了,导致启动不了。 ORACLE_HOME_LISTNER=$ORACLE_HOME
# vi /etc/oratab --修改开机启动,将值由N设为Y
hyl:/home/u01/app/oracle/product/10.2.0/db_1:Y
开机启动配置:/etc/rc.local
su - oracle -c "/data/oracle/product/10.2.0/db_1/bin/lsnrctl start" su - oracle -c "/data/oracle/product/10.2.0/db_1/bin/dbstart " su - oracle -c "isqlplusctl start" su - oracle -c "emctl start dbconsole"
可以参考:https://www.ilanni.com/?p=4672
https://www.ilanni.com/?p=4733
原文链接:centos 6上安装oracle 10g安装,转载请注明来源!
