Oracle 12c for Centos7.x 全命令行静默安装

目录

 

1、环境

1.1、配置本地YUM源

1.2、安装依赖包

1.3、创建用户组 

1.4、创建软件安装目录和数据库目录

1.5、准备其它条件 

1.7、关闭防火墙与selinux

1.8、解压数据库文件 

2、安装数据库 

2.1、安装数据库软件

3、静默进行创建监听

 

4、建立pdb类型数据库

4.1、准备pdb响应文件

4.1.2、dbca建库

5、普通建库

5.1、准备响应文件

5.2、dbca建立普通库


 

 

1、环境

1.1、配置本地YUM源

mount -t auto /dev/cdrom  /mnt

rm -rf /etc/yum.repos.d/
mkdir -p /etc/yum.repos.d/



cat >> /etc/yum.repos.d/CentOS-Media.repo<<EOF
# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF


yum clean all
yum makecache

1.2、安装依赖包

 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 libXext* unzip

1.3、创建用户组 

groupadd -g 1001 oinstall
groupadd -g 1002 dba
groupadd -g 1003 oper
groupadd -g 1004 asmdba
groupadd -g 1005 backupdba
groupadd -g 1006 dgdba
groupadd -g 1007 kmdba
groupadd -g 1008 racdba

useradd -u 1001 -m -g oinstall -G dba,oper,asmdba,backupdba,dgdba,kmdba,racdba oracle
id oracle
a=1
echo oracle:$a|chpasswd

1.4、创建软件安装目录和数据库目录

mkdir -p /u01/app/oracle
chown -R oracle:oinstall  /u01
chmod -R 775 /u01
mkdir -p /oracle/oinstall
chown -R oracle:oinstall  /oracle

1.5、准备其它条件 

hostnamectl set-hostname oracle12c
cat >> /etc/hosts <<EOF
17.21.68.132  oracle12c
EOF
cat >> /etc/sysctl.conf <<EOF
fs.file-max = 6815744  
kernel.sem = 250 32000 100 128  
kernel.shmmni = 4096  
kernel.shmall = 1073741824  
kernel.shmmax = 6597069766656
kernel.panic_on_oops = 1  
net.core.rmem_default = 262144  
net.core.rmem_max = 4194304  
net.core.wmem_default = 262144  
net.core.wmem_max = 1048576  
#net.ipv4.conf.eth3.rp_filter = 2       
#net.ipv4.conf.eth2.rp_filter = 2
#net.ipv4.conf.eth0.rp_filter = 1  
fs.aio-max-nr = 1048576  
net.ipv4.ip_local_port_range = 9000 65500 
EOF

cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
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
 umask 022
fi
EOF

cat >> /etc/csh.login <<EOF
if ( \$USER == "oracle" ) then
 limit maxproc 16384
 limit descriptors 65536
 umask 022
endif
EOF















cat >> /etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
EOF

cat >>/home/oracle/.bash_profile<<EOF
unset USERNAME
export ORACLE_BASE=/u01/app/oracle 
export ORACLE_HOME=\$ORACLE_BASE/product/12.2/db
export ORACLE_SID=orcl
export PATH=\$PATH:\$HOME/bin:\$ORACLE_HOME/bin:\$ORA_CRS_HOME/bin:\$ORACLE_BASE/common/oracle/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
export ORACLE_PATH=\$ORACLE_BASE/common/oracle/sql:\$ORACLE_HOME/rdbms/admin
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export ORA_NLS10=\$ORACLE_HOME/nls/data
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib
export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=\$ORACLE_HOME/JRE
export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
export CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
umask=022
EOF
su - oracle
mkdir -p $ORACLE_HOME

1.7、关闭防火墙与selinux

systemctl status firewalld

systemctl stop firewalld

systemctl disable firewalld

sed -i 's/=enforcing/=disabled/g' /etc/selinux/config

setenforce 0

 getenforce

1.8、解压数据库文件 

cd /oracle/

unzip linuxx64_12201_database.zip 

chown -R oracle:oinstall database/

2、安装数据库 

2.1、安装数据库软件

cat >/tmp/db_install.rsp <<EOF
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/12.2/db
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=backupdba
oracle.install.db.OSDGDBA_GROUP=dgdba
oracle.install.db.OSKMDBA_GROUP=kmdba
oracle.install.db.OSRACDBA_GROUP=racdba
EOF


./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp

oracle@oracle12c database]$ ./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 28971 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-04-04_12-33-52PM. Please wait ...[oracle@oracle12c database]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2020-04-04_12-33-52PM.log

 The installation of Oracle Database 12c was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2020-04-04_12-33-52PM.log' for more details.

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/12.2/db/root.sh


