CentOS7安装Oracle21c

2年前 (2022) 程序员胖胖胖虎阿
287 0 0

前提条件:
准备一台CentOS虚拟机。(2C 8G 80GB)
参考:vmware上安装centos7的安装(仅主机模式)

1.先决条件

1.1关闭防火墙

#检查防火墙状态
systemctl status firewalld.service
#暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动
systemctl stop firewalld.service
#彻底永久关闭防火墙
systemctl disable firewalld.service

1.2 关闭SELINUX防火墙!

vi /etc/selinux/config
将内容
SELINUX=enforcing
更改为
SELINUX=disabled

1.3 更改主机名,
/etc/hosts中添加 192.168.16.21 oracle21c

vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.16.21 oracle21c

1.4 配置yum源:参考 yum源的介绍

创建 yums目录

[root] mkdir /yums

a 挂载光盘镜像
b 进入到光盘镜像中的Package目录中将所有的软件包复制到我们预设的目录下

cd /run/media/root/CentOS 7 x86_64/Packages
cp * /yums
cd /yums
createrepo .

删除CentOS自带的YUM源,并创建yum.local.repo文件,加入如下内容
[local]
name=yum local repo
baseurl=file:///yums
gpgcheck=0
enable=1

cd /etc/yum.repos.d/
rm -rf *
vi yum.local.repo
[local]
name=yum local repo
baseurl=file:///yums
gpgcheck=0
enable=1

生成缓存

yum clean all 

1.5 安装依赖包

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-*

1.6. 修改LINUX的内核文件

vi /etc/sysctl.conf
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 67747971072
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
#net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2

生成系统参数

sysctl -p 

1.7 添加下列参数到/etc/security/limits.conf

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

1.8.添加下列条目到/etc/pam.d/login 这两个主要是限制使用进程数

vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so

1.9 添加环境变量

vim /etc/profile
if [ $USER = "oracle" ]; then
   if [ $SHELL = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
      else
      ulimit -u 16384 -n 65536
   fi
fi

使环境变量生效

source /etc/profile

1.10 创建文件目录和相应的用户

groupadd oinstall
groupadd dba     
groupadd oper         
useradd -g oinstall -G dba,oper oracle
	
mkdir -p /u01/app/oracle                    	     
mkdir -p /u01/app/oraInventory
chown -R oracle.oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle	
	
#/21c需要额外创建
mkdir -p /u01/app/oracle/product/21c/db_1    
chown -R oracle:oinstall /u01/app/oracle/product/

1.11给oracle用户加一个密码

passwd oracle

1.12 配置ORACLE用户的环境变量

su - oracle
#修改oracle用户的环境变量文件
vim .bash_profile
export EDITOR=vi
export TMP=/tmp  
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/21c/db_1
export INVENTORY_LOCATION=/u01/app/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022

使环境变量生效

source .bash_profile

1.13 上传软件并且解压
21c和11g/12c不一样一定要上传到ORACLE_HOME目录/u01/app/oracle/product/21c/db_1下。

su - root
chown -R oracle:oinstall LINUX.X64_213000_db_home.zip

su - oracle
cd $ORACLE_HOME
unzip LINUX.X64_213000_db_home.zip

1.14 安装额外的依赖包(11g和12c不需要)
只需要将下列的软件包上传到服务器/root 目录下即可
切记这三个软件包上传到哪里,你就必须要在这个位置上执行以下命令安装软件包:

su - root
cd /root
yum install -y compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
yum install -y kmod-20-21.el7.x86_64.rpm
yum install -y kmod-libs-20-21.el7.x86_64.rpm

1.15 将显示内容在宿主机上显示
注意:192.168.16.1 是我本机的VMnet1的网卡的IP。因为我虚拟机选用是仅主机模式
CentOS7安装Oracle21c

切换回oracle用户下进行安装。

su - oracle
export DISPLAY=192.168.16.1:0.0
cd $ORACLE_HOME
./runInstaller

2.开始安装

CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
新开一个session,用root用户登入顺序执行
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/21c/db_1/root.sh

[root@ ~]# /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@oracle11g ~]# /u01/app/oracle/product/21c/db_1/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/21c/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.
[root@ ~]#

3.配置监听

[oracle@ db_1]$ netca

CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c

5.dbca建库

[oracle@ db_1]$ dbca

CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
CentOS7安装Oracle21c
安装完成

使用sqlplus / as sysdba登入验证。

[oracle@ db_1]$ sqlplus / as sysdba

SQL*Plus: Release 21.0.0.0.0 - Production on Mon May 16 03:25:14 2022
Version 21.3.0.0.0

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


Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> select sysdate from dual;

SYSDATE
-------------------
2022-05-16 03:25:26

SQL>

附加

SQL> select sysdate from dual;

SYSDATE
-------------------
2022-05-16 03:25:26

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
SQL>

21c 创建一个新的PDB:

[oracle@ db_1]$ dbca

CentOS7安装Oracle21c

CentOS7安装Oracle21c

CentOS7安装Oracle21c

CentOS7安装Oracle21c
CentOS7安装Oracle21c

CentOS7安装Oracle21c
CentOS7安装Oracle21c

CentOS7安装Oracle21c

再次等入,就可以看见PDB创建成功了。
CentOS7安装Oracle21c
如果这篇文章对您有帮助,请帮忙在下方点个赞。
如果有疑问,欢迎在评论留言哦…

版权声明:程序员胖胖胖虎阿 发表于 2022年9月12日 下午7:24。
转载请注明:CentOS7安装Oracle21c | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...