oracle19c数据库静默安装
1 安装基础部分操作
(1)规划
主机名:linux-centos7-01
(2)机器资源
内存:2GB
磁盘:20GB
CPU: 1c
操作系统:CentOS-7.7.1908
内核:3.10.0-1062.el7.x86_64
数据库版本:LINUX.X64_193000_db_home.zip (Version 19.3.0.0.0)
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
(3)时间同步
*/5 * * * * /sbin/ntpdate ntp.gwadar.cn >> /dev/null 2>&1
2 基础设置
(1)设置/etc/hosts
echo "192.168.207.11 linux-centos7-01" >> /etc/hosts
(2)创建用户和组
/usr/sbin/groupadd -g 65431 oinstall
/usr/sbin/groupadd -g 65432 dba
/usr/sbin/groupadd -g 65433 oper
useradd -u 61001 -g oinstall -G dba,oper -m oracle
echo "oracledasefasdfvadvad" | passwd --stdin oracle
(3)创建文件夹及权限
mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01
chmod -R 775 /u01
(4)安装rpm包
yum -y install bc gcc gcc-c++ binutils compat-libcap1 compat-libstdc++ dtrace-modules dtrace-modules-headers dtrace-modules-provider-headers dtrace-utils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libdtrace-ctf-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc librdmacm-devel libstdc++ libstdc++-devel libxcb make smartmontools sysstat unzip
(5)修改用户安全限制
#vim /etc/security/limits.conf
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 16384
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
(6)shell限制
echo "session required pam_limits.so" >> /etc/pam.d/login
(7)修改内核参数
cp /etc/sysctl.conf{,.2021020801}
cat >> /etc/sysctl.conf << EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 33554432
kernel.shmmax = 137438953471
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
kernel.panic_on_oops = 1
EOF
参数设置计算:
kernel.shmmax = 当前内存GB * 1024 * 1024 * 1024 * 0.9
注:当前内存推荐至少4GB
kernel.shmall = kernel.shmmax / kernel.shmmni
详细解释:
shmall 是全部允许使用的共享内存大小
shmmax 是单个段允许使用的大小
这两个可以设置为内存的 90%
例如 16G 内存,16*1024*1024*1024*90% = 15461882265
shmall 的大小为 15461882265/4k(getconf PAGESIZE可得到) = 3774873
#修改后执行
sysctl -p
(8)禁用防火墙和 selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config
(9)设置用户环境变量
#切换到oracle用户
su - oracle
#vim .bash_profile
#PS1="[`whoami`@`hostname`:"'$PWD]$'
#export PS1
export TMP=/tmp
export LANG=en_US.UTF-8
export TMPDIR=$TMP
export ORACLE_UNQNAME=cdb19c
export ORACLE_SID=cdb19c
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORACLE_TERM=xterm
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin
export THREADS_FLAG=native
umask=022
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
注:此处之后最好直接使用oracle用户登录linux系统,顺便在开启一个root终端,以便后续的操作
(10)解压
注:从oracle 18c开始,必须把压缩文件解压到 $ORACLE_HOME 里面
#root操作
mkdir /soft
mv LINUX.X64_193000_db_home.zip /soft
chown -R oracle:oinstall /soft
chmod -R 775 /soft
su - oracle
cd $ORACLE_HOME
unzip -q /soft/LINUX.X64_193000_db_home.zip
3 oracle安装
(1)安装oracle软件(su - oracle)
响应文件: /u01/app/oracle/product/19.3.0/dbhome_1/install/response/db_install.rsp
#正式安装(此处的目录可以修改)
/u01/app/oracle/product/19.3.0/dbhome_1/runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile /u01/app/oracle/product/19.3.0/dbhome_1/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1 \
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=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
#输出如下信息表示此步骤正确
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2021-02-08_09-22-48PM
#切换到root用户,依次执行以下2个脚本
[root@linux-centos7-01 ~]# /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@linux-centos7-01 ~]# /u01/app/oracle/product/19.3.0/dbhome_1/root.sh
Check /u01/app/oracle/product/19.3.0/dbhome_1/install/root_linux-centos7-01_2021-02-08_21-27-57-386058318.log for the output of root script
[root@linux-centos7-01 ~]#
#检查
cat /u01/app/oracle/product/19.3.0/dbhome_1/install/root_linux-centos7-01_2021-02-08_21-27-57-386058318.log
Finished running generic part of root script.
Now product-specific root actions will be performed.
Oracle Trace File Analyzer (TFA) is available at : /u01/app/oracle/product/19.3.0/dbhome_1/bin/tfactl
(2)创建监听
注:可以不单独创建监听; 如果创建,则多了一个listener.ora文件,生产一般都是创建的
su - oracle
#启动监听 1521
[oracle@linux-centos7-01:/u01/app/oracle/product/19.3.0/dbhome_1]$lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 08-FEB-2021 21:30:02
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/linux-centos7-01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux-centos7-01)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 08-FEB-2021 21:30:02
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/linux-centos7-01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=linux-centos7-01)(PORT=1521)))
The listener supports no services
The command completed successfully
#检查
# ss -anp | grep ":1521"
tcp LISTEN 0 128 [::]:1521 [::]:* users:(("tnslsnr",pid=41628,fd=8))
(3)创建数据库(su - oracle)
响应文件: $ORACLE_HOME/assistants/dbca/dbca.rsp
dbca -silent -createDatabase -templateName General_Purpose.dbc \
-gdbname cdb19c \
-sid cdb19c \
-databaseConfigType SI \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName oca \
-useLocalUndoForPDBs TRUE \
-pdbAdminPassword oracle1 \
-sysPassword oracle2 \
-systemPassword oracle3 \
-characterSet AL32UTF8 \
-memoryPercentage 30
(4)登录数据库(su - oracle)
#以操作系统身份登录
sqlplus / as sysdba
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY YES
3 OCA READ WRITE YES