云平台Centos 7.6 静默安装oracle 11r数据库

Posted 小堂运维笔记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了云平台Centos 7.6 静默安装oracle 11r数据库相关的知识,希望对你有一定的参考价值。

      前言:

目前绝大多数的centos云主机都是没有图形界面的,数据库迁移上云的话这对于之前用图形界面安装的小伙伴们无疑是增加了许多工作量,现整理一份最为完整oracle静默安装方法,方便各位小伙伴在云主机上面安装oracle数据库。


准备条件:

云主机4核 8g内存 操作系统centos 7.6

Oracle 安装包 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
上传到/home目录下解压


一、安装依赖

yum -y install 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


二、创建用户

sysctl -p
groupadd -g 200 oinstall
groupadd -g 201 dba
useradd -u 440 -g oinstall -G dba oracle
###修改oracle密码为rjy@666
echo oracle:rjy@666|chpasswd


三、配置系统文件

cat >>/etc/sysctl.conf<<dd
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 100128
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
dd


四、配置limits.conf文件

cat >>/etc/security/limits.conf<<eof
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
eof
cat >>/etc/pam.d/login<<eof
session required pam_limits.so
eof
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


五、新建文件目录

mkdir -p /home/oracle/app/
mkdir -p /home/oracle/oradata/
chmod 755 /home/oracle/
chmod 775 /home/oracle/app/
chown oracle.oinstall -R /home/oracle/


六、设置环境变量

cat >>~/.bash_profile<<eof
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=\\$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=\\$PATH:\\$ORACLE_HOME/bin
export ORACLE_SID=orcl
export ORACLE_PID=orcl
eof
cat >>/home/aa.txt<<eof
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=\\$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=\\$PATH:\\$ORACLE_HOME/bin
export ORACLE_SID=orcl
export ORACLE_PID=orcl
eof
su - oracle <<eof
cat /home/aa.txt>>~/.bash_profile
eof


七、设置oracle安装配置文件

sed -i "s#oracle.install.option=#oracle.install.option=INSTALL_DB_SWONLY#g"  /home/database/response/db_install.rsp
sed -i "s#ORACLE_HOSTNAME=#ORACLE_HOSTNAME=$hname#g" /home/database/response/db_install.rsp
sed -i "s#UNIX_GROUP_NAME=#UNIX_GROUP_NAME=oinstall#g" /home/database/response/db_install.rsp
sed -i "s#INVENTORY_LOCATION=#INVENTORY_LOCATION=/home/oracle/app/oraInventory#g" /home/database/response/db_install.rsp
sed -i "s#SELECTED_LANGUAGES=#SELECTED_LANGUAGES=en,zh_CN,zh_TW#g" /home/database/response/db_install.rsp
sed -i "s#ORACLE_HOME=#ORACLE_HOME=/home/oracle/app/product/11.2.0/dbhome_1#g" /home/database/response/db_install.rsp
sed -i "s#ORACLE_BASE=#ORACLE_BASE=/home/oracle/app#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.InstallEdition=#oracle.install.db.InstallEdition=EE#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.DBA_GROUP=#oracle.install.db.DBA_GROUP=dba#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.OPER_GROUP=#oracle.install.db.OPER_GROUP=oinstall#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.config.starterdb.type=#oracle.install.db.config.starterdb.type=GENERAL_PURPOSE#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.config.starterdb.globalDBName=#oracle.install.db.config.starterdb.globalDBName=orcl#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.config.starterdb.SID=#oracle.install.db.config.starterdb.SID=orcl#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.config.starterdb.memoryLimit=#oracle.install.db.config.starterdb.memoryLimit=81920#g" /home/database/response/db_install.rsp
sed -i "s#oracle.install.db.config.starterdb.password.ALL=#oracle.install.db.config.starterdb.password.ALL=oracle#g" /home/database/response/db_install.rsp
sed -i "s#SECURITY_UPDATES_VIA_MYORACLESUPPORT=#SECURITY_UPDATES_VIA_MYORACLESUPPORT=false#g" /home/database/response/db_install.rsp
sed -i "s#DECLINE_SECURITY_UPDATES=#DECLINE_SECURITY_UPDATES=true#g" /home/database/response/db_install.rsp


八、安装oracle

oracle 用户下执行

cd /home/database/
./runInstaller -silent -ignorePrereq -responseFile /home/database/response/db_install.rsp


云平台Centos

云平台Centos

云平台Centos

切换root用户执行:

/home/oracle/app/oraInventory/orainstRoot.sh
/home/oracle/app/product/11.2.0/dbhome_1/root.sh


安装监听

su - oracle
cd /home/oracle/app/product/11.2.0/dbhome_1/bin/
netca /silent /responseFile /home/database/response/netca.rsp

云平台Centos

成功运行后

在/home/oracle/app/product/11.2.0/dbhome_1/network/admin/中生成listener.ora和sqlnet.ora

云平台Centos

安装数据库

dbca -silent -createDatabase -characterset ZHS16GBK -templateName $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc -gdbName orcl -sid orcl -sysPassword sys -systemPassword system

oracle设置

root用户执行

sed -i s#orcl:/home/oracle/app/product/11.2.0/dbhome_1:N#orcl:/home/oracle/app/product/11.2.0/dbhome_1:Y#g /etc/oratab
cat >>/etc/rc.d/rc.local<<eof
su - oracle -lc "/home/oracle/app/product/11.2.0/dbhome_1/bin/lsnrctl start"
su - oracle -c "/home/oracle/app/product/11.2.0/dbhome_1/bin/dbstart"
Eof
##授权rc.local文件
chmod +x /etc/rc.d/rc.local


oracle优化

cat >>/home/oracle.sq<<EOF
sqlplus / as sysdba <<DD
alter system set deferred_segment_creation=false;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
shutdown immediate;
startup mount;
alter system enable restricted session;
alter system set job_queue_processes=0;
alter system set aq_tm_processes=0;
alter database open;
ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK;
ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;
alter system set processes=1000 scope=spfile;
alter system set sessions=1105 scope=spfile;
shutdown immediate;
startup;
DD
EOF

授权执行

chmod -R 777 /home/oracle.sq
su - oracle -c "/home/oracle.sq"


防火墙放行端口

firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --zone=public --add-port=1158/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports

遇到问题:

Checking swap space: 0 MB available, 150 MB required. Failed

云平台Centos

解决方法:

dd if=/dev/zero of=/swapfile bs=1024 count=512k
mkswap /swapfile
swapon /swapfile

/etc/fstab 文件,在其最后添加如下一行:

/swapfile          swap            swap    defaults        0 0


结束语:

全程复制粘贴命令即可,小编安装完大概耗时15分钟左右,云主机的各项性能还是杠杠滴。

以上是关于云平台Centos 7.6 静默安装oracle 11r数据库的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 6.5下静默安装oracle

Centos6.10静默安装Oracle 11G详细教程

oracle11g静默安装

Linux静默安装Oracle

CentOS7.2静默安装Oracle11G

CentOS 7静默(无图形化界面)安装Oracle 11g