1、服务器环境
操作系统 | CentOS 7.4 |
数据库版本 | 19.5.0 |
CPU | T450 i5 |
物理内存 | 8G |
swap | 20G |
虚拟机硬盘 | 80G |
2、安装系统依赖包
2.1 检查缺失的依赖包
rpm --query --queryformat "%{NAME}-%{VERSION}.%{RELEASE} (%{ARCH})\n" bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat elfutils-libelf elfutils-libelf-devel fontconfig-devel libxcb smartmontools libX11 libXau libXtst libXrender libXrender-devel

2.2 使用yum进行安装依赖包
主要安装 “package XXX is not installed” 的依赖包。
yum install -y compat-libcap1 compat-libstdc++-33 gcc-c++
3、准备工作
3.1 创建oracle用户组
[root@ywxtdb ~]# groupadd oinstall
[root@ywxtdb ~]# groupadd dba
[root@ywxtdb ~]# groupadd asmdba
[root@ywxtdb ~]# groupadd backupdba
[root@ywxtdb ~]# groupadd dgdba
[root@ywxtdb ~]# groupadd kmdba
[root@ywxtdb ~]# groupadd racdba
[root@ywxtdb ~]# groupadd oper
[root@ywxtdb ~]#
[root@ywxtdb ~]# useradd -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper -m oracle
3.2 配置域名解析文件
配置/etc/hosts文件
[root@host-173-16-87-178 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.128 ywxtdb
3.3 配置系统内核参数
[root@host-173-16-87-178 ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1998336
kernel.shmmax = 4911110553.6
kernel.shmmni = 6144
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 = 1048576
--- 如上是以8G内存为标准配置
#共享内存设置公式
kernel.shmall:控制共享内存页数,该参数大小为物理内存除以pagesize
kernel.shmmax:设置为实际物理内存的2/3
1、查询pagesize
[root@WWJD01 ~]# getconf PAGESIZE -- 4096
2、查询物理内存
[root@WWJD01 ~]# free -m
total used free shared buffers cached
Mem: 258012 87100 170912 78214 225 79199
-/+ buffers/cache: 7675 250337
Swap: 65535 0 65535
3、计算共享内存
kernel.shmall = 258012*1024/4=66051072
kernel.shmmax = 258012*1024*1024*0.6=162327114547.2
#输入sysctl -P使配置生效
[root@localhost ~]# /sbin/sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1998336
sysctl: setting key "kernel.shmmax": Invalid argument
kernel.shmmax = 4911110553.6
kernel.shmmni = 6144
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 = 1048576
3.4 关闭selinux和防火墙
[root@host-173-16-87-178 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@host-173-16-87-178 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
You have mail in /var/spool/mail/root
[root@host-173-16-87-178 ~]#
3.5 配置用户环境
1、oracle用户环境变量
[root@host-173-16-87-178 ~]# su - oracle
[oracle@ywxtdb ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19.5.0
export PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin
export ORACLE_HOSTNAME=ywxtdb
export ORACLE_SID=ywxtdb
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/network/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
[root@host-173-16-87-178 ~]#
#创建oracle安装目录
[root@host-173-16-87-178 ~]# mkdir -p /u01/app/oracle/product/19.5.0
[root@host-173-16-87-178 ~]# chmod 777 /u01
2、修改用户的Shell限制
[root@host-173-16-87-178 ~]# vi /etc/security/limits.conf
# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
"/etc/security/limits.conf" 67L, 2542C
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
# End of file
# Set Oracle Database Server
@oinstall soft nofile 2048
@oinstall hard nofile 65536
@oinstall soft nproc 16384
@oinstall soft stack 10240
"/etc/security/limits.conf" 73L, 2681C written
[root@host-173-16-87-178 ~]#
4、安装
4.1 解压安装包
[root@ywxtdb soft]# cd /u01/app/oracle/product/19.5.0
[root@ywxtdb 19.5.0]# unzip LINUX.X64_193000_db_home.zip -d .
[root@ywxtdb 19.5.0]# chown -R oracle:oinstall /u01/*
4.2配置响应文件
su - oracle
#备份
[oracle@zbglxtdb response]$ cd $ORACLE_HOME/install/response
[oracle@zbglxtdb response]$ cp db_install.rsp db_install.rsp.bak
#编辑db_install.rsp
[oracle@zbglxtdb response]$ vi db_install.rsp
主要是修改以下参数
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.5.0
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
4.3 执行安装
[oracle@localhost response]$ cd ../../
[oracle@localhost 19.5.0]$ ./runInstaller -silent -responseFile /u01/app/oracle/product/19.5.0/install/response/db_install.rsp
Launching Oracle Database Setup Wizard...
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2020-10-23_02-59-42PM.log
ACTION: Identify the list of failed prerequisite checks from the log: installActions2020-10-23_02-59-42PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
/u01/app/oracle/product/19.5.0/install/response/db_2020-10-23_02-59-42PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2020-10-23_02-59-42PM/installActions2020-10-23_02-59-42PM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/19.5.0/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[zylc]
Execute /u01/app/oracle/product/19.5.0/root.sh on the following nodes:
[zylc]
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2020-10-23_02-59-42PM
4.4 根据提示使用root用户执行脚本完成安装
[oracle@localhost 19.5.0]$ exit
logout
[root@localhost 19.5.0]# /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@localhost 19.5.0]# /u01/app/oracle/product/19.5.0/root.sh
Check /u01/app/oracle/product/19.5.0/install/root_localhost.localdomain_2022-07-24_22-08-56-879455388.log for the output of root script
5、创建数据库实例
5.1 配置监听
[root@localhost 19.5.0]# su - oracle
Last login: Sun Jul 24 22:08:56 CST 2022 on pts/0
[oracle@localhost ~]$ netca /silent /responseFile /u01/app/oracle/product/19.5.0/assistants/netca/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /u01/app/oracle/product/19.5.0/assistants/netca/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/19.5.0/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
查看监听状态
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 24-JUL-2022 22:11:16
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ywxtdb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 24-JUL-2022 22:10:03
Uptime 0 days 0 hr. 1 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.5.0/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.128)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
5.2 创建数据库
[oracle@localhost ~]$ cd /u01/app/oracle/product/19.5.0/assistants/dbca
[oracle@localhost dbca]$ cp dbca.rsp dbca.rsp.bak
[oracle@localhost dbca]$ vi dbca.rsp
#主要修改以下参数
gdbName=ywxtdb
sid=ywxtdb
databaseConfigType=SI
templateName=General_Purpose.dbc
sysPassword=sys
systemPassword=sys
emConfiguration=DBEXPRESS
dbsnmpPassword=“password”
datafileDestination=/u01/app/oracle/oradata
characterSet=ZHS16GBK
totalMemory=8192
5.3 执行安装
[oracle@localhost dbca]$ dbca -silent -createDatabase -responseFile /u01/app/oracle/product/19.5.0/assistants/dbca/dbca.rsp
[WARNING] [DBT-11209] Current available memory is less than the required available memory (8,192MB) for creating the database.
CAUSE: Following nodes do not have required available memory :
Node:localhost Available memory:6.9089GB (7244488.0KB)
[WARNING] [DBT-11207] Specified SGA size is greater than the shmmax on the system. The database creation might fail with "ORA-27125 - Unable to create shared memory segment error".
ACTION: Specify SGA size lesser than or equal to the shmmax on the system.
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
10% complete
Copying database files
40% complete
Creating and starting Oracle instance
42% complete
46% complete
50% complete
54% complete
60% complete
Completing Database Creation
66% complete
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/ywxtdb.
Database Information:
Global Database Name:ywxtdb
System Identifier(SID):ywxtdb
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ywxtdb/ywxtdb.log" for further details.
5.4 检查
[oracle@ywxtdb ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Mar 6 21:53:54 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
???:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
发现有乱码,需要修改客户端的字符集
[oracle@ywxtdb ~]$vi .bash_profile #添加下面这行后重新应用生效即可。
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
".bash_profile" 21L, 623C written
[oracle@ywxtdb ~]$ source .bash_profile
连接数据库
[oracle@ywxtdb ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on 星期五 3月 6 21:56:33 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
连接到:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
ywxtdb OPEN
SQL> exit
从 Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0 断开
[oracle@ywxtdb ~]$
6、设置开机自启
6.1 修改配置
打开开关,如下设置为Y
[root@localhost ~]# 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.
#
#
ywxtdb:/u01/app/oracle/product/19.5.0:Y
创建启动脚本
[root@localhost ~]# vi /usr/bin/oracle.sh
#! /bin/bash
# script For oracle19c.service
/u01/app/oracle/product/19.5.0/bin/lsnrctl start
/u01/app/oracle/product/19.5.0/bin/dbstart /u01/app/oracle/product/19.5.0
设置权限
[root@localhost ~]# chmod 777 /usr/bin/oracle.sh
添加自启脚本
[root@localhost ~]# vi /etc/systemd/system/oracle19c.service
[Unit]
Description=Oracle19c
After=syslog.target network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=oneshot
RemainAfterExit=yes
User=oracle
Environment="ORACLE_HOME=/u01/app/oracle/product/19.5.0"
ExecStart=/usr/bin/oracle.sh
[Install]
WantedBy=multi-user.target
设置开机自启
[root@localhost ~]# systemctl enable oracle19c
Created symlink from /etc/systemd/system/multi-user.target.wants/oracle19c.service to /etc/systemd/system/oracle19c.service.
测试
[root@localhost ~]# reboot
重新登录
如下则表示自启成功。
[root@localhost ~]# systemctl status oracle19c
● oracle19c.service - Oracle19c
Loaded: loaded (/etc/systemd/system/oracle19c.service; enabled; vendor preset: disabled)
Active: activating (start) since Wed 2022-07-27 18:55:17 CST; 8s ago
Main PID: 1289 (oracle.sh)
CGroup: /system.slice/oracle19c.service
├─1289 /bin/bash /usr/bin/oracle.sh
├─1711 /u01/app/oracle/product/19.5.0/bin/tnslsnr LISTENER -inherit
├─1758 /bin/sh /u01/app/oracle/product/19.5.0/bin/dbstart /u01/app/oracle/product/19.5.0
├─1846 /bin/sh /u01/app/oracle/product/19.5.0/bin/dbstart /u01/app/oracle/product/19.5.0
├─1920 sqlplus
└─1921 oracleywxtdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: Security ON: Local OS Authentication
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: SNMP OFF
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: Listener Parameter File /u01/app/oracle/product/19.5.0/network/admin/l...r.ora
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listene...g.xml
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: Listening Endpoints Summary...
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.128)(PORT=1521)))
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: The listener supports no services
Jul 27 18:55:21 localhost.localdomain oracle.sh[1289]: The command completed successfully
Jul 27 18:55:22 localhost.localdomain oracle.sh[1289]: Processing Database instance "ywxtdb": log file /u01/app/oracle/product/...p.log
Hint: Some lines were ellipsized, use -l to show in full.
版权声明:本文为zlb663107原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。