陈老师:1415968548 郑老师:2735197625 乐老师:354331153
客服热线:
19941464235/19906632509(微信同号)

客服微信

【Oracle OCP】linux 8安装19c单机版

作者:炎燚小寶
发布时间:2023-12-19 09:15
浏览量:465

本文为云贝教育 刘峰 原创,请尊重知识产权,转发请注明出处,不接受任何抄袭、演绎和未经注明出处的转载。

一、安装基本信息


Ø 数据库安装版本 19c单机

Ø 操作系统版本 Linux 8+



二、操作系统配置

2.1、系统语言检查


如果是运行数据库,建议更改为英语使用UTF8,查看命令如下:

localectl status|grep LANG


设置语言

rhel7

localectl set-locale LANG=en_US.UTF8 && localectl status|grep LANG

其它的版本

LANG="en_US.UTF-8"

grep LANG  /etc/sysconfig/i18n

cp /etc/sysconfig/i18n /etc/sysconfig/i18n_`date +"%Y%m%d_%H%M%S"`&& sed -i "/LANG=/d" /etc/sysconfig/i18n && echo "LANG=\"en_US.UTF-8\"" >>/etc/sysconfig/i18n && grep LANG /etc/sysconfig/i18n



2.2 主机时间时区检查

查看时间的时区,如果不是中国内的,请修改
Ø RHEL7/8
查看时间时区
timedatectl
设置时区
timedatectl set-timezone "Asia/Shanghai"

timedatectl set-time HH:MM:SS
timedatectl set-time "2012-10-30 18:17:16"
--将系统时间同步给硬件时间
timedatectl set-local-rtc 1


2.3、修改主机名


hostnamectl set-hostname ora19c


2.4、关闭防火墙、SELINUX及操作系统Transparent Huge Pages

1)防火墙
systemctl stop    firewalld
systemctl disable firewalld

2)selinux
--查看
getenforce

SELINUX=`grep ^SELINUX= /etc/selinux/config`

if [ $SELINUX != "SELINUX=disabled" ];then
  cp /etc/selinux/config /etc/selinux/config.bak
  sed -i 's/^SELINUX=/#SELINUX=/g' /etc/selinux/config
  sed -i '$a SELINUX=disabled' /etc/selinux/config
else
  echo "SELINUX is already disabled"
fi



3)透明大页
--查看
[root@pgDB01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

--关闭
sed -i 's/quiet/quiet transparent_hugepage=never/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot


2.5、修改shm自动挂载

cp /etc/fstab /etc/fstab_`date +"%Y%m%d_%H%M%S"`
echo "tmpfs    /dev/shm    tmpfs    rw,exec    0 0">>/etc/fstab


2.6、修改host文件

cp /etc/hosts /etc/hosts_`date +"%Y%m%d_%H%M%S"`
echo '
192.168.74.129 ora19c1
'>> /etc/hosts
cat /etc/hosts

2.7、修改内核参数

1)参数设置

从redhat 7起,原来redhat 6下的内核参数配置文件/etc/sysctl.conf已经不推荐使用,【尽管经过实测(7.4 7.6),/etc/sysctl.conf下配置内核参数仍然可以永久生效】,不过我们还是按照推荐,在参数修改位于/etc/sysctl.d/下,创建个99-oracle.conf的文件。
--脚本配置
cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo
MemTotal=`grep MemTotal /proc/meminfo | awk '{print $2}'`
PAGE_SIZE=`getconf PAGE_SIZE`
shmmax=`expr $MemTotal \* 1024`
shmall=`expr $shmmax / $PAGE_SIZE`
cat >> /etc/sysctl.conf << EOF fs.file-max = 6815744 kernel.sem = 10000 10240000 10000 1024 kernel.shmmni = 4096 kernel.shmall = $shmall kernel.shmmax = $shmmax net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 16777216 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.wmem_default = 16777216 fs.aio-max-nr = 6194304 vm.dirty_ratio=20 vm.dirty_background_ratio=3 vm.dirty_writeback_centisecs=100 vm.dirty_expire_centisecs=500 vm.swappiness=10 vm.min_free_kbytes=524288 net.core.netdev_max_backlog = 30000 net.core.netdev_budget = 600 net.ipv4.conf.all.rp_filter = 2 net.ipv4.conf.default.rp_filter = 2 #vm.nr_hugepages =51200 EOF --启用参数 sysctl --system --大页计算 使用Oracle 提供的脚本hugepages_settings.sh的脚本来计算vm.nr_hugepages的值,这个参数值需要根据实际的大内存页面数设置,这个参数在大内存页设置一节有详细描述。注脚本跑出来的值在加10,以免SGA有额外开销用不上,用以下命令来计算内核参数。 MEM=512; SGA=256; echo "vm.nr_hugepages = `expr ${MEM} / 2 \* 1024 \* 1024 \* 1024 / 2048 / 1024 + 10; `"


