目录
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 oracle18c
cat >> /etc/hosts <<EOF
17.21.68.132 oracle18c
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/pam.d/login <<EOF
session required /lib/security/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
umask 022
fi
EOF
cat >> /etc/csh.login <<EOF
if ( \$USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
cat >>/home/oracle/.bash_profile<<EOF
unset USERNAME
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/18.0/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
exit
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 LINUX.X64_180000_db_home.zip
/u01/app/oracle/product/18.0/db
2、安装数据库
2.1、安装数据库软件
cat >/tmp/db_install.rsp <<EOF
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v18.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/18.0/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@oracle18c db]$ ./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp
Launching Oracle Database Setup Wizard...
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2020-04-04_03-47-48AM.log
ACTION: Identify the list of failed prerequisite checks from the log: installActions2020-04-04_03-47-48AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
/u01/app/oracle/product/18.0/db/install/response/db_2020-04-04_03-47-48AM.rsp
You can find the log of this install session at:
/tmp/InstallActions2020-04-04_03-47-48AM/installActions2020-04-04_03-47-48AM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/18.0/db/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[oracle18c]
Execute /u01/app/oracle/product/18.0/db/root.sh on the following nodes:
[oracle18c]
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2020-04-04_03-47-48AM
[root@oracle18c ~]# 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@oracle18c ~]# sh /u01/app/oracle/product/18.0/db/root.sh
Check /u01/app/oracle/product/18.0/db/install/root_oracle18c_2020-04-04_03-49-19-555893641.log for the output of root script
3、静默进行创建监听
netca -silent -responsefile /u01/app/oracle/product/18.0/db/assistants/netca/netca.rsp
[oracle@oracle18c db]$ netca -silent -responsefile /u01/app/oracle/product/18.0/db/assistants/netca/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /u01/app/oracle/product/18.0/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/18.0/db/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
4、建立pdb类型数据库
4.1、准备pdb响应文件
mkdir /oradata
chown oracle:oinstall /oradata
touch /oracle/dbca_install.rsp
cat >/oracle/dbca_install.rsp<<EOF
responseFileVersion=/oracle/install/rspfmt_dbca_response_schema_v18.0
gdbName=orcl
sid=orcl
databaseConfigType=SI
createAsContainerDatabase=true
numberOfPDBs=1
pdbName=orclpdb
templateName=/u01/app/oracle/product/18.0/db/assistants/dbca/templates/General_Purpose.dbc
emExpressPort=5500
omsPort=0
characterSet=AL32UTF8
listeners=LISTENER
memoryPercentage=40
automaticMemoryManagement=false
totalMemory=0
datafileDestination =/oradata
EOF
cat /oracle/dbca_install.rsp
4.2、dbca建库
dbca -silent -createDatabase -responseFile /oracle/dbca_install.rsp
[oracle@oracle18c templates]$ dbca -silent -createDatabase -responseFile /oracle/dbca_install.rsp
Enter SYS user password:
Enter SYSTEM user password:
Enter PDBADMIN User Password:
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[oracle@oracle18c templates]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat Apr 4 04:05:11 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
5、普通建库
5.1、准备响应文件
cat >/oracle/dbca_nopdb.rsp<<EOF
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
gdbName=oab
sid=oab
templateName=/u01/app/oracle/product/18.0/db/assistants/dbca/templates/General_Purpose.dbc
sysPassword=Oracle123
oracleHomeUserPassword=Oracle123
emExpressPort=5500
totalMemory=1500
sysPassword = Oracle123
systemPassword = Oracle123
datafileDestination =/oradata
characterSet =ZHS16GBK
nationalCharacterSet=AL16UTF16
databaseType = OLTP
automaticMemoryManagement = TRUE
EOF
5.2、dbca建立普通库
dbca -silent -createDatabase -responseFile /oracle/dbca_nopdb.rsp
[oracle@oracle18c templates]$ dbca -silent -createDatabase -responseFile /oracle/dbca_nopdb.rsp
Enter SYS user password:
Enter SYSTEM user password:
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
60% complete
Completing Database Creation
66% complete
69% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/oab.
Database Information:
Global Database Name:oab
System Identifier(SID):oab
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/oab/oab.log" for further details.
[oracle@oracle18c templates]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat Apr 4 04:13:51 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs
SQL>