安装环境
系统:Linux CentOS7 64位
Oracle版本:Oracle 12C
一、安装前准备
1、创建运行oracle数据库的系统用户和用户组
[root@bogon ~]# groupadd oinstall
[root@bogon ~]# groupadd dba
[root@bogon ~]# useradd -g oinstall -g dba -m oracle
[root@bogon ~]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bogon ~]# id oracle
uid=1001(oracle) gid=1002(dba) groups=1002(dba)
2、修改/etc/sysctl.conf
文件,输入命令:vi /etc/sysctl.conf
,将下列内容加入该文件。
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
使用/sbin/sysctl -p
命令使 sysctl.conf 配置生效。
3、修改操作系统核心参数
输入命令:vi /etc/security/limits.conf
,将下列内容加入该文件。
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
4.、修改/etc/pam.d/login
文件,输入命令:vi /etc/pam.d/login
,将下列内容加入该文件。
session required /lib/security/pam_limits.so
session required pam_limits.so
5、 编辑 /etc/profile
,输入命令:vi /etc/profile
,将下列内容加入该文件。
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
export DISPLAY=:0.0
[root@bogon ~]# source /etc/profile
[root@bogon ~]# export DISPLAY=:0.0
[root@bogon ~]# xhost +
access control disabled, clients can connect from any host
6、创建数据库软件目录和数据文件存放目录,注意磁盘空间即可,这里我放到oracle用户下,输入如下命令
[root@bogon ~]# mkdir /home/oracle/app
[root@bogon ~]# mkdir /home/oracle/app/oracle
[root@bogon ~]# mkdir /home/oracle/app/oradata
[root@bogon ~]# mkdir /home/oracle/app/oracle/product
7、更改目录属主为 oracle 用户所有,输入命令:
[root@bogon ~]# chown -R oracle:oinstall /home/oracle/app
8、切换为oracle用户登录
su - oracle
9、配置 oracle 用户环境变量
编辑 bash_profile
,输入命令:vi .bash_profile
,添加如下环境变量
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/12.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
[oracle@bogon ~]$ source .bash_profile
10、切换为 root 用户,关闭 selinux
su root
# 修改/etc/selinux/config文件 vi /etc/selinux/config
修改SELINUX
为disabled,如下:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
二、软件包依赖
安装oracle之前需要许多软件包依赖,如果可用外网,使用如下命令安装。
yum install binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel compat-libcap1.x86_64 0:1.10-7.el7
查看这些软件包版本,可使用如下命令,如有未安装的会有提示。
rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
如果 compat-libstdc++ 安装提示No package compat-libstdc++ available.
,请使用命令yum install compat-libstdc++-33
安装。
使用rpm -qa | grep "compat-libstdc"
可查看。
三、安装
官网下载地址:Database Software Downloads | Oraclehttps://www.oracle.com/database/technologies/oracle-database-software-downloads.html#11g,这里下载12C版本,两个包都下载,放在/home/oracle/a