侧边栏壁纸
博主头像
DBA的笔记本博主等级

think in coding

  • 累计撰写 21 篇文章
  • 累计创建 20 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

从0开始在云上搭建一台Oracle服务器

张彤
2024-07-20 / 0 评论 / 0 点赞 / 51 阅读 / 41815 字

前面的话

Oracle 数据库安装繁复,如果没有专业dba带路,大部分同学在windows上安装很可能会出现非常尬尴的情况,如果没有安装成功,又没有删干净的话,是没法重新安装的,糟糕的情况下,需要重装系统。 那么读此文前,我希望你具备以下知识,这样的话,会更快的定位部署中遇到的问题。

  • linux 常用的命令,角色,权限,组等概念

  • oracle的文件组织架构

  • 云服务器的基础,如果是在自己的虚拟机上安装,这步可以替换为本机虚拟网关。

申请云资源

  • 这里以腾讯云的轻量服务器为例,其他云类似,不是意味着腾讯云就好。 现在假设我们腾讯的账号和实名认证工作已经完成,服务器也已经购买。

启动后的第一步就是修改登陆密码。 控制台-轻量应用服务器-左侧栏 服务器-点击进入具体的实例-实例信息中的右下方 重置密码

在这里需要注意一下资源使用情况,轻量级的服务器便宜是便宜,但是限制也是蛮多的。主要是以下几点

  • 系统盘不能扩容

  • 每月有一个流量限制

  • 镜像无法共享

  • IP无法更改

修改登陆方式

由于在外网上,常常有人猜密码,这些都在/var/log/scure日志中有所记录,一旦破解成功,服务器就芭比Q了。

[root@oel7 ~]# cd ~
[root@oel7 ~]# ssh-keygen -t rsa

第一次输入这个命令的时候,第一个提示是是否将密钥放入默认路径/root/.ssh

[root@oel7 .ssh]# ll 
total 8
-rw------- 1 root root  400 Jan  5 01:12 id_rsa.pub
-rw------- 1 root root 1766 Jan  5 01:12 id_rsa
[root@oel7 .ssh]# mv id_rsa.pub authorized_keys
[root@oel7 .ssh]# chmod 600 authorized_keys
​
  • 使用xshell用私钥远程免密登录,选择浏览点击文件,选择私钥文件即可登录。

关闭密码登陆,启用密钥登陆 修改文件/etc/ssh/sshd_config PasswordAuthentication no 关闭密码登陆 AuthorizedKeysFile .ssh/authorized_keys 设置公钥位置 PubkeyAuthentication yes 开启公钥

然后使用命令systemctl restart sshd重启登陆服务。

  • 注:这里需要特别小心的是,密钥登陆配置一旦更改,最好先不要关闭本窗口,而是新开一个窗口测试,是否能够通过私钥登陆服务器,如果不能,那么需要抓紧恢复了,如果关闭窗口后,再登陆出现认证错误,那么你和你的服务器只能说再见了,唯一的办法是腾讯云上的重装服务器。

更新yum源

# 先备份
cd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repo_bak
​
# 163
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache
# aliyun
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum clean all
​
# epel
yum -y install epel-release
yum clean all
yum makecache

安装oracle19c

到此为止,我们已经完成了初步的服务器配置,可以准备安装Oracle19c了 这里采用Oracle 静默安装

LINUX.X64_193000_db_home.zip 下载地址

安装前的准备

root用户执行以下内容

su - root

在hosts文件中添加主机信息

vim /etc/hosts
​
# 加入以下内容,例如
192.168.122.1 oel7 oel7.dbaora.com
​
# ip 可以通过 ip addr 来进行查找
# oel7 是hostname 
# 最后是域名

/etc/hosts 详解

设置hostname

hostnamectl set-hostname oel7.dbaora.com --static

更新yum 包

yum update -y

另外有以下配置步骤 新增 OS 组 新增 OS 用户 安装 OS 依赖包 设置specific kernel 参数 禁用 transparent hugepagesdefrag

自动安装 当然你也可以一劳永逸的自动化安装

yum install -y oracle-database-preinstall-19c
  • 注意,如果显示No package ,可以使用下面的命令

yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

不过下面的手动安装过程中,用户组需要变更一下组号,比如

groupmod -g 54321 oinstall

手动安装 手动安装可以给你更多配置自由

#basic groups for database management
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
​
#extra dedicated groups can be ignored for simple installations
groupadd -g 54324 backupdba
groupadd -g 54325 dgdba
groupadd -g 54326 kmdba
groupadd -g 54327 asmdba
groupadd -g 54328 asmoper
groupadd -g 54329 asmadmin
groupadd -g 54330 racdba

