CentOS7-2009 安装 Oracle Database 19C-19.3.0.0 步骤

数据库安装包下载参考:https://www.cnblogs.com/dawnlz/p/15777139.html

## 使用root用户开始操作:
## 1、安装依赖包,centos 为最小化安装版本,加下依赖
yum install -y 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 zip vim

## 2、添加用户组 和 用户

groupadd oper;
groupadd dba;
groupadd asmdba;
groupadd backupdba;
groupadd dgdba;
groupadd kmdba;
groupadd racdba;
groupadd oinstall;
useradd -g oinstall -G oper,dba,asmdba,backupdba,dgdba,kmdba,racdba oracle;

# 设置oracle 用户密码为 oracle
passwd oracle # password : oracle

## 3、禁用 selinux; 关闭防火墙,禁止开机自启动
vi /etc/selinux/config #改为 disabled

systemctl disable firewalld;
systemctl stop firewalld

## 4、 创建 oracle home 并设置属主为oracle 用户

mkdir -p /orasrc/app/oracle/product/19c/dbhome_1;
mkdir -p /orasrc/app/oraInventory

# 把安装文件解压到 dbhome_1下,V982063-01.zip 为数据库19.3 安装包

unzip -d /orasrc/app/oracle/product/19c/dbhome_1/ V982063-01.zip;
chown -R oracle:oinstall /orasrc/

## 5、系统内核参数修改

vi /etc/sysctl.conf

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max= 6815744
fs.aio-max-nr = 1048576

# 刷新系统内核参数
sysctl --system

# 修改用户系统资源限制
vi /etc/security/limits.conf

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240


## 6、以上用户为 root 用户,从root用户切到oracle用户,继续后续安装操作
su - oracle

## 7、修改oracle 用户环境变量

vi ~/.bash_profile

umask 022
export ORACLE_SID=orcl
export ORACLE_BASE=/orasrc/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export EDITOR=vi
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin


# 执行静默安装配置命令

/orasrc/app/oracle/product/19c/dbhome_1/runInstaller -silent -force -noconfig -ignorePrereq \
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0 \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/orasrc/app/oraInventory \
ORACLE_BASE=/orasrc/app/oracle \
ORACLE_HOME=/orasrc/app/oracle/product/19c/dbhome_1 \
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

# 执行静默创建数据库,这一步比较耗时

dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname orcl -sid orcl \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName orclpdb \
-pdbAdminPassword oracle \
-sysPassword oracle -systemPassword oracle \
-datafileDestination '/orasrc/app/oracle/oradata' \
-recoveryAreaDestination '/orasrc/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-totalMemory 4096 \
-databaseType OLTP \
-emConfiguration NONE


## 8、安装完成后,启动监听服务,启动数据库实例服务,进行测试连接
# 监听服务命令:  lsnrctl start\status\stop
lsnrctl  start

# 监听服务命令启动后 启动sqlplus

$ sqlplus /nolog

# 进入sqlplus,切到dba用户下

SQL> conn /as sysdba

# 启动数据库实例服务,关闭数据库实例服务命令 shutdown
startup

# 启动服务后,客户端连接测试,system/oracle(用户/密码),127.0.0.1(改成实际ip或主机)/orcl

## 后续进行业务系统用户、表空间等创建

##############################################################################

服务临时启停脚本参考:

## startDBServer.sh

#!/bin/bash

logname="dbStart-`date +'%Y%m%d-%H%M%S'`.log"

lsnrctl start >> $logname

echo "----------- `date +'%Y%m%d-%H%M%S'` start db instance" >> $logname

sqlplus -S /nolog >> $logname <<EOF
conn /as sysdba
startup
EOF

## stopDBServer.sh

#!/bin/bash

logname="dbStop-`date +'%Y%m%d-%H%M%S'`.log"

lsnrctl stop >> $logname

echo "----------- `date +'%Y%m%d-%H%M%S'` stop db instance" >> $logname

sqlplus -S /nolog >> $logname <<EOF
conn /as sysdba
shutdown
EOF

 

posted @ 2022-01-08 13:02  往事隨風~  阅读(405)  评论(0编辑  收藏  举报