注意事项:
在安装的时候多次涉及root用户和oracle用户的切换,请注意区分,本文已明显
一、环境准备
1、关闭防火墙
[root@localhost ~]# systemctl stop firewalld
2、 禁用NetworkManager服务(非必须)
[root@localhost ~]# systemctl stop NetworkManager
[root@localhost ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
3、禁用SELINUX
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
[root@localhost ~]# sed -i "/^SELINUX=/s#enforcing#disabled#" /etc/selinux/config
4、配置HOSTS解析
[root@localhost ~]# cat >> /etc/hosts <<EOF
> 192.168.8.220 host_db
> EOF
5、修改主机名称
[root@localhost ~]# hostnamectl set-hostname host_db
6、创建组和用户
创建dba和onstall两个用户组
[root@host-db ~]# groupadd dba
[root@host-db ~]# groupadd oper
[root@host-db~]# groupadd oinstall
创建oracle用户
[root@host-db ~]# useradd -g oinstall -G dba,oper oracle
配置oracle用户密码
[root@host-db ~]# echo "oracle"|passwd --stdin oracle
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
7、创建安装目录并赋权
创建目录
[root@host-db /]# mkdir -p /opt/oracle/app/oraInventory
[root@host-db /]# mkdir -p /opt/oracle/app/oracle/product/19.3.0/dbhome_1
赋权
[root@host-db /]# chown -R oracle:oinstall /opt/oracle
[root@host-db /]# chmod -R 775 /opt/oracle
8、配置用户环境变量(在oracle用户下)
[oracle@host-db ~]$su - oracle
[oracle@host-db ~]$ vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME= host_db
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/opt/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORACLE_SID=orcl
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
source ~/.bash_profile
echo $ORACLE_HOME
9、配置系统环境变量
#在 /etc/profile.d目录下创建存放oracle的环境,名字可以随意,但是必须以sh结尾
[root@host-db /]# vi /etc/profile.d/env_oracle.sh
if [ \$USER = "oracle" ]; then if [ \$SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fi
fi
10、修改系统内核参数
[root@host-db /]# vi /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.sem = 513065280510256
kernel.shmmni = 4096
kernel.shmmax = 549755813888
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
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
net.ipv4.ip_local_port_range = 900065500
11、配置LIMITS限制参数
[root@host-db sys]# vi /etc/security/limits.conf
oracle soft nproc 16384oracle hard nproc 16384oracle soft nofile 65536oracle hard nofile 65536oracle soft memlock 3145728oracle hard memlock 3145728
二、安装Oracle 19C 软件
基本都在oracle用户下操作,个别需要在root用户下执行,已明确标出,请注意查看
0、离线安装所需依赖(在root用户下)
[root@host-db opt]# unzip base.zip
[root@host-db opt]# cd base
[root@host-db base]# rpm -Uvh *.rpm --nodeps --force
0.0、检查依赖是否都存在
[root@host_db 19cc]# rpm -ivh oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
如果检查完发现还缺少依赖,可以自行下载,一般情况下所给的依赖已经很全了。
rpm依赖下载地址:rpm依赖
2.1、解压数据库软件(roacle用户下)
# root用户下
[root@host-db ~]$ mv /opt/LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
# 切换oracle用户下
[root@host-db home]# su - oracle
[oracle@host-db ~]$ unzip -q LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
2.2、开始安装数据库软件(需要在oracle用户下)
2.2.1、编写相应文件db_install.rsp
[oracle@host-db response]$ vi $ORACLE_HOME/install/response/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=/opt/oracle/app/oracle/oraInventory
ORACLE_BASE=/opt/oracle/app/oracle
ORACLE_HOME=/opt/oracle/app/oracle/product/19.3.0/dbhome_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=false
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.ConfigureAsContainerDB=false
oracle.install.db.config.starterdb.characterSet= ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.password.ALL=oracle
2.2.2/运行安装命令
[oracle@host-db ~]$ cd $ORACLE_HOME
[oracle@host-db ~]$ ./runInstaller -silent -skipPrereqs -responseFile ./install/response/db_install.rsp
根据提示,使用root账号执行以上两个脚本
[root@host_db 19cc]# /opt/oracle/app/oracle/oraInventory/orainstRoot.sh
[root@host_db 19cc]# /opt/oracle/app/oracle/product/19.3.0/dbhome_1/root.sh
2.3、创建监听
[oracle@host-db db_1]$ netca -silent -responseFile /opt/oracle/app/oracle/product/19.3.0/dbhome_1/assistants/netca/netca.rsp
2.3.1、查看监听状态
lsnrctl status
2.4、创建数据库
2.4.1、编写相应文件
[oracle@host-db db_1]$ vim /opt/oracle/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp
gdbName=orcl
sid=orcl
databaseConfigType=SI
createAsContainerDatabase=false
templateName=General_Purpose.dbc
sysPassword=oracle
systemPassword=oracle
2.4.2、运行安装命
[oracle@host-db db_1]$dbca -silent -createDatabase -responseFile /opt/oracle/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp
2.4.3、测试是否可用
[oracle@host_db admin]$sqlplus / nolog
SQL>conn sys/oracle as sysdba