[关闭]
@clisdodo 2019-10-24T14:49:21.000000Z 字数 5333 阅读 2599

Oracle 19c 单实例文件系统搭建(华为云)

HUAWEIYUN CentOS7.6 Oracle19c Silent


AskScuti :搭建类 1-0-6 Oracle 19c 单实例文件系统静默安装


主机名及IP

编辑 /etc/hosts 文件,IP在下面命令中被隐藏。

echo "x.x.x.x ecs-s6-medium-2-linux-20191021888888" >> /etc/hosts

语言环境

echo "export LANG=en_US" >> ~/.bash_profile

交换分区

华为云实验环境内存为2G,swap分区为2G * 2 = 4G,物理内存对应swap大小规则参考值:

  1. 物理<8G swap=物理*2
  2. 8<=物理<=16 swap=物理;
  3. 物理>16G swap=物理/2
dd if=/dev/zero of=/home/swap bs=1M count=4096
mkswap /home/swap
swapon /home/swap
free -h

开机自启

获取交换分区UUID

blkid /home/swap

编辑 /etc/fstab 文件
vim /etc/fstab ,加入以下行内容

UUID=b8eb3f00-4ce3-4006-85fd-76a6971ce3bb swap  swap  defaults  0 0

用户和组

/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
passwd oracle

文件夹及权限

mkdir /u01
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

RPM包

yum -y install autoconf
yum -y install automake
yum -y install binutils
yum -y install binutils-devel
yum -y install bison
yum -y install cpp
yum -y install dos2unix
yum -y install ftp
yum -y install gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-libcap1
yum -y install compat-libstdc++-33
yum -y install compat-libstdc++-33.i686
yum -y install glibc-*
yum -y install glibc-*.i686
yum -y install libXpm-*.i686
yum -y install libXext
yum -y install libXext.i686
yum -y install libXtst
yum -y install libXtst.i686
yum -y install libX11
yum -y install libX11.i686
yum -y install libXau
yum -y install libXau.i686
yum -y install libxcb
yum -y install libxcb.i686
yum -y install libXi
yum -y install libXi.i686
yum -y install libstdc++.i686
yum -y install libstdc++-devel
yum -y install libstdc++-devel.i686
yum -y install libaio
yum -y install libaio.i686
yum -y install libaio-devel
yum -y install libaio-devel.i686
yum -y install ksh
yum -y install libXp
yum -y install libaio-devel
yum -y install numactl
yum -y install numactl-devel
yum -y install make -y
yum -y install sysstat -y
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
yum -y install unzip
yum install -y libXrender
yum install -y libXrender-devel
yum install -y nfs-utils
yum install -y smartmontools

资源限制

编辑 /etc/security/limits.conf 文件,内存大于8G需配置大内存页。
屏蔽内容

#* soft nofile 65535
#* hard nofile 65535

添加内容

oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 16384
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
#oracle hard memlock 8192000 (Memory larger than 8GB)
#oracle soft memlock 8192000 (Memory larger than 8GB)

SHELL限制

echo "session required pam_limits.so" >> /etc/pam.d/login

内核参数

编辑 /etc/sysctl.conf 文件
和内存大小相关的两个参数需要根据实际情况修改,修改建议请参考阿里云12cR2内核参数章节。

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 1932735283
kernel.shmall = 471859
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 = 1048586
kernel.panic_on_oops = 1

使之生效

sysctl -p

关闭防火墙

systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service

环境变量

切换 oracle 用户

su - oracle

编辑 .bash_profile

vim .bash_profile

末尾添加以下行,注意换行问题

  1. PS1="[`whoami`@`hostname`:"'$PWD]$'
  2. export PS1
  3. export TMP=/tmp
  4. export LANG=en_US
  5. export TMPDIR=$TMP
  6. export ORACLE_UNQNAME=cdb19c
  7. ORACLE_SID=cdb19c; export ORACLE_SID
  8. ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
  9. ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1; export ORACLE_HOME
  10. ORACLE_TERM=xterm; export ORACLE_TERM
  11. NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
  12. NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
  13. PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin; export PATH
  14. THREADS_FLAG=native; export THREADS_FLAG
  15. umask=022
  16. if [ $USER = "oracle" ]; then
  17. if [ $SHELL = "/bin/ksh" ]; then
  18. ulimit -p 16384
  19. ulimit -n 65536
  20. else
  21. ulimit -u 16384 -n 65536
  22. fi
  23. umask 022
  24. fi

解压软件

压缩包上传至 /soft 目录,用 oracle 用户进行解压,注意权限。

注意:从 oracle 18c 开始,必须把压缩文件解压到 $ORACLE_HOME 里面,点我查看官方文档

chown -R oracle:oinstall /soft
chmod -R 775 /soft
su - oracle
cd $ORACLE_HOME
unzip -q /soft/19c-V982063-01.zip 

软件安装

静默安装参数定义请参考文件 $ORACLE_HOME/install/response/db_install.rsp

./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

执行脚本

切换到 root 用户,依次执行下列两个脚本

As a root user, execute the following script(s):
    1. /u01/app/oraInventory/orainstRoot.sh
    2. /u01/app/oracle/product/19.3.0/dbhome_1/root.sh

启动监听

lsnrctl status
lsnrctl start

创建数据库

静默建库参数定义请参考文件 $ORACLE_HOME/assistants/dbca/dbca.rsp官方文档

dbca -silent -createDatabase -templateName General_Purpose.dbc \
-gdbname cdb19c \
-sid cdb19c \
-databaseConfigType SI \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName sales \
-useLocalUndoForPDBs TRUE \
-pdbAdminPassword oracle \
-sysPassword oracle \
-systemPassword oracle \
-characterSet AL32UTF8 \
-memoryPercentage 30

连接测试

sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 23 13:02:21 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> show pdbs
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注