在 CentOS 上配置 Oracle 数据库(以 Oracle 19c / 18c / 11g 常见场景为例)通常包括:系统准备 → 安装依赖 → 创建用户 → 修改内核参数 → 安装 Oracle → 建库 → 配置自启。下面给你一份通用、可落地的配置指南(以 Oracle 19c 为例,其他版本类似)。
cat /etc/redhat-release
free -h
df -h
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
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 \
unixODBC unixODBC-devel
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
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
编辑 /etc/sysctl.conf:
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmax = 4294967295
kernel.shmall = 1073741824
kernel.shmmni = 4096
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
生效:
sysctl -p
编辑 /etc/security/limits.conf:
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
切换到 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
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
生效:
source ~/.bash_profile
LINUX.X64_193000_db_home.zip)$ORACLE_HOMEcd $ORACLE_HOME
./runInstaller
按图形界面:
安装完成后执行:
/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 \
-responseFile NO_VALUE \
-characterSet AL32UTF8 \
-totalMemory 2048
sqlplus / as sysdba
SQL> startup
SQL> shutdown immediate
监听:
lsnrctl start
lsnrctl status
编辑 /etc/oratab:
orcl:/u01/app/oracle/product/19.3.0/dbhome_1:Y
| 问题 | 解决 |
|---|---|
| Cannot open display | 使用 X11 或 VNC |
| INS-30131 | 权限或目录错误 |
| ORA-00845 | /dev/shm 太小 |
| 中文乱码 | 字符集用 AL32UTF8 |
如果你告诉我:
我可以给你更精确的一步到位配置脚本。