如果您在使用本文档安装oracle过程中存在问题,请留言
0.配置yum源
#参开地址
http://blog.csdn.net/JW_xueZhiXia/article/details/78709810
1.配置主机名
cat >> /etc/sysconfig/network <<EOF
HOSTNAME=oracle
EOF
echo oracle >/proc/sys/kernel/hostname
#将本机主机名与ip加入/etc/hosts中,填写实际IP
echo "192.168.76.157 oracle" >> /etc/hosts
2.关闭selinux与防火墙
echo "SELINUX=disabled" >> /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
3.配置yum安装依赖
yum install -y gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel vim unzip
yum install -y libgcc.i686 glibc.i686 glibc-devel.i686 libaio.so.1 libXext.so.6 compat-libstdc++-33.i686
#写入/etc/profile
cat >> /etc/profile <<EOF
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/u01/app/oracle/product/11.2.0/inventory/Scripts/ext/lib
EOF
4.创建用户用户组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
echo "123456" | passwd --stdin oracle
5.修改内核参数
cat >> /etc/sysctl.conf <<EOF
io-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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 = 1048576
EOF
sysctl -p
6.修改用户的限制文件
cat >> /etc/security/limits.conf << EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
cat >> /etc/pam.d/login <<EOF
session required /lib64/security/pam_limits.so
session required pam_limits.so
EOF
7.修改/etc/profile文件
cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
8.创建目录
mkdir -p /u01/app/oracle/product/11.2.0
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/inventory
mkdir /u01/app/oracle/fast_recovery_area
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
9.上传包至/tmp下并解压
#安装包下载地址
https://updates.oracle.com/Orion/Services/download/p13390677_112040_LINUX_1of7.zip?aru=16720989&patch_file=p13390677_112040_LINUX_1of7.zip
https://updates.oracle.com/Orion/Services/download/p13390677_112040_LINUX_2of7.zip?aru=16720989&patch_file=p13390677_112040_LINUX_2of7.zip
cd /tmp
unzip p13390677_112040_LINUX_1of7.zip
unzip p13390677_112040_LINUX_2of7.zip
10.切换到oracle用户,设置oracle用户环境变量
su - oracle
cat >> ~/.bash_profile <<EOF
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=\$PATH:\$ORACLE_HOME/bin
export ORACLE_UNQNAME=$ORACLE_SID
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
EOF
11.切换root编辑静默安装响应文件
#切换至root,或者exit退出oracle用户
su -
sed -i 's#oracle.install.option=#oracle.install.option=INSTALL_DB_SWONLY#g' /tmp/database/response/db_install.rsp
sed -i 's#ORACLE_HOSTNAME=#ORACLE_HOSTNAME=oracle#g' /tmp/database/response/db_install.rsp
sed -i 's#UNIX_GROUP_NAME=#UNIX_GROUP_NAME=oinstall#g' /tmp/database/response/db_install.rsp
sed -i 's#INVENTORY_LOCATION=#INVENTORY_LOCATION=/u01/app/oracle/inventory#g' /tmp/database/response/db_install.rsp
sed -i 's#SELECTED_LANGUAGES=en#SELECTED_LANGUAGES=en,zh_CN#g' /tmp/database/response/db_install.rsp
#
sed -i 's#ORACLE_HOME=#ORACLE_HOME=/u01/app/oracle/product/11.2.0#g' /tmp/database/response/db_install.rsp
sed -i 's#ORACLE_BASE=#ORACLE_BASE=/u01/app/oracle#g' /tmp/database/response/db_install.rsp
sed -i 's#oracle.install.db.InstallEdition=#oracle.install.db.InstallEdition=EE#g' /tmp/database/response/db_install.rsp
sed -i 's#oracle.install.db.DBA_GROUP=#oracle.install.db.DBA_GROUP=dba#g' /tmp/database/response/db_install.rsp
sed -i 's#oracle.install.db.OPER_GROUP=#oracle.install.db.OPER_GROUP=dba#g' /tmp/database/response/db_install.rsp
sed -i 's#DECLINE_SECURITY_UPDATES=#DECLINE_SECURITY_UPDATES=true#g' /tmp/database/response/db_install.rsp
12.切换oracle用户
su - neusoft
/tmp/database/runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
13.切换root执行
#按照提示切换root用户运行脚本
su -
sh /u01/app/oracle/inventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0/root.sh
14.切换oracle用户为登录配置监听
su - oracle
/u01/app/oracle/product/11.2.0/bin/netca -silent -responseFile /tmp/database/response/netca.rsp
15.切换root建立新库,同时建立对应的实例
sed -i "s#GDBNAME = \"orcl11g.us.oracle.com\"#GDBNAME = \"orcl\"#g" /tmp/database/response/dbca.rsp
sed -i "s#SID = \"orcl11g\"#SID = \"orcl\"#g" /tmp/database/response/dbca.rsp
sed -i "s/#SYSPASSWORD = \"password\"/SYSPASSWORD = \"oracle\"/g" /tmp/database/response/dbca.rsp
sed -i "s/#SYSTEMPASSWORD = \"password\"/SYSTEMPASSWORD = \"oracle\"/g" /tmp/database/response/dbca.rsp
sed -i "s/#SYSMANPASSWORD = \"password\"/SYSMANPASSWORD = \"oracle\"/g" /tmp/database/response/dbca.rsp
sed -i "s/#DBSNMPPASSWORD = \"password\"/DBSNMPPASSWORD = \"oracle\"/g" /tmp/database/response/dbca.rsp
sed -i "s;#DATAFILEDESTINATION =;DATAFILEDESTINATION =/u01/app/oracle/oradata;g" /tmp/database/response/dbca.rsp
sed -i "s;#RECOVERYAREADESTINATION=;RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area;g" /tmp/database/response/dbca.rsp
sed -i "s;#CHARACTERSET = \"US7ASCII\";CHARACTERSET = \"ZHS16GBK\";g" /tmp/database/response/dbca.rsp
sed -i "s;#TOTALMEMORY = \"800\";TOTALMEMORY = \"1638\";g" /tmp/database/response/dbca.rsp
16.切换oracle进行静默配置
su - oracle
/u01/app/oracle/product/11.2.0/bin/dbca -silent -responseFile /tmp/database/response/dbca.rsp
export ORACLE_HOME_LISTNER=$ORACLE_HOME
cat >> ~/.bash_profile <<EOF
export ORACLE_HOME_LISTNER=\$ORACLE_HOME
EOF
17.查看监听状态
lsnrctl status
#启动
lsnrctl start
18.设置开机启动
#root用户执行
su -
sed -i 's#N#Y#g' /etc/oratab
#切换oracle用户执行
su - oracle
vi $ORACLE_HOME/bin/dbstart
#将ORACLE_HOME_LISTNER=$1换成
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi $ORACLE_HOME/bin/dbshut
#将ORACLE_HOME_LISTNER=$1换成
ORACLE_HOME_LISTNER=$ORACLE_HOME
#编写脚本
> /etc/init.d/oracle
vim /etc/init.d/oracle
#!/bin/sh
#chkconfig: 2345 20 80
#description: Oracle dbstart / dbshut
#以上两行为chkconfig所需
ORA_HOME=/u01/app/oracle/product/11.2.0
ORA_OWNER=oracle
LOGFILE=/var/log/oracle.log
echo "#################################" >> ${LOGFILE}
date +"### %T %a %D: Run Oracle" >> ${LOGFILE}
if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then
echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
exit
fi
start(){
echo "###Startup Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"
echo "###Done."
echo "###Run database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"
echo "###Done."
}
stop(){
echo "###Stop database control..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"
echo "###Done."
echo "###Shutdown Database..."
su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"
echo "###Done."
}
case "$1" in
'start')
start >> ${LOGFILE}
;;
'stop')
stop >> ${LOGFILE}
;;
'restart')
stop >> ${LOGFILE}
start >> ${LOGFILE}
;;
esac
date +"### %T %a %D: Finished." >> ${LOGFILE}
echo "#################################" >> ${LOGFILE}
echo ""
#将 oracle 添加到 chkconfig中:
chkconfig --add oracle
#可使用如下命令查看和设置oracle服务的开机启动级别:
chkconfig | grep oracle #查看oracle服务的开机启动级别
chkconfig --level 24 oracle off #修改oracle服务的开机启动级别
chkconfig --level 35 oracle on
#至此可使用如下命令对oracle的启动或关闭进行管理
service oracle start #启动
service oracle stop #关闭
service oracle restart #重启
#建立连接:
ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle #关机执行
ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle #重启执行
19.连接串配置
vm =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.76.157)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)