目录
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,asmdba,backupdba,dgdba,kmdba,racdba oracle
id oracle
a=1
echo oracle:$a|chpasswd
hostnamectl set-hostname oracle19c
su -
1.4、创建软件安装目录和数据库目录
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chmod -R 775 /u01
1.5、准备其它条件
cat >> /etc/hosts <<EOF
192.168.33.100 oracle19c
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/19.0.0.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、解压数据库文件
[root@oracle19c db]# pwd
/u01/app/oracle/product/19.0.0.0/db
[root@oracle19c db]# unzip db.zip
[root@oracle19c 19.0.0.0]# chown -R oracle:oinstall db/
2、安装数据库
2.1、准备db_install.rsp文件
mkdir -p /oracle/install/
chown -R oracle:oinstall /oracle/install/
su - oracle
cat >>/tmp/db_install.rsp <<EOF
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.0.0.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
oracle.install.db.rootconfig.executeRootScript=true
oracle.install.db.rootconfig.configMethod=ROOT
EOF
./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp
2.2、安装数据库
[oracle@oracle19c db]$ ./runInstaller -silent -ignorePrereq -responseFile /tmp/db_install.rsp
Launching Oracle Database Setup Wizard...
[WARNING] [INS-32047] The location (/u01/app/oraInventory) specified for the central inventory is not empty.
ACTION: It is recommended to provide an empty location for the inventory.
Enter password for 'root' user:
[WARNING] [INS-13013] Target environment does not meet some mandatory requirements.
CAUSE: Some of the mandatory prerequisites are not met. See logs for details. /tmp/InstallActions2020-03-31_10-45-58PM/installActions2020-03-31_10-45-58PM.log
ACTION: Identify the list of failed prerequisite checks from the log: /tmp/InstallActions2020-03-31_10-45-58PM/installActions2020-03-31_10-45-58PM.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/19.0.0.0/db/install/response/db_2020-03-31_10-45-58PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2020-03-31_10-45-58PM/installActions2020-03-31_10-45-58PM.log
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2020-03-31_10-45-58PM
3、建库
3.1、准备dbca.rsp文件
touch /tmp/dbca.rsp
cat >>/tmp/dbca.rsp<<EOF
responseFileVersion=/home/oracle/rspfmt_dbca_response_schema_v19.0.0
gdbName=orcl
sid=orcl
sysPassword=orcl
oracleHomeUserPassword=orcl
emExpressPort=5500
totalMemory=1500
sysPassword = Oracle123
systemPassword = Oracle123
datafileDestination =/u01/app/oracle/oradata
characterSet = ZHS16GBK
nationalCharacterSet= AL16UTF16
databaseType = OLTP
automaticMemoryManagement = TRUE
EOF
3.2、进行dbca建库
dbca -J-Doracle.assistants.dbca.validate.ConfigurationParams=false -silent -createDatabase -templateName General_Purpose.dbc -responseFile /tmp/dbca.rsp
[oracle@oracle19c oradata]$ dbca -J-Doracle.assistants.dbca.validate.ConfigurationParams=false -silent -createDatabase -templateName General_Purpose.dbc -responseFile /tmp/dbca.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/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl0.log" for further details
4、静默进行创建监听
自定义配置监听
Oracle用户执行
cat >>/tmp/netca.rsp <<EOF
[GENERAL]
RESPONSEFILE_VERSION="19.0"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
EOF
netca -silent -responsefile /tmp/netca.rsp
[oracle@oracle19c admin]$ netca -silent -responsefile /tmp/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /tmp/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/19.0.0.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
默认配置监听
netca -silent -responsefile /u01/app/oracle/product/19.0.0.0/db/assistants/netca/netca.rsp
[oracle@oracle19c netca]$ netca -silent -responsefile /u01/app/oracle/product/19.0.0.0/db/assistants/netca/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /u01/app/oracle/product/19.0.0.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/19.0.0.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
[oracle@oracle19c netca]$ lsnrctl
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 08-APR-2020 07:46:28
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> stat
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle19c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 08-APR-2020 07:46:26
Uptime 0 days 0 hr. 0 min. 3 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.0.0.0/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle19c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle19c)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
LSNRCTL> exit