温馨提示×

centos怎么安装oracle

小樊
41
2026-10-11 18:23:12
栏目: 云计算

在 CentOS 上安装 Oracle Database(以 Oracle 11g / 12c / 19c 为例,最常用的是 19c)是一个比较复杂的流程,下面给你一个通用、清晰的安装步骤指南(以 Oracle 19c + CentOS 7/8 为例,其他版本类似)。


一、安装前准备

1. 系统要求

  • CentOS 7.x / 8.x(推荐 7.9)
  • 内存 ≥ 2GB(生产建议 ≥ 4GB)
  • 磁盘 ≥ 20GB
  • swap ≥ 内存大小(或至少 2GB)

2. 关闭防火墙和 SELinux

systemctl stop firewalld
systemctl disable firewalld

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

3. 配置主机名和 hosts

hostnamectl set-hostname oracle19c
vi /etc/hosts

添加:

192.168.1.100 oracle19c

二、安装依赖包

yum install -y \
binutils \
compat-libcap1 \
compat-libstdc++-33 \
gcc \
gcc-c++ \
glibc \
glibc-devel \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unzip \
elfutils-libelf-devel

三、创建 Oracle 用户和组

groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

四、修改系统内核参数

vi /etc/sysctl.conf

添加:

fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
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

执行:

sysctl -p

五、设置用户限制

vi /etc/security/limits.conf

添加:

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

六、创建安装目录

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

七、配置 Oracle 环境变量

切换到 oracle 用户:

su - oracle
vi ~/.bash_profile

添加:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH

生效:

source ~/.bash_profile

八、上传并解压 Oracle 安装包

Oracle 19c 安装包(如 LINUX.X64_193000_db_home.zip):

cd $ORACLE_HOME
unzip LINUX.X64_193000_db_home.zip

九、开始安装

方式一:图形界面(推荐新手)

cd $ORACLE_HOME
./runInstaller

方式二:静默安装(服务器常用)

./runInstaller -silent \
-responseFile $ORACLE_HOME/install/response/db_install.rsp

安装完成后按提示执行:

/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/19.3.0/dbhome_1/root.sh

十、创建数据库

dbca

或使用静默:

dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname orcl -sid orcl \
-characterSet AL32UTF8

十一、启动与验证

sqlplus / as sysdba
startup;

查看版本:

select * from v$version;

常见问题

  • swap 不足 → 无法安装
  • 依赖缺失 → runInstaller 会提示
  • 中文乱码 → 使用 AL32UTF8
  • 监听问题 → lsnrctl start

如果你告诉我:

  • CentOS 版本(7 / 8 / 9)
  • Oracle 版本(11g / 12c / 19c)
  • 是否图形界面 / 服务器

我可以给你更精确的一步到位方案,甚至 一键脚本。

0 踩