[root@oracle12c ~]# sh /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@oracle12c ~]# sh /u01/app/oracle/product/12.2/db/root.sh
Check /u01/app/oracle/product/12.2/db/install/root_oracle12c_2020-04-04_12-38-08-362765168.log for the output of root script
[root@oracle12c ~]# 

3、静默进行创建监听

 

[oracle@oracle12c db]$ netca -silent -responsefile /u01/app/oracle/product/12.2/db/assistants/netca/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /u01/app/oracle/product/12.2/db/assistants/netca/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/12.2/db/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@oracle12c db]$ 

 

4、建立pdb类型数据库

4.1、准备pdb响应文件

mkdir /oradata
chown oracle:oinstall

cat >/oracle/database/response/dbca_install.rsp<<EOF
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=orcl
sid=orcl
databaseConfigType=SI
createAsContainerDatabase=true
numberOfPDBs=1
pdbName=orclpdb
templateName=/u01/app/oracle/product/12.2/db/assistants/dbca/templates/General_Purpose.dbc
emExpressPort=5500
omsPort=0
characterSet=AL32UTF8
listeners=LISTENER
memoryPercentage=40
automaticMemoryManagement=false
totalMemory=0
datafileDestination =/data
EOF




cat /oracle/database/response/dbca_install.rsp

4.1.2、dbca建库

dbca -silent -createDatabase  -responseFile  /oracle/database/response/dbca_install.rsp
[oracle@oracle12c templates]$ dbca -silent -createDatabase  -responseFile  /oracle/database/response/dbca_install.rsp
Enter SYS user password: 

Enter SYSTEM user password: 

Enter PDBADMIN User Password: 

Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
49% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.


[oracle@oracle12c ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Apr 4 13:14:34 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO
SQL> 

5、普通建库

5.1、准备响应文件

cat >/oracle/database/response/dbca_nopdb.rsp<<EOF 
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=oab
sid=oab
templateName=/u01/app/oracle/product/12.2/db/assistants/dbca/templates/General_Purpose.dbc
oracleHomeUserPassword="Oracle123"
emExpressPort=5500
totalMemory=1500
sysPassword = "Oracle123"
systemPassword = "Oracle123"
datafileDestination ="/data"
characterSet =ZHS16GBK
nationalCharacterSet=AL16UTF16
databaseType = OLTP
automaticMemoryManagement = TRUE
EOF



dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname oab -sid oab -responseFile NO_VALUE -characterSet ZHS16GBK  -datafileDestination /data  -totalMemory 1500

5.2、dbca建立普通库

dbca -silent -createDatabase  -responseFile  /oracle/database/response/dbca_nopdb.rsp

[oracle@oracle12c response]$ dbca -silent -createDatabase  -responseFile  /oracle/database/response/dbca_nopdb.rsp
Enter SYS user password: 

Enter SYSTEM user password: 

Copying database files
1% complete
2% complete
18% complete
33% complete
Creating and starting Oracle instance
35% complete
40% complete
44% complete
49% complete
50% complete
53% complete
55% complete
Completing Database Creation
56% complete
57% complete
58% complete
62% complete
65% complete
66% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/oab/oab.log" for further details.


[oracle@oracle12c response]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Apr 4 13:12:57 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs
SQL> 

 增加控制启动项

cat >/lib/systemd/system/oracle.service<<EOF
[Unit]  
Description=Oracle Database 12c Startup/Shutdown Service  
After=syslog.target network.target  
[Service]  
LimitMEMLOCK=infinity  
LimitNOFILE=65535  
Type=oneshot  
RemainAfterExit=yes  
User=root
ExecStart=/root/scripts/dbstart.sh >2>&1 &  
ExecStop=/root/scripts/dbstop.sh  2>&1 &  
  
[Install]  
WantedBy=multi-user.target
EOF

cat /lib/systemd/system/oracle.service

mkdir -p /root/scripts/
cat >/root/scripts/dbstart.sh<<EOF
#!/bin/bash
su - oracle -c "dbstart"
EOF
cat /root/scripts/dbstart.sh

cat >/root/scripts/dbstop.sh<<EOF
#!/bin/bash
su - oracle -c "dbshut"
EOF
cat /root/scripts/dbstop.sh


sed -i 's/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g' /u01/app/oracle/product/12.2/db/bin/dbstart

sed -i 's/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g' /u01/app/oracle/product/12.2/db/bin/dbshut



sed -i 's/db:N/db:Y/g' /etc/oratab
cat /etc/oratab

chmod 777 /root/scripts/dbstart.sh
chmod 777 /root/scripts/dbstop.sh 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值