CentOS7下Oracle安装

OracleLinux安装Oracle

一、准备工作

1.打开终端,输入命令 groupadd oinstall 创建用户组

CentOS7下Oracle安装

2.输入命令 groupadd dba 创建用户组dba

CentOS7下Oracle安装

3.输入命令 useradd -g oinstall -g dba -m oracle 创建oracle用户,并加入到oinstall和dba用户组

CentOS7下Oracle安装

4.输入命令 passwd oracle 设置oracle用户的登录密码

CentOS7下Oracle安装

5.输入命令 id oracle 查看创建的oracle用户

 

CentOS7下Oracle安装

6.输入命令 mkdir -p /data/oracle ,创建oracle数据库安装目录

CentOS7下Oracle安装

7.输入 mkdir -p /data/oraInventory ,创建oracle数据库配置文件目录

CentOS7下Oracle安装

8.输入命令 mkdir -p /data/database ,创建oracle数据库软件包解压目录

CentOS7下Oracle安装

9.输入命令 chown -R oracle:oinstall /data/oracle ,设置目录所有者为oinstall用户组的oracle用户

CentOS7下Oracle安装

10.输入命令 chown -R oracle:oinstall /data/oraInventory ,设置目录所有者为oinstall用户组的oracle用户

 

CentOS7下Oracle安装

11.输入命令 chown -R oracle:oinstall /data/database ,设置目录所有者为oinstall用户组的oracle用户

CentOS7下Oracle安装

12.输入命令 systemctl status firewalld.service ,查看防火墙状态

CentOS7下Oracle安装

13.输入命令 systemctl stop firewalld.service ,关闭防火墙

CentOS7下Oracle安装

14. 输入命令 systemctl status firewalld.service,再次查看状态,防火墙已关闭

CentOS7下Oracle安装

15.输入命令 systemctl disable firewalld.service ,禁止启动后防火墙再次开启

CentOS7下Oracle安装

16.输入命令 vi /etc/selinux/config ,修改selinux配置文件

CentOS7下Oracle安装

17.将下图位置修改为 disabled

CentOS7下Oracle安装

18.按ESC,然后输入 :wq!,保存退出

CentOS7下Oracle安装

19.输入命令 vi /etc/sysctl.conf ,编辑文件

CentOS7下Oracle安装

20.将以下内容复制进文件,按ESC,:wq!,保存退出

net.ipv4.icmp_echo_ignore_broadcasts = 1

net.ipv4.conf.all.rp_filter = 1

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 #可使用的IPv4端口范围

net.core.rmem_default = 262144

net.core.rmem_max= 4194304

net.core.wmem_default= 262144

net.core.wmem_max= 1048576

CentOS7下Oracle安装

21.输入命令 sysctl -p 使配置生效

CentOS7下Oracle安装

22.输入命令 vi /etc/security/limits.conf ,对oracle用户设置限制,提高软件运行性能

CentOS7下Oracle安装

23.在文件末尾,加入以下内容,按ESC,:wq!保存退出

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

CentOS7下Oracle安装

24.输入命令 vi /home/oracle/.bash_profile ,编辑环境变量

CentOS7下Oracle安装

25.在文件末尾加入以下内容,按ESC,:wq!,保存退出

export ORACLE_BASE=/data/oracle #oracle数据库安装目录

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle数据库路径

export ORACLE_SID=orcl #oracle启动数据库实例名

export ORACLE_TERM=xterm #xterm窗口模式安装

export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量

export LANG=C #防止安装过程出现乱码

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK  #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致

CentOS7下Oracle安装

26.输入命令 source /home/oracle/.bash_profile ,使文件生效

CentOS7下Oracle安装

27.输入命令 rpm -q binutils compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat  查看缺少的软件包

CentOS7下Oracle安装

28.输入命令 yum -y install libstdc++ 安装缺少的软件包

CentOS7下Oracle安装

CentOS7下Oracle安装

       这里若出现以下问题,输入命令 rm -rf /var/run/yum.pid 强制解锁yum

CentOS7下Oracle安装

       若出现以下问题,输入命令 yum clean all 回车,若还不可以,再输入 yum makecache 回车,清理yum缓存

CentOS7下Oracle安装

29. 输入命令 yum -y install ksh 安装缺少的软件包

CentOS7下Oracle安装

CentOS7下Oracle安装

30. 输入命令 yum -y install libaio-devel安装缺少的软件包

CentOS7下Oracle安装

CentOS7下Oracle安装

31.输入命令 reboot 重新启动,然后用oracle用户登陆系统

CentOS7下Oracle安装

 

二、开始安装

