目录
一、安装准备
系统版本:CentOS Linux release 7.9.2009 (Core)
(安装步骤见文章:https://blog.csdn.net/a2279338659/article/details/126346345)
Oracle 19c 安装包:
链接:https://pan.baidu.com/s/1uWnRYXFraZonoVyFeyHRrQ
提取码:0712
CentOS7镜像(见文章https://blog.csdn.net/a2279338659/article/details/126346345)
二、环境配置
2.1 修改配置hosts文件
[root@ORCL ~]# vi /etc/hosts
192.168.198.142 ORCL ORCL.localdamain
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
2.2 关闭防火墙
[root@ORCL ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-10-21 15:37:18 CST; 1h 5min ago
Docs: man:firewalld(1)
Main PID: 771 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─771 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
Oct 21 15:37:14 ORCL systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 21 15:37:18 ORCL systemd[1]: Started firewalld - dynamic firewall daemon.
Oct 21 15:37:19 ORCL firewalld[771]: WARNING: AllowZoneDrifting is enabled. This is con...ow.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ORCL ~]# systemctl stop firewalld.service
[root@ORCL ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
2.3 关闭SELINUX防火墙
[root@ORCL ~]# vi /etc/selinux/config
2.4 配置yum源
[root@ORCL ~]# cd /etc/yum.repos.d/
[root@ORCL yum.repos.d]# rm -rf /etc/yum.repos.d/ *
[root@ORCL yum.repos.d]# echo > /etc/yum.repos.d/server.repo
[root@ORCL yum.repos.d]# vi /etc/yum.repos.d/server.repo
#挂载镜像文件,安装ORACLE先决条件的软件包
[root@ORCL soft]# mount -o loop CentOS-7-x86_64-DVD-2009.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only
[root@ORCL ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 0 1.4G 0% /dev/shm
tmpfs 1.4G 11M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda3 26G 12G 15G 45% /
/dev/sda1 1014M 180M 835M 18% /boot
tmpfs 283M 0 283M 0% /run/user/0
tmpfs 283M 40K 283M 1% /run/user/1000
/dev/loop0 4.4G 4.4G 0 100% /mnt
[root@ORCL ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: Server
Cleaning up list of fastest mirrors
Other repos take up 166 M of disk space (use --verbose for details)
[root@ORCL ~]# yum repolist all
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Server | 3.6 kB 00:00:00
(1/2): Server/group_gz | 153 kB 00:00:00
(2/2): Server/primary_db | 3.3 MB 00:00:00
repo id repo name status
Server Server enabled: 4,070
repolist: 4,070
[root@ORCL ~]# yum install -y bc
yum install -y compat-libcap1*
yum install -y compat-libcap*
yum install -y binutils
yum install -y compat-libstdc++-33
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y gcc
yum install -y gcc-c++
yum install -y glibc-2.5
yum install -y glibc-common
yum install -y glibc-devel
yum install -y glibc-headers
yum install -y ksh libaio
yum install -y libaio-devel
yum install -y libgcc
yum install -y libstdc++
yum install -y libstdc++-devel
yum install -y make
yum install -y sysstat
yum install -y unixODBC
yum install -y unixODBC-devel
yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install -y libXp*
yum install -y glibc-kernheaders
yum install -y net-tools-*
yum install -y libXrender-devel
yum insatll -y fontconfig-devel
yum install -y expect
yum install -y tigervnc-server
yum install -y vnc
yum install -y lfutils-libelf-devel
yum install -y ibXrender-devel
yum install -y martmontools
yum install -y ontconfig-devel
#19c 额外需要的安装依赖包
[root@ORCL ~]# rpm -ivh /soft/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
warning: /soft/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:compat-libstdc++-33-3.2.3-72.el7 ################################# [100%]
[root@ORCL ~]#
2.5 修改LINUX的内核文件
根据官方文档将参数整合成一个脚本命令,直接复制下方命令执行即可:
DAYTIME=$(date +%Y%m%d)
mv /etc/sysctl.conf /etc/sysctl.conf.${DAYTIME}
memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')
totalMemory=$((memTotal / 2048))
shmall=$((memTotal / 4))
if [ $shmall -lt 2097152 ]; then
shmall=2097152
fi
shmmax=$((memTotal * 1024 - 1))
if [ "$shmmax" -lt 4294967295 ]; then
shmmax=4294967295
fi
cat <<EOF >/etc/sysctl.conf
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = $shmall
kernel.shmmax = $shmmax
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 = 1048576
EOF
[root@ORCL ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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 = 1048576
2.6 Limits配置
[root@ORCL ~]# vi /etc/security/limits.conf
添加以下内容:
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
2.7 添加条目
[root@ORCL ~]# vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
2.8 创建文件目录和相应的用户
[root@ORCL ~]# groupadd -g 1001 oinstall
[root@ORCL ~]# groupadd -g 1002 dba
[root@ORCL ~]# groupadd -g 1003 oper
[root@ORCL ~]# groupadd -g 1004 backupdba
[root@ORCL ~]# groupadd -g 1005 dgdba
[root@ORCL ~]# groupadd -g 1006 kmdba
[root@ORCL ~]# groupadd -g 1007 racdba
[root@ORCL ~]# useradd -g oinstall -G dba,oper,backupdba,dgdba,kmdba,racdba oracle
[root@ORCL ~]# echo "123456" |passwd oracle --stdin
Changing password for user oracle.
passwd: all authentication tokens updated successfully.
[root@ORCL ~]# mkdir -p /u01/app/oracle
[root@ORCL ~]# mkdir -p /u01/oraInventory
[root@ORCL ~]# mkdir -p /u01/app/oracle/product/19c/db_1
[root@ORCL ~]# chown oracle.oinstall /u01
[root@ORCL ~]# chown oracle:oinstall /u01/app/oracle
[root@ORCL ~]# chmod -R 775 /u01/app/oracle
[root@ORCL ~]# chown -R oracle:oinstall /u01/app/oracle/product/
2.9 配置ORACLE用户的环境变量
[root@ORCL ~]# su - oracle
[oracle@ORCL ~]$ vi .bash_profile
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19c/db_1/
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
[oracle@ORCL ~]$ source .bash_profile
三、安装Oracle软件
3.1 解压安装包。
[oracle:/home/oracle]$unzip /soft/LINUX.X64_193000_db_home\ .zip -d /u01/app/oracle/product/19c/db_1/
3.2 按步骤进行Oracle软件的安装。
[oracle:/home/oracle]$cd /u01/app/oracle/product/19c/db_1/
[oracle:/u01/app/oracle/product/19c/db_1]$./runInstaller
[root@ORCL ~]# /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@ORCL ~]# /u01/app/oracle/product/19c/db_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/19c/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
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/19c/db_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
四、Netca创建监听
[oracle:/home/oracle]$netca
五、DBCA创建数据库
[oracle:/home/oracle]$dbca
六、检查并测试是否安装成功
6.1 启动监听
[oracle:/home/oracle]$lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 24-OCT-2022 10:42:29
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19c/db_1//bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19c/db_1//network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/ORCL/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ORCL)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ORCL)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 24-OCT-2022 10:42:29
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19c/db_1//network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/ORCL/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ORCL)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
6.2 sqlplus连接启动数据库
[oracle@ORCL ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Oct 24 11:00:36 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
//启动数据库
SQL>startup
ORACLE instance started.
Total System Global Area 1191181696 bytes
Fixed Size 8895872 bytes
Variable Size 788529152 bytes
Database Buffers 385875968 bytes
Redo Buffers 7880704 bytes
Database mounted.
Database opened.
6.3查看监听状态
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 24-OCT-2022 11:02:50
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ORCL)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 24-OCT-2022 10:59:18
Uptime 0 days 0 hr. 3 min. 32 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19c/db_1//network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/ORCL/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ORCL)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=ORCL)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
至此,Oracle软件,实例以及监听都安装和配置成功,如果有什么问题可以留言或私信讨论,希望可以跟大家一起进步。