Centos 8.5 Oracle12c安装

2023-12-21 06:43:37

由于多次安装踩坑,所以本次写了一份12c安装的完整版。可以直接使用。

一、安装数据库基本信息

名称

主机名

database

操作系统

CentOS Linux release 8.5.2111

Oracle用户名/密码

oracle

Oracle 版本

12c Enterprise Edition Release 12.2.0.1.0

oracle用户SID

orcl

PdbSID

orclpdb

ORACLE_BASE

/data/app/oracle

ORACLE_HOME

/data/app/oracle/product/12.2.0/db_1

IP

192.168.49.148/24

二、安装前环境准备

  1. 安装JDK

jdk上传到/tmp

tar? -zxvf? /tmp/openjdk-11+28_linux-x64_bin.tar.gz?? -C? /opt/

echo "export JAVA_HOME=/opt/jdk-11

export PATH=\$JAVA_HOME/bin:\$PATH" >> ~/.bash_profile

. ~/.bash_profile

  1. 关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service ?#禁止firewall开机启动

systemctl status firewalld.service #查看firewall状态

  1. 修改主机名称

#/etc/hosts

echo "192.168.49.148 database">> /etc/hosts

#/etc/hostname

echo "database" > /etc/hostname

#/etc/sysconfig/network

echo "database" >> /etc/sysconfig/network

执行reboot重启环境

  1. 关闭selinux

改为SELINUX=disabled

sed -i 's/enforcing/disabled/g' /etc/selinux/config

  1. 修改阿里源(此处可不做)

备份原有的yum源文件,以便需要时恢复:

mv /etc/yum.repos.d/CentOS-* /tmp/

下载并安装阿里云的CentOS 8源配置文件

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

清理缓存

yum clean all

执行以下命令生成缓存

yum makecache

  1. 安装依赖

yum -y install binutils

yum -y install gcc

yum -y install gcc-c++

yum -y install glibc

yum -y install glibc.i686

yum -y install glibc-devel

yum -y install glibc-devel.i686

yum -y install ksh

yum -y install libgcc

yum -y install libgcc.i686

yum -y install libstdc++

yum -y install libstdc++.i686

yum -y install libstdc++-devel

yum -y install libstdc++-devel.i686

yum -y install libaio

yum -y install libaio.i686

yum -y install libaio-devel

yum -y install libaio-devel.i686

yum -y install libXext

yum -y install libXext.i686

yum -y install libX11

yum -y install libX11.i686

yum -y install libxcb

yum -y install libxcb.i686

yum -y install libXi

yum -y install libXi.i686

yum -y install make sysstat

yum -y install libnsl.x86_64

  1. 检查依赖

rpm -q? binutils \

gcc \

gcc-c++ \

glibc \

glibc.i686 \

glibc-devel \

glibc-devel.i686 \

ksh \

libgcc \

libgcc.i686\

libstdc++ \

libstdc++.i686 \

libstdc++-devel \

libstdc++-devel.i686 \

libaio \

libaio.i686 \

libaio-devel \

libaio-devel.i686 \

libXext \

libXext.i686 \

libX11 \

libX11.i686 \

libxcb \

libxcb.i686 \

libXi \

libXi.i686 \

make sysstat \

libnsl.x86_64

  1. 用户/组配置

groupadd oinstall

groupadd oper

groupadd dba

groupadd backupdba

groupadd dgdba

groupadd kmdba

groupadd racdba

  1. 创建oracle用户

useradd -g oinstall -G oper,dba,backupdba,dgdba,kmdba,racdba -p `openssl passwd -1 "oracle"` -d /home/oracle oracle

  1. 环境变量设置

当前用户下(可不执行)

echo "export ORACLE_BASE=/data/app/oracle

export ORACLE_HOME=/data/app/oracle/product/12.2.0/db_1

export ORACLE_SID=orcl

# sqlplus 使用的一些.so文件

export LD_LIBRARY_PATH=\$ORACLE_HOME/stage/ext/lib

PATH=\$PATH:\$HOME/.local/bin:\$HOME/bin:\$ORACLE_HOME/bin

export PATH " >> ~/.bash_profile

. ~/.bash_profile

Oracle用户下:

su - oracle

echo "export ORACLE_BASE=/data/app/oracle

export ORACLE_HOME=/data/app/oracle/product/12.2.0/db_1

export ORACLE_SID=orcl