2)参数设置


2.8、配置本地yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

2.9、rpm****依赖包安装

rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' \
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 \
kmod-oracleasm \
kmod-libs \

rpm安装
yum -y install targetcli python python-configshell python-rtslib python-six bc binutils compat-libstdc compat-libcap1 gcc gcc-c++ libX11 libXau libXi libXtst libXrender libXrender-devel libxcb glibc glibc-common  glibc-devel fontconfig-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat openssh-clients compat-libcap1   xorg-x11-utils xorg-x11-xauth elfutils unixODBC unixODBC-devel libXp elfutils-libelf elfutils-libelf-devel smartmontools

yum install -y /soft/*.rpm

yum -y install /lib64/libnsl.so.1 



日常管理工作安装

yum -y install unzip  sysstat setuptool telnet iotop openssh-clients net-tools unzip libvncserver tigervnc-server device-mapper-multipath dstat lsof ntp psmisc redhat-lsb-core parted xhost strace showmount expect tcl


2.10、创建用户、用户组及目录

1)创建用户组
    groupadd -g 54321 oinstall
    groupadd -g 54322 dba
    groupadd -g 54323 oper
    groupadd -g 54324 backupdba
    groupadd -g 54325 dgdba
    groupadd -g 54326 kmdba
    groupadd -g 54327 asmdba
    groupadd -g 54330 racdba

2)创建oracle用户
    useradd -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,racdba -u 6000 oracle
    --修改oracle密码
    echo "Oracle123()"|passwd oracle --stdin

3)创建目录

mkdir -p /u01/app
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/product/19.3/dbhome_1
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app


2.11 配置用户环境变量

cat >> /home/oracle/.bash_profile << "EOF" export TMP=/tmp export TMPDIR=$TMP export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/19.3/dbhome_1 export ORACLE_SID=prod1 export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH EOF


2.12 修改会话限制

1)备份配置文件
cp /etc/security/limits.conf /etc/security/limits.conf.bak

2、修改oracle会话限制
cat >> /etc/security/limits.conf << "EOF" oracle soft nproc 655350 oracle hard nproc 655350 oracle soft nofile 655360 oracle hard nofile 655360 oracle soft stack 102400 oracle hard stack 327680 EOF echo --------------/etc/pam.d/login----------------- echo cat >> /etc/pam.d/login << "EOF" session required pam_limits.so EOF --------------/etc/profile----------------- cat >> /etc/profile << "EOF" if [ $USER = "oracle" ] || [ $USER = "root" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi EOF

三、DB****安装及初始化实例(静默)

3.1、解压oracle soft

su – oracle
cd /soft/
unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME


3.2 安装db soft

1)配置rsp文件,静默安装db
$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=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.3/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=backupdba
oracle.install.db.OSDGDBA_GROUP=dgdba
oracle.install.db.OSKMDBA_GROUP=kmdba
oracle.install.db.OSRACDBA_GROUP=racdba
oracle.install.db.rootconfig.executeRootScript=false

2)执行安装
--设置兼容性, 解决[INS-08101] Unexpected error while executing the action at state: 'supportedOSCheck'
export CV_ASSUME_DISTID=RHEL7.6

cd $ORACLE_HOME
--安装前检查
./runInstaller -executePrereqs -silent -responseFile /u01/app/oracle/product/19.3/dbhome_1/install/response/db_install.rsp
--安装DB软件
./runInstaller -silent -responseFile /u01/app/oracle/product/19.3/dbhome_1/install/response/db_install.rsp -skipPrereqs

--执行root.sh脚本
[root@ora19c ~]# /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@ora19c ~]# /u01/app/oracle/product/19.3/dbhome_1/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/19.3/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Oracle Trace File Analyzer (TFA - Standalone Mode) is available at :
    /u01/app/oracle/product/19.3/dbhome_1/bin/tfactl

Note :
1. tfactl will use TFA Service if that service is running and user has been granted access
2. tfactl will configure TFA Standalone Mode only if user has no access to TFA Service or TFA is not installed


安装时提示[INS-08101] Unexpected error while executing the action at state: 'supportedOSCheck'

报错的主要原因是OS 操作系统不兼容问题
通过以下方法解决
export CV_ASSUME_DISTID=RHEL7.6


3)清理环境重新安装

    rm -rf /u01/app
    rm -rf /etc/oracle
    rm -f /etc/init.d/init.cssd 
    rm -f /etc/init.d/init.crs 
    rm -f /etc/init.d/init.crsd 
    rm -f /etc/init.d/init.evmd 
    rm -f /etc/oraInst.loc
    rm -f /u01/app/oracle/oraInventory
    rm -rf /etc/oratab
    rm -rf /tmp/Ora*


4)DBCA静默文件

--配置文件
$ORACLE_HOME/assistants/dbca/dbca.rsp
--配置内容
responseFileVersion=/home/oracle/rspfmt_dbca_response_schema_v19.0.0
gdbName=orclcdb
sid=orclcdb
sysPassword=oracle
oracleHomeUserPassword=oracle
templateName=General_Purpose.dbc
emExpressPort=5500
totalMemory=800
sysPassword=Oracle123
systemPassword=Oracle123
datafileDestination=/u01/app/oracle/oradata
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
databaseType=OLTP
createAsContainerDatabase=true


5)创建实例

$ dbca -silent -createDatabase -responseFile $ORACLE_HOME/assistants/dbca/dbca.rsp
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
52% complete
56% complete
60% complete
Completing Database Creation
66% complete
69% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/orclcdb.
Database Information:
Global Database Name:orclcdb
System Identifier(SID):orclcdb
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orclcdb/orclcdb.log" for further details


四、DB安装及初始化实例


1)验证图形化

[root@ora19c ~]# export DISPLAY=192.168.3.245:0.0
[root@ora19c ~]# xterm

2)图形化安装数据库软件

export CV_ASSUME_DISTID=RHEL7.6

[oracle@ora19c ~]$ cd $ORACLE_HOME
[oracle@ora19c dbhome_1]$ ./runInstaller 
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.
Launching Oracle Database Setup Wizard...

1、选择只安装 database 软件

2、单实例数据库安装

3、企业版安装

4、配置database 的base 目录( 已从环境变量中自动获取)


5、配置database 软件用户组( 已从用户信息直接获取)

6、配置安装脚本自动执行,输入root 用户密码( 如不配置则需手动执后面的安装脚本)

7、安装前检查
swap检查可以忽略继续安装



8、开始安装数据库软件

执行完上面两个脚本,安装完成

3)图形初始化数据库实例
[oracle@ora19c dbhome_1]$ dbca


五、安装故障


1、DBCA在配置内存过程中报错

DBCA failed with DBT-50000 & DBT-50001

解决方案:

Please apply the one-off patch for BUG 30827849 via https://updates.oracle.com/download/30827849.html.
Or you can apply DB RU19.12 and later.
Or you can use below workaround to run dbca.
COMMAND: dbca -J-Djava.io.tmpdir=
E.g: ./dbca -J-Djava.io.tmpdir=/home/oracle/tmp

2、安装前检查,提示SWAP空间问题

1、swap的作用
系统管理和DBA都知道,在Linux和UNIX系统上都有一个SWAP分区,该分区,例似于于Windows系统上的虚拟内存。
当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,临时转移到SWAP上,供当前运行的程序提供物理内存空间,当程序需要再访问被转移到了SWAP空间上的数据时,再从SWAP中恢复到物理内存中。从此工作原理不难看出来,SWAP要有,但是尽量不要使用,使用了就会发生内存交换,必然影响系统性能。

2、swap设置问题
有经验的系统管理员和DBA,往往会给系统建设一个适中大小的SWAP大小,但实际生产系统中,也经常发现有一些,因为SWAP设置过小的原因,而导致物理内存、SWAP全部耗尽,导致DOWN机的情况;也有发现一因为SWAP设置太大太大而浪费必要的存储空间的情况,SWAP到底该设置多大,可以参考一下ORACLE官方的建议。

3、ORACLE官方建议swap设置标准
对于运行ORACLE数据库的操作系统,ORACLE官方是有设置大小建议的,在此以从ORACLE 官方文档中提取的建议大小为例:
(1)ORACLE官方要求最小1GB的RAM,建议2GB或更大
(2)SWAP与RAM的大小配置关系
  • 1)RAM为1-2GB时,SWAP大小建议为RAM大小的1.5倍
  • 2)RAM为2-16GB时,SWAP大小建议与RAM大小相等
  • 3)RAM大于16GB时,SWAP大小建议为16GB

4、如何调整SWAP空间
1)创建swapfile:
root权限下,创建swapfile,假设当前目录为“/”,执行如下命令:
#dd if=/dev/zero of=swapfile bs=1024 count=500000
则在根目录下创建了一个swapfile,名称为“swapfile”,大小为500M
2)将swapfile设置为swap空间
#mkswap swapfile
3)启用交换空间:
# swapon swapfile
可以使用free命令查看swap空间大小是否发生变化;
示例如下
[root@oracle19c03 ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/nvme0n1p2                          partition       2145276 668672  -2
/root/swapfile                          file            499996  0       -3
[root@oracle19c03 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           2814         623         700           0        1489         720
Swap:          2583         653        1930