1.将oracle的两个安装包拖入 /data/database/ 目录

CentOS7下Oracle安装

2.打开终端,进入 /data/database 目录,输入命令 unzip 软件包名 解压第一个压缩包

CentOS7下Oracle安装

3.输入命令 unzip 软件包名 解压第二个压缩包

CentOS7下Oracle安装

4.进入 /data/database/database/ 目录,输入命令 export LANG="en_US" ,防止乱码

CentOS7下Oracle安装

5.输入命令 ./runInstaller ,运行安装程序

CentOS7下Oracle安装

6.将勾点掉,点Next

CentOS7下Oracle安装

7.点击yes

CentOS7下Oracle安装

8.选第一项,点击Next

CentOS7下Oracle安装

9.目前个人用,选择桌面版,点击Next,如果是公司服务器用,选择服务端版

CentOS7下Oracle安装

10.输入密码和确认密码,然后店即将Next

CentOS7下Oracle安装

11.这里提示密码不是很复杂,点击yes跳过

CentOS7下Oracle安装

12.点击Next

CentOS7下Oracle安装

13.执行先决条件检查

CentOS7下Oracle安装

14.检查之后,结果是交换空间大小出现警告

CentOS7下Oracle安装

15. 输入命令 free –m 查看当前虚拟内存

CentOS7下Oracle安装

16. 输入命令su切换到root用户,输入命令 dd if=/dev/zero of=/home/swap bs=1024 count=1024000 将虚拟内存调大

 

CentOS7下Oracle安装

17. 输入命令 mkswap /home/swap,设置交换空间大小

CentOS7下Oracle安装

18. 输入命令 swapon /home/swap 增加并启用内存

CentOS7下Oracle安装

19. 输入命令 free –m 再次查看,交换空间变大

CentOS7下Oracle安装

20.关闭终端,点击Check Again,再次检查,先决条件全部通过

CentOS7下Oracle安装

21.点击 Install

CentOS7下Oracle安装

22.等待安装

CentOS7下Oracle安装

23.提示需要运行2个脚本,列出了脚本的名称和位置

CentOS7下Oracle安装

24.打开终端,输入 su ,切换到root用户,输入命令 . /data/oraInventory/orainstRoot.sh 执行第一个脚本

CentOS7下Oracle安装

25. 输入命令 . /data/oracle/product/11.2.0/db_1/root.sh 执行第二个脚本

CentOS7下Oracle安装

26.点击回车

CentOS7下Oracle安装

27.点击回车

CentOS7下Oracle安装

28.关闭终端后,点击OK

CentOS7下Oracle安装

29.另外,可能出现如下问题,如未出现继续看下一步,出现这个问题是oracle在64位电脑一个bug,oracle11已经有解决此问题的脚本了,目前oracle12还没有脚本解决此问题,如果是oracle11出现下列问题,用如下方式解决:

CentOS7下Oracle安装

首先将脚本的zip上传到linux服务器,输入命令 unzip 脚本包名 解压,将脚本解压到当前目录,会出现一个8670579文件夹

CentOS7下Oracle安装

输入命令 cd $ORACLE_HOME/OPatch 进入目录

CentOS7下Oracle安装

输入命令 ./opatch apply /data/database/8670579/ 执行脚本,这里注意,/data/database/为/8670579/的目录,如目录不为此处,则更改路径

CentOS7下Oracle安装

 

30.点击Skip跳过此问题

CentOS7下Oracle安装

31.等待数据库实例的安装

CentOS7下Oracle安装

32.如果不配置登陆的用户,直接点击OK即可,若需要配置,点击Password Management配置

CentOS7下Oracle安装

33.安装完成,点击Next

CentOS7下Oracle安装

34.点击Close

CentOS7下Oracle安装

35.打开终端,输入 sqlplus /nolog 进入sqlplus

CentOS7下Oracle安装

       这里注意,如果系统重启,用root账户是无法登陆sqlplus的,要输入命令 su – oracle ,切换到oracle用户登陆数据库,如下所示

CentOS7下Oracle安装

36.输入命令 conn /as sysdba ,以DBA身份连接数据库实例

CentOS7下Oracle安装

       这里注意,如果系统重启,数据库实例会关闭,输入以上命令,会出现如下情况

CentOS7下Oracle安装

       此时输入命令 startup 启动数据库实例,然后再进行连接即可,如下所示

CentOS7下Oracle安装

37.输入语句 select to_char(sysdate,'yyyy-mm-dd') from dual; ,查询系统当前时间,证明数据库安装完成

CentOS7下Oracle安装

38.输入 exit 退出数据库

CentOS7下Oracle安装