# sqlplus 使用的一些.so文件

export LD_LIBRARY_PATH=\$ORACLE_HOME/stage/ext/lib

PATH=\$PATH:\$HOME/.local/bin:\$HOME/bin:\$ORACLE_HOME/bin

export PATH " >> ~/.bash_profile

. ~/.bash_profile

  1. 内核参数

shmall=$(echo "`cat /proc/meminfo | grep "MemTotal" | awk '{print $2}'` / (`getconf PAGESIZE` / 1024)" | bc)

shmmax=$(echo "`cat /proc/meminfo | grep "MemTotal" | awk '{print $2}'` * 1024 * 0.8" | bc? | sed 's#\..*$##')

cat << EOF > /etc/sysctl.conf

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

sysctl -p

  1. 用户资源

修改/etc/security/limits.conf

cat << EOF > /etc/security/limits.conf

oracle?? soft?? nproc??? 131072

oracle?? hard?? nproc??? 131072

oracle?? soft?? nofile?? 131072

oracle?? hard?? nofile?? 131072

oracle?? soft?? stack??? 10240

oracle?? hard?? stack??? 32768

oracle?? soft?? memlock? 50000000

oracle?? hard?? memlock? 50000000

EOF

Login添加oracle信息

echo "session required /lib64/security/pam_limits.so

session required pam_limits.so" >> /etc/pam.d/login

三、oracle安装

  1. 解压12c安装包

建议安装文件放到/tmp

unzip? linuxx64_12201_database.zip

  1. 文件夹准备

mkdir -p /data/app/oracle/product/12.2.0/db_1

chown -R oracle:oinstall /data

安装:安装直接解压到database目录即可,进入database目录,用oracle用户运行

  1. 安装数据库

su? -? oracle

cd? /tmp/database/

./runInstaller -silent -force \

oracle.install.option=INSTALL_DB_SWONLY \

UNIX_GROUP_NAME=oinstall \

INVENTORY_LOCATION=/data/app/oraInventory \

ORACLE_HOME=/data/app/oracle/product/12.2.0/db_1 \

ORACLE_BASE=/data/app/oracle \

oracle.install.db.InstallEdition=EE \

oracle.install.db.isCustomInstall=false \

oracle.install.db.DBA_GROUP=dba \

oracle.install.db.OPER_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 \

DECLINE_SECURITY_UPDATES=true

  1. root.sh:运行root2个脚本(root用户)

su? -

/data/app/oraInventory/orainstRoot.sh

/data/app/oracle/product/12.2.0/db_1/root.sh

  1. 创建并启动监听

su? - oracle

cd $ORACLE_HOME

netca -silent -responseFile `pwd`/assistants/netca/netca.rsp

  1. 查看状态

lsnrctl status

三、初始化实例(二选一)

方法一:使用资源文件

编辑assistants/dbca/dbca.rsp

gdbName=

SID=

templateName=General_Purpose.dbc

sysPassword=

systemPassword=

characterSet=

nationalCharacterSet=

初始化数据库

dbca -createdatabase -silent -responseFile `pwd`/assistants/dbca/dbca.rsp

方法二:使用命令参数

多租户(二选一,本次使用该配置)

dbca -silent -createDatabase \

?-templateName General_Purpose.dbc \

?-gdbname orcl -sid orcl -responseFile NO_VALUE \

?-characterSet AL32UTF8 \

?-sysPassword oracle \

?-systemPassword oracle \

?-createAsContainerDatabase true \

?-numberOfPDBs 1 \

?-pdbName orclpdb \

?-pdbAdminPassword oracle \

?-databaseType MULTIPURPOSE \

?-memoryMgmtType auto_sga \

?-totalMemory 1536 \

?-storageType FS \

?-datafileDestination "/data/app/oracle/oradata/" \

?-redoLogFileSize 50 \

?-emConfiguration NONE \

?-ignorePreReqs

注意:此处提示是密码设置过于简单,忽略。

简单配置(二选一,不带PDB库)

dbca -silent -createDatabase \

?-templateName General_Purpose.dbc \

?-gdbname orcl -sid orcl -responseFile NO_VALUE \

?-characterSet AL32UTF8 \

?-sysPassword oracle \

?-systemPassword oracle \

?-emConfiguration NONE \

?-ignorePreReqs

文章来源:https://blog.csdn.net/huijieshizhu0/article/details/135065655
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。