一、 环境介绍
操作系统 Centos release 7.4
数据库版本 Oracle database 19.3
主机名 dbserver
IP地址 183.236.94.19
安装目录 /oracle/app/oracle/19.3.0/db_1
数据库名称 orcl
字符集 AL32UTF8
二、 环境准备
2.1. 关闭防火墙
[root@dbserver ~]# systemctl stop firewalld
[root@dbserver ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
2.2. 禁用NetworkManager服务
[root@dbserver ~]# systemctl stop NetworkManager
[root@dbserver ~]# systemctl disable NetworkManager
2.3. 禁用SELINUX
[root@dbserver ~]# setenforce 0
setenforce: SELinux is disabled
[root@dbserver ~]# sed -i "/^SELINUX=/s#enforcing#disabled#" /etc/selinux/config
2.4. 配置HOSTS解析(这里写你自己的地址)
[root@dbserver ~]# cat >> /etc/hosts <<EOF
192.168.84.99 dbserver
EOF
2.5. 修改主机名
[root@dbserver ~]# hostnamectl set-hostname dbserver
2.6. 配置NOZEROCONFIG
[root@dbserver ~]# cat >> /etc/sysconfig/network <<EOF NOZEROCONF=yes EOF
2.7. 创建组和用户
# 创建dba和onstall两个用户组
[root@dbserver ~]# groupadd -g 501 dba
[root@dbserver ~]# groupadd -g 502 oinstall
[root@dbserver ~]# groupadd -g 503 oper
[root@dbserver ~]# groupadd -g 504 asmadmin
[root@dbserver ~]# groupadd -g 505 asmoper
[root@dbserver ~]# groupadd -g 506 asmdba
[root@dbserver ~]# useradd -g oinstall -G dba,oper oracle
[root@dbserver ~]# useradd -g oinstall -G asmadmin,asmdba,asmoper,dba grid
2.8. 创建安装目录并赋权
[root@dbserver ~]# mkdir -p /oracle/app/oracle
[root@dbserver ~]# chown oracle:oinstall /oracle/app/oracle
[root@dbserver ~]# chmod -R 775 /oracle/app/oracle
[root@dbserver ~]# mkdir -p /oracle/app/oracle/19.3.0/db_1
[root@dbserver ~]# chown oracle:oinstall /oracle/app/oracle/19.3.0/db_1
[root@dbserver ~]# chmod -R 775 /oracle/app/oracle/19.3.0/db_1
2.9. 配置用户环境变量
[oracle@dbserver ~]$ vi .bash_profile
##加上以下条目
umask 022
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_TERM=xterm
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=/oracle/app/oracle/19.3.0/db_1
export PATH=$PATH:$CRS_HOME/bin:$ORACLE_HOME/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export ORA_NLS10=$GRID_HOME/nls/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/oracm/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/network/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export THREADS_FLAG=native
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
2.11. 修改系统内核参数
[root@dbserver ~]# vi /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.sem = 5130 65280 510 256
kernel.shmmni = 4096
kernel.shmmax = 549755813888 #support max TotalMemory 512GB
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
fs.aio-max-nr = 1048576
vm.swappiness = 10
vm.dirty_background_ratio = 20
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.tcp_wmem = 262144
net.ipv4.tcp_rmem = 4194304
[root@dbserver ~]# /sbin/sysctl -p
kernel.shmall = 4294967296
kernel.sem = 5130 65280 510 256
kernel.shmmni = 4096
kernel.shmmax = 549755813888
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
fs.aio-max-nr = 1048576
vm.swappiness = 10
vm.dirty_background_ratio = 20
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.tcp_wmem = 262144
net.ipv4.tcp_rmem = 4194304
2.12. 配置LIMITS限制参数
[root@dbserver ~]# cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft memlock 3145728
oracle hard memlock 3145728
EOF
2.13. 配置PAM验证
[root@dbserver ~]# cat >> /etc/pam.d/login <<EOF session required /lib64/security/pam_limits.so EOF
2.14. 安装依赖包
2.13.1 挂载系统介质
2.13.2 配置yum包
2.13.3 安装依赖包
[root@dbserver ~]# yum install -y bc binutils compat-libcap1 compat-libstdc++ elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat unzip vim
三、 安装软件
3.1. 解压数据库软件
[root@dbserver ~]$ su - oracle
[oracle@dbserver ~]$ unzip -q LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
3.2. 开始安装数据库 软件
# 编写响应文件
[oracle@dbserver ~]$ cat 19c_db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/app/oracle/oraInventory
ORACLE_BASE=/oracle/app/oracle
ORACLE_HOME=/oracle/app/oracle/19.3.0/db_1
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
oracle.install.db.rootconfig.executeRootScript=true
oracle.install.db.rootconfig.configMethod=ROOT
运行安装命令
[oracle@dbserver ~]$ $ORACLE_HOME/runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/19c_db_install.rsp
备注:该过程非常快,整个运行不到1分钟,中途会提示输入root用户密码用于自动执行root.sh脚本
四、 创建监听
# 编写监听配置文件
[oracle@dbserver]$ cd $ORACLE_HOME/network/admin
[oracle@dbserver admin]$ vi listener.ora
# listener.ora Network Configuration File: /oracle/app/oracle/19.3.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbserver)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
[oracle@dbserver]$ lsnrctl start
五、 创建数据库
编写数据库创建相应文件
[oracle@dbserver ~]$ cd ~
[oracle@dbserver ~]$ vi 19c_dbca.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
templateName=General_Purpose.dbc
gdbName=orcl
sid=orcl
createAsContainerDatabase=FALSE
sysPassword=oracle
systemPassword=oracle
datafileDestination=/oracle/app/oracle/oradata
recoveryAreaDestination=/oracle/app/oracle/flash_recovery_area
storageType=FS
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
sampleSchema=true
totalMemory=2048
databaseType=OLTP
emConfiguration=NONE
静默创建数据库
[oracle@dbserver ~]$ dbca -silent -createDatabase -responseFile /home/oracle/19c_dbca.rsp
** 重启自启动**
[root@dbserver ~]# vi /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/oracle/app/oracle/19.3.0/db_1:Y ##修改为Y
[root@dbserver ~]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
## 增加以下两列
su oracle -lc "/oracle/app/oracle/19.3.0/db_1/bin/lsnrctl start"
su oracle -lc "/oracle/app/oracle/19.3.0/db_1/bin/dbstart"
[root@dbserver ~]# chmod +x /etc/rc.d/rc.local