Centos7安装oracle12c

ping www.baidu.com

Centos7安装oracle12c_第1张图片

一下步

将主机命名为c120
hostnamectl set-hostname c120

Centos7安装oracle12c_第2张图片

vi /etc/hosts
#添加如下内容
192.168.3.1 c120 #IP +主机名
oracle12c安装前的环境配置
#在最后添加如下内容

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

sysctl -p

Centos7安装oracle12c_第3张图片

#在最后添加如下内容
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
安装依赖包,耐心等它跑完就行
yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install make -y
yum install nfs-utils -y
yum install net-tools -y
yum install smartmontools -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y

Centos7安装oracle12c_第4张图片

#创建安装oracle12c需要的用户组和用户,oinstall组用于安装数据库,dba组用于管理数据库,-g表示这个用户的主组,-G标识这个用户的其它组
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper

useradd -u 54321 -g oinstall -G dba,oper oracle

passwd oracle

Centos7安装oracle12c_第5张图片

#设置SELINUX
vi /etc/selinux/config

#该更内容 SELINUX=permissive

setenforce Permissive
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
#创建Oracle安装目录
mkdir -p /usr/local/products/oracle12c
chown -R oracle:oinstall /usr/local
chmod -R 775 /usr/local/

Centos7安装oracle12c_第6张图片

#切换到oracle用户
su - oracle
#在最后添加如下内容
vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=solang
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/usr/local/products
export ORACLE_HOME=$ORACLE_BASE/oracle12c
export ORACLE_SID=cdb1

export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
#立即生效
source .bash_profile
echo $ORACLE_HOME

 yum - y install unzip

下载地址https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

将oracle12c压缩包上传到  /home/oracle 目录下

yum -y install unzip
unzip linuxx64_12201_database.zip

Centos7安装oracle12c_第7张图片

Centos7安装oracle12c_第8张图片

cd database/response/

vi db_install.rsp #编辑的时候可能没有权限解决办法如 su 切换到root 对文件授权chmod -R 775 /home/oracle/database/response/db_install.rsp   #chmod -R 775 绝对路径/文件

#编辑db_install.rsp,对应修改
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/usr/local/oraInventory
ORACLE_HOME=/usr/local/products/oracle12c
ORACLE_BASE=/usr/local/products
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba

Centos7安装oracle12c_第9张图片

# su - oracle 在oracle用户下操作
cd ~/database

#静默安装oracle12c
./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforesponseFile /home/oracle/database/response/db_install.rsp
或者
./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion \ -showProgress -silent -responseFile /home/oracle/database/response/db_install.rsp

Centos7安装oracle12c_第10张图片

Centos7安装oracle12c_第11张图片

#切换到root用户
su
/usr/local/oraInventory/orainstRoot.sh
/usr/local/products/oracle12c/root.sh

Centos7安装oracle12c_第12张图片

#oracle数据库软件安装成功
su - oracle
sqlplus / as sysdba

Centos7安装oracle12c_第13张图片

#数据库创建,使用数据库配置助手DBCA静默模式下创建数据库,看不懂则看下图
dbca -silent -createDatabase \
 -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \
 -gdbname cdb1 -sid cdb1 -responseFile /home/oracle/database/response/dbca.rsp \
 -characterSet AL32UTF8 \
 -sysPassword OraPasswd1 \
 -systemPassword OraPasswd1 \
 -createAsContainerDatabase true \
 -numberOfPDBs 1 \
 -pdbName pdb1 \
 -pdbAdminPassword OraPasswd1 \
 -automaticMemoryManagement false \
 -ignorePreReqs

Centos7安装oracle12c_第14张图片

sqlplus / as sysdba
select status from v$instance;  #如图数据库创建成功

Centos7安装oracle12c_第15张图片

#配置监听,使用默认的netca.rsp文件
netca -silent -responseFile /home/oracle/database/response/netca.rsp

Centos7安装oracle12c_第16张图片

修改为本机的主机名和oracle对应端口1521
su 切换到root授权listener.ora
chmod -R 775 /usr/local/products/oracle12c/network/admin/listener.ora
su - oracle
vi /usr/local/products/oracle12c/network/admin/listener.ora
lsnrctl status

#启动和关闭监听
lsnrctl start
lsnrctl stop

Centos7安装oracle12c_第17张图片

Centos7安装oracle12c_第18张图片

Centos7安装oracle12c_第19张图片

#将N修改为Y
vi /etc/oratab
vi /etc/init.d/dbora
#修改如下

#! /bin/sh
# description: Oracle auto start-stop script.
#
# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORACLE_HOME.

ORACLE_HOME=/usr/local/products/oracle12c
ORA_OWNER=oracle

case "$1" in
'start') 
    # Start the Oracle databases:
    # The following command assumes that the oracle login
    # will not prompt the user for any values
    # Remove "&" if you don't want startup as a background process.
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
    touch /var/lock/subsys/dbora
    ;;

'stop')
    # Stop the Oracle databases:
    # The following command assumes that the oracle login
    # will not prompt the user for any values
    su - $ORA_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
    rm -f /var/lock/subsys/dbora
    ;;
esac

export ORA_OWNER=oracle
echo $ORA_OWNER     #ORA_OWNER设置为oracle用户

Centos7安装oracle12c_第20张图片

#修改dbora组和文件权限
chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbor
#创建符号链接
ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

#Oracle数据库开机自动启动,在oracle用户中单独启动和关闭数据库

$ORACLE_HOME/bin/dbstart $ORACLE_HOME
$ORACLE_HOME/bin/dbshut $ORACLE_HOME

Centos7安装oracle12c_第21张图片

Centos7安装oracle12c_第22张图片

你可能感兴趣的:(数据库,oracle,数据库)