为Oracle软件创建Oracle用户

useradd -u 54321 -g oinstall \
-G dba,oper,backupdba,dgdba,kmdba,racdba oracle

变更oracle用户的密码

passwd oracle

安装依赖包

#basic packages to install
yum install -y bc 
yum install -y binutils 
yum install -y compat-libcap1 
yum install -y compat-libstdc++-33 
yum install -y elfutils-libelf 
yum install -y elfutils-libelf-devel 
yum install -y fontconfig-devel 
yum install -y glibc 
yum install -y glibc-devel 
yum install -y ksh 
yum install -y libaio 
yum install -y libaio-devel 
yum install -y libdtrace-ctf-devel 
yum install -y libXrender 
yum install -y libXrender-devel 
yum install -y libX11 
yum install -y libXau 
yum install -y libXi 
yum install -y libXtst 
yum install -y libgcc 
yum install -y librdmacm-devel 
yum install -y libstdc++ 
yum install -y libstdc++-devel 
yum install -y libxcb 
yum install -y make 
yum install -y smartmontools 
yum install -y sysstat
​
#following 4 not available in oel7
#yum install -y dtrace-modules 
#yum install -y dtrace-modules-headers 
#yum install -y dtrace-modules-provider-headers 
#yum install -y dtrace-utils 
​
#(for Oracle RAC and Oracle Clusterware)
yum install -y net-tools 
​
#(for Oracle ACFS)
yum install -y nfs-utils 
​
#(for Oracle ACFS Remote)
yum install -y python 
yum install -y python-configshell
yum install -y python-rtslib
yum install -y python-six
yum install -y targetcli

/etc/sysctl.conf 中增加核心参数

# kernel parameters for 19C installation
​
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
net.ipv4.ip_local_port_range = 9000 65500

应用内核参数

/sbin/sysctl -p

/etc/security/limits.conf中新增如下内容

# shell limits for users oracle 19C
​
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   soft   memlock  134217728
oracle   hard   memlock  134217728

禁用 Transparent Hugepagesdefrag

oracle 建议此步骤 新增transparent_hugepage=never 内容到文件/etc/default/grub

[root@oel7 ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"

重启后使用以下命令检查

[root@oel7 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

root用户新增如下分支路径

mkdir -p /ora01/app/oracle/product/19.3.0.0/db_1
chown oracle:oinstall -R /ora01

禁用防火墙,注意这一步可以先暂时stop ,后面讲介绍端口加入firewalld和改端口等内容

systemctl stop firewalld
systemctl disable firewalld

/home/oracle/.bash_profile文件末尾新增Oracle用户环境变量

# Oracle Settings
export TMP=/tmp
​
export ORACLE_HOSTNAME=oel7.dbaora.com
export ORACLE_UNQNAME=ORA19C
export ORACLE_BASE=/ora01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0.0/db_1
export ORACLE_SID=ORA19C
​
PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin
​
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
​
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME'
alias tns='cd $ORACLE_HOME/network/admin'
alias envo='env | grep ORACLE'
​
umask 022
​
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
       ulimit -u 16384 
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi
​
envo

至此,数据库环境已经部署完毕,下面开始安装数据库。

安装数据库软件

oracle 用户操作

[root@oel7 ~]# su - oracle

将zip文件异动到ORACLE_HOME下

[oracle@oel7 ~]$ 
cp LINUX.X64_193000_db_home.zip /ora01/app/oracle/product/19.3.0.0/db_1
​
cd /ora01/app/oracle/product/19.3.0.0/db_1
unzip LINUX.X64_193000_db_home.zip

解压后,你会看到如下内容

[oracle@oel7 db_1]$ pwd
/ora01/app/oracle/product/19.3.0.0/db_1
[oracle@oel7 db_1]$ ls
addnode     dbs          instantclient                 network  owm          root.sh.old.1  ucp
apex        deinstall    inventory                     nls      perl         runInstaller   usm
assistants  demo         javavm                        odbc     plsql        schagent.conf  utl
bin         diagnostics  jdbc                          olap     precomp      sdk            wwg
clone       dmu          jdk                           OPatch   QOpatch      slax           xdk
crs         drdaas       jlib                          opmn     R            sqldeveloper
css         dv           ldap                          oracore  racg         sqlj
ctx         env.ora      lib                           ord      rdbms        sqlpatch
cv          has          LINUX.X64_193000_db_home.zip  ords     relnotes     sqlplus
data        hs           md                            oss      root.sh      srvm
dbjava      install      mgw                           oui      root.sh.old  suptools

检查环境变量

--I defined 4 aliases in .bash_profile of user oracle to make 
--administration easier :)
​
[oracle@oel7 ~]$ alias envo tns cdoh cdob
alias envo='env | grep ORACLE'
alias tns='cd $ORACLE_HOME/network/admin'
alias cdoh='cd $ORACLE_HOME'
alias cdob='cd $ORACLE_BASE'
​
--run alias command envo to display environment settings
[oracle@oel7 ~]$ envo
ORACLE_UNQNAME=ORA19C
ORACLE_SID=ORA19C
ORACLE_BASE=/ora01/app/oracle
ORACLE_HOSTNAME=oel7.dbaora.com
ORACLE_HOME=/ora01/app/oracle/product/19.3.0.0/db_1
​
--run alias command cdob and cdoh 
--to check ORACLE_BASE, ORACLE_HOME 
[oracle@oel7 ~]$ cdob
[oracle@oel7 oracle]$ pwd
/ora01/app/oracle
​
[oracle@oel7 ~]$ cdoh
[oracle@oel7 db_1]$ pwd
/ora01/app/oracle/product/19.3.0.0/db_1

Response files 响应文件

column1

column2

column3

content1

content2

content3

|directory| response file| |-------|-------| |ORACLE_HOME/install/response |db_install.rsp | |ORACLE_HOME/assistants/dbca |dbca.rsp | |$ORACLE_HOME/assistants/netca |netca.rsp|

  • db_install.rsp – 用于安装Oracle二进制文件,以静默方式安装/升级数据库

  • dbca.rsp - 用于以静默方式安装/配置/删除数据库

  • netca.rsp - 用于在静默模式下为Oracle数据库配置简单网络

[oracle@oel7 response]$ cd $ORACLE_HOME/install/response
​
[oracle@oel7 response]$ pwd
/ora01/app/oracle/product/19.3.0.0/db_1/install/response
​
[oracle@oel7 response]$ ls *.rsp
db_install.rsp
[oracle@oel7 dbca]$ cd $ORACLE_HOME/assistants/dbca
​
[oracle@oel7 dbca]$ pwd
/ora01/app/oracle/product/19.3.0.0/db_1/assistants/dbca
​
[oracle@oel7 dbca]$ ls *.rsp
dbca.rsp
[oracle@oel7 dbca]$ cd $ORACLE_HOME/assistants/netca
​
[oracle@oel7 netca]$ pwd
/ora01/app/oracle/product/19.3.0.0/db_1/assistants/netca
​
[oracle@oel7 netca]$ ls *.rsp
netca.rsp

安装oracle二进制文件

在编辑之前,最好保留原始响应文件db_install.rsp

[oracle@oel7 response]$ cp db_install.rsp db_install.rsp.bck

编辑db_install.rsp文件中的参数以便安装Oracle,这只是示例,在下一个发布参数版本中可以不同

--------------------------------------------
-- force to install only database software
--------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
​
--------------------------------------------
-- set unix group for oracle inventory
--------------------------------------------
UNIX_GROUP_NAME=oinstall
​
--------------------------------------------
-- set directory for oracle inventory
--------------------------------------------
INVENTORY_LOCATION=/ora01/app/oraInventory
​
--------------------------------------------
-- set oracle home for binaries
--------------------------------------------
ORACLE_HOME=/ora01/app/oracle/product/19.3.0.0/db_1
​
--------------------------------------------
-- set oracle home for binaries
--------------------------------------------
ORACLE_BASE=/ora01/app/oracle
​
--------------------------------------------
-- set version of binaries to install
-- EE - enterprise edition
--------------------------------------------
oracle.install.db.InstallEdition=EE
​
--------------------------------------------
-- specify extra groups for database management
--------------------------------------------
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
  • 一旦编辑完成,启动二进制安装文件

cd /ora01/app/oracle/product/19.3.0.0/db_1
./runInstaller -silent \
-responseFile /ora01/app/oracle/product/19.3.0.0/db_1/install/response/db_install.rsp

输出如下

[oracle@oel7 db_1]$ ./runInstaller -silent \ -responseFile /ora01/app/oracle/product/19.3.0.0/db_1/install/response/db_install.rsp
Launching Oracle Database Setup Wizard...
​
The response file for this session can be found at:
 /ora01/app/oracle/product/19.3.0.0/db_1/install/response/db_2019-06-07_11-13-06AM.rsp
​
You can find the log of this install session at:
 /tmp/InstallActions2019-06-07_11-13-06AM/installActions2019-06-07_11-13-06AM.log
​
As a root user, execute the following script(s):
    1. /ora01/app/oraInventory/orainstRoot.sh
    2. /ora01/app/oracle/product/19.3.0.0/db_1/root.sh
​
Execute /ora01/app/oraInventory/orainstRoot.sh on the following nodes: 
[oel7]
Execute /ora01/app/oracle/product/19.3.0.0/db_1/root.sh on the following nodes: 
[oel7]
​
Successfully Setup Software.
Moved the install session logs to:
 /ora01/app/oraInventory/logs/InstallActions2019-06-07_11-13-06AM
  • Oracle的警告需要8GB RAM,但VirtualBoxVideomeMory消耗了128MB。

root用户运行下面2个脚本

[root@oel7 /]# 
/ora01/app/oraInventory/orainstRoot.sh
/ora01/app/oracle/product/19.3.0.0/db_1/root.sh

快速进行确认

[oracle@oel7 db_1]$ sqlplus / as sysdba
​
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 7 11:17:42 2019
Version 19.3.0.0.0
​
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
​
Connected to an idle instance.
​
SQL>

配置oracle net

cd /ora01/app/oracle/product/19.3.0.0/db_1/assistants/netca
cp netca.rsp netca.rsp.bck

您可以编辑netca.rsp以设置自己的参数。 我没有改变任何东西。所以都是标准配置。它将使用标准设置配置侦听器。

netca -silent -responseFile /ora01/app/oracle/product/19.3.0.0/db_1/assistants/netca/netca.rsp
netca -silent -responseFile /ora01/app/oracle/product/19.3.0.0/db_1/assistants/netca/netca.rsp
​
Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /ora01/app/oracle/product/19.3.0.0/db_1/assistants/netca/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /ora01/app/oracle/product/19.3.0.0/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

检查监听LISTENER 状态

[oracle@oel7 db_1]$ lsnrctl status
​
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 07-JUN-2019 11:32:53
​
Copyright (c) 1991, 2019, Oracle.  All rights reserved.
​
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oel7.dbaora.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                07-JUN-2019 11:28:40
Uptime                    0 days 0 hr. 4 min. 13 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /ora01/app/oracle/product/19.3.0.0/db_1/network/admin/listener.ora
Listener Log File         /ora01/app/oracle/diag/tnslsnr/oel7/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel7)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
​

配置数据库

最后一个配置是创建oracle19c 容器 准备数据库数据文件和闪存恢复区域的目录

mkdir /ora01/app/oracle/oradata
mkdir /ora01/app/oracle/flash_recovery_area

为dbca备份初始的文件

cd /ora01/app/oracle/product/19.3.0.0/db_1/assistants/dbca
​
cp dbca.rsp dbca.rsp.bck
vi dbca.rsp

以下是我的配置

--------------------------------------------
-- global database name
--------------------------------------------
gdbName=ORA19C.dbaora.com
​
--------------------------------------------
-- instance database name
--------------------------------------------
sid=ORA19C
​
--------------------------------------------
--create container database
--------------------------------------------
createAsContainerDatabase=true
​
--------------------------------------------
-- number of pluggable databases
--------------------------------------------
numberOfPDBs=1
​
--------------------------------------------
-- list of pluggable databases
--------------------------------------------
pdbName=PORA19C1
​
-------------------------------------------- 
-- Flag to create local undo tablespace for all PDB's.
-------------------------------------------- useLocalUndoForPDBs=true
​
--------------------------------------------
-- pluggable administrator password
--------------------------------------------
pdbAdminPassword=Oracle19c#
​
--------------------------------------------
-- template name used to create database
--------------------------------------------
templateName=General_Purpose.dbc
​
--------------------------------------------
-- password for user sys
--------------------------------------------
sysPassword=Oracle19c#
​
--------------------------------------------
-- password for user system
--------------------------------------------
systemPassword=Oracle19c#
​
--------------------------------------------
-- configure dbexpress with port 5500
--------------------------------------------
emConfiguration=DBEXPRESS
emExpressPort=5510
​
--------------------------------------------
-- password for dbsnmp user
--------------------------------------------
dbsnmpPassword=Oracle19c#
​
--------------------------------------------
-- default directory for oracle database datafiles
--------------------------------------------
datafileDestination=/ora01/app/oracle/oradata
​
--------------------------------------------
-- default directory for flashback data
--------------------------------------------
recoveryAreaDestination=/ora01/app/oracle/flash_recovery_area
​
--------------------------------------------
-- storage used for database installation
-- FS - OS filesystem
--------------------------------------------
storageType=FS
​
--------------------------------------------
-- database character set
--------------------------------------------
characterSet=AL32UTF8
​
--------------------------------------------
-- national database character set
--------------------------------------------
nationalCharacterSet=AL16UTF16
​
--------------------------------------------
-- listener name to register database to
--------------------------------------------
listeners=LISTENER
​
--------------------------------------------
-- force to install sample schemas on the database
--------------------------------------------
sampleSchema=true
​
--------------------------------------------
--specify database type
--has influence on some instance parameters
--------------------------------------------
databaseType=OLTP
​
--------------------------------------------
-- defines size of memory used by the database
--------------------------------------------
totalMemory=4096

运行数据库安装

dbca -silent -createDatabase \
-responseFile /ora01/app/oracle/product/19.3.0.0/db_1/assistants/dbca/dbca.rsp

输出如下

[oracle@oel7 dbca]$ dbca -silent -createDatabase \
> -responseFile /ora01/app/oracle/product/19.3.0.0/db_1/assistants/dbca/dbca.rsp
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /ora01/app/oracle/cfgtoollogs/dbca/ORA19C.
Database Information:
Global Database Name:ORA19C.dbaora.com
System Identifier(SID):ORA19C
Look at the log file "/ora01/app/oracle/cfgtoollogs/dbca/ORA19C/ORA19C.log" for further details.

验证连接

[oracle@oel7 dbca]$ sqlplus / as sysdba
​
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jun 8 02:35:22 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 parameter db_name
​
NAME        TYPE        VALUE
--------------- ----------- ------------------------------
db_name         string      ORA19C
​
SQL> alter session set container=PORA19C1;
​
Session altered.
​
SQL> show con_id
​
CON_ID
------------------------------
3
SQL> show con_name
​
CON_NAME
------------------------------
PORA19C1
SQL>

检查端口状态

SQL> ALTER SESSION SET CONTAINER=cdb$root;
​
Session altered.
​
SQL> select DBMS_XDB_CONFIG.GETHTTPSPORT from dual;
​
GETHTTPSPORT
------------
    5510
​
SQL>

至此,Oracle数据库安装完毕


修改默认端口

由于刚才的监听设置是默认监听端口1521,现在为了安全考虑,将他变更为 115211。

  1. 首先修改$ORACLE_HOME$/network/admin/listener.ora这个文件。

# listener.ora Network Configuration File: /ora01/app/oracle/product/19.3.0.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
​
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      # change port 1521 to 115211
      (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.dbaora.com)(PORT = 115211))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
​
  1. 修改ORACLE_HOME/network/admin/tnsnames.ora这个文件。(这个文件不修改,数据库重新启动会报错:tns-12542;tns-12560)

# tnsnames.ora Network Configuration File: /ora01/app/oracle/product/19.3.0.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
​
ORA19C =
  (DESCRIPTION =
# change port 1521 to 115211
    (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.dbaora.com)(PORT = 115211))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA19C.dbaora.com)
    )
  )
​
LISTENER_ORA19C =
  (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.dbaora.com)(PORT = 115211))
​
  1. 管理员身份修改local_listener参数

alter system set local_listener='(address=(protocol=tcp)(host=oel7.dbaora.com)(port=115211))';
  1. 退出sql,启动监听服务,查看监听的端口。

[root@oel7 ~]# su - oracle
Last login: Wed Jan  5 20:24:41 CST 2022 on pts/0
ORACLE_UNQNAME=ORA19C
ORACLE_SID=ORA19C
ORACLE_BASE=/ora01/app/oracle
ORACLE_HOSTNAME=oel7.dbaora.com
ORACLE_HOME=/ora01/app/oracle/product/19.3.0.0/db_1
[oracle@oel7 ~]$ netstat -an|grep 11521
tcp        0      0 10.0.5.3:34274          10.0.5.3:115211          ESTABLISHED
tcp6       0      0 :::115211                :::*                    LISTEN     
tcp6       0      0 10.0.5.3:115211          10.0.5.3:34274          ESTABLISHED
​

至此,oracle端口重新配置完毕。 firewalld 中加入刚才开放的端口

firewall-cmd --zone=public --add-port=115211/tcp --permanent  
  • 记得在腾讯云上安全配置中开放115211这个端口

最后的最后,禁止远程登陆sysdba用户。

alter system set remote_login_passwordfile=none scope=spfile;


0

评论区