一、环境版本
系统版本:CentOS 6.3 X86_64(最小化安装)
数据库版本:Oracle 11gR2X86_64(Release 11.2.0.1.0)
主机名:GZ-DDN
IP地址:192.168.1.253
二、基本组件及更新
#yum install wgetvim-enhanced which screen make setuptool system-config-network*system-config-firewall* xorg-x11-xauth && yum groupinstall “development tools” && yum update
三、Oracle依赖包安装及工具
#yum install binutils compat-libstdc++-33elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gccgcc-c++ libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstatunixODBC unixODBC-devel pdksh
四、关闭selinux
#vim/etc/selinux/config
将SELINUX=enforcin g改为 SELINUX=disabled 并重启生效
# setenforce 0
五、修改内核参数
[root@db01 ~]# vi /etc/sysctl.conf
# make it comment
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
#net.bridge.bridge-nf-call-arptables = 0
# add at the last line
net.ipv4.ip_local_port_range = 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576
[root@db01 ~]# sysctl -p #使以上修改生效
六、添加oracle用户
[root@db01 ~]# groupadd -g 200 oinstall
[root@db01 ~]# groupadd -g 201 dba &mkdir /app/users
[root@db01 ~]# useradd -u 440 -g oinstall -G dba -m -d/app/users/oracle oracle
[root@db01 ~]#passwd oracle #设置oracle用户的密码
[root@db01 ~]# mkdir -p /oracle/DB #创建oracle要安装的目录
[root@db01 ~]# chown -R oracle:oinstall /oracle #设置目录权限
在/etc/hosts中添加主机名解析
[root@db01~]#vim /etc/hosts
添加以下行:
192.168.10.50 GZ-DDN
[root@db01 ~]# vi/etc/pam.d/login
# near line 14: add
session required pam_selinux.so open
session required pam_namespace.so
session requiredpam_limits.so
session optional pam_keyinit.so force revoke
session include system-auth
-session optional pam_ck_connector.so
[root@db01 ~]# vi /etc/security/limits.conf
# add at the last line
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
[root@db01 ~]# vi /etc/profile
# add at the last line
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[root@db01 ~]# su - oracle
[oracle@localhost ~]$ vi .bash_profile (设置环境变量)
export PATH
ORACLE_BASE=/oracle/DB
ORACLE_HOME=$ORACLE_BASE/oracle
ORACLE_SID=DB01
PATH=$ORACLE_HOME/bin:$PATH
exportORACLE_BASE ORACLE_HOME ORACLE_SID PATH
alias sqlplus='rlwrap sqlplus'
alias rman='rlwraprman'
退出当前会话,并重新以oracle用户登录后确认:
[oracle@localhost ~]$ env|grepORA
ORACLE_SID=DB01
ORACLE_BASE=/oracle
ORACLE_HOME=/oracle/DB
至此,安装oracle的前期准备工作就全部完成了。
七、安装oracle软件
[root@db01 ~]# unzip linux.x64_11gR2_database_1of2.zip&& unzip linux.x64_11gR2_database_2of2.zip
[root@db01 ~]# chown -R oracle:oinstall database
[oracle@oatest2 database]$./runInstaller
执行root.sh
安装软件包命令:
例如yum installcompat-libstdc++*i686安装32位的软件包,根据依赖关系,会自动安装相关的软件包。
例如yuminstallcompat-libstdc++*x86_64安装64位的软件包,根据依赖关系,会自动安装相关的软件包。
八、开机启动
方法一:加入启动脚本:
# vi /etc/oratab
#orcl:/home/oracle/DB/oracle:N
orcl:/home/oracle/DB/oracle:Y
su - oracle -c"/usr/local/oracle/product/10201/bin/dbstart start"
su - oracle -c "/usr/local/oracle/product/10201/bin/lsnrctlstart"
方法二:
# vi /etc/oratab
#orcl:/home/oracle/DB/oracle:N
orcl:/home/oracle/DB/oracle:Y
修改dbstart 和dbshut 路径:$ORACLE_HOME/bin/
ORACLE_HOME_LISTNER=$ORACLE_HOME
增加启动脚本
cd /etc/rc.d/init.d
vi oraserver
chmod 755 oraserver
写入以下内容
#!/bin/bash # chkconfig: 2345 99 01 # description: Oracle10g Server # processname: oraserver # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network RETVAL=0 prog="oraserver" ORACLE_HOME=/app/oracle/product/10.2.0/db_1 if [ ! -f $ORACLE_HOME/bin/dbstart ] then echo "Oracle10g cannot start:Cannot find dbstart..." exit fi start() { echo "Starting Oracle10g Server..." su - oracle -c "$ORACLE_HOME/bin/dbstart" RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole" return $RETVAL } stop() { su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole" echo "Stoping Oracle10g Server..." su - oracle -c "$ORACLE_HOME/bin/dbshut" RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL } restart() { echo "Restart Oracle10g Server" stop start echo } case "$1" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/$prog ]; then stop start RETVAL=$? fi ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 2 esac exit $RETVAL
添加服务
chkconfig --add oraserver
chkconfig --list oraserver
find /etc/rc.d -name '*oraserver' -print