Oracle快速静默安装

参考地址:https://blog.51cto.com/mflag/2420185

操作系统环境:最小化安装 centos7

一、创建目录、更新补丁、安装依赖包与创建用户
mkdir -p /data/u01/software
yum -y groupinstall 'Development Tools'
yum -y install epel-release lrzsz vim unzip net-tools lsof
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
echo "oracleadmin" | passwd --stdin oracle
mkdir -p /data/u01/app/oracle/product/11.2.0/dbhome_1
mkdir /data/u01/app/oracle/{oradata,inventory,fast_recovery_area}
chown -R oracle:oinstall /data/u01/app/oracle
chmod -R 775 /data/u01/app/oracle
yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel numactl-devel sysstat unixODBC unixODBC-devel kernelheaders pdksh pcre-devel readline* rlwrap
yum -y update
cd /data/u01/software
ls

二、新会话:上传安装包
cd /data/u01/software
ls
上传Oracle安装包linux.x64_11gR2_database*

三、新会话修改配置文件、安装sqlplus
echo "#"$(date) "quick install oracle11GR2 add vim /etc/sysctl.conf">> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 1073741824" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
sysctl -p
echo "#"$(date) "quick install oracle11GR2 add vim /etc/security/limits.conf">>/etc/security/limits.conf
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
echo "oracle soft stack 10240" >>/etc/security/limits.conf
echo "#"$(date) "quick install oracle11GR2 add vim /etc/pam.d/login">>/etc/pam.d/login
echo "session required /lib64/security/pam_limits.so">>/etc/pam.d/login
echo "session required pam_limits.so">>/etc/pam.d/login

echo "#"$(date) "quick install oracle11GR2 add vim /etc/profile">>/etc/profile
echo 'if [ $USER = "oracle" ]; then'>>/etc/profile
echo 'if [ $SHELL = "/bin/ksh" ]; then'>>/etc/profile
echo "ulimit -p 16384">>/etc/profile
echo "ulimit -n 65536">>/etc/profile
echo "else">>/etc/profile
echo "ulimit -u 16384 -n 65536">>/etc/profile
echo "fi">>/etc/profile
echo "fi">>/etc/profile

cd /data/u01/software

前面已经安装,此步忽略

#tar -xvf rlwrap-0.42.tar.gz
#cd rlwrap-0.42
#./configure
#make
#make install

需要等上传完成;
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

su - oracle
echo "#"$(date) "quick install oracle11GR2 add vim .bash_profile">>.bash_profile
echo "export ORACLE_BASE=/data/u01/app/oracle">>.bash_profile
echo "export ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1">>.bash_profile
echo "export ORACLE_SID=orcl">>.bash_profile
echo 'export ORACLE_UNQNAME=$ORACLE_SID'>>.bash_profile
echo 'export PATH=$ORACLE_HOME/bin:$PATH'>>.bash_profile
echo "export NLS_LANG=american_america.AL32UTF8">>.bash_profile
echo "alias sqlplus='rlwrap sqlplus'">>.bash_profile
echo "alias rman='rlwrap rman'">>.bash_profile
source .bash_profile
ls

以下第四,五步可以使用本地已经配置好的response.tar.gz包上传到 /home/oracle/ 目录
然后执行:
cd /data/u01/software/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
等待执行成功
继续执行安装实例:
dbca -silent -responseFile /home/oracle/response/dbca.rsp
等待执行成功

四、修改静默响应文件并执行安装
拷贝备份一份响应文件:
cp -R /data/u01/software/database/response/ .
cd response/
vim db_install.rsp

修改内容:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/data/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

切换到解压的安装包目录执行安装:
cd /data/u01/software/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
sqlplus / as sysdba

linux CentOS7下快速静默安装Oracle11GR2数据库并创建实例

五、切换一个会话开始配置实例响应文件
配置响应文件:
vim /home/oracle/response/dbca.rsp
修改内容(注意修改选项前面的#要删除):
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "输入密码"
SYSTEMPASSWORD = "输入密码"
SYSMANPASSWORD = "输入密码"
DBSNMPPASSWORD = "输入密码"
DATAFILEDESTINATION =/data/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/data/u01/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "2048"

egrep -v "(^#|^$)" /home/oracle/response/dbca.rsp

安装创建(等第六步成功后执行):
cd ~
dbca -silent -responseFile /home/oracle/response/dbca.rsp
linux CentOS7下快速静默安装Oracle11GR2数据库并创建实例

六、数据库操作

1、检查oracle数据库是否启动:ps -ef | grep ora
2、检查Oracle DB监听器是否正常:
         输入:lsnrctl status 检查监听是否启动,如未启动
 输入:lsnrctl start 启动监听器;
lsnrctl stop 停止监听器命令
       netstat -ntlp 查看1521端口是否启动

3、进入sqlplus界面:
sqlplus /nolog;
conn / as sysdba;
然后startup启动数据库实例和数据库
shutdown关闭数据库实例

# oracle 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×