当前位置: 移动技术网 > IT编程>数据库>Oracle > CentOS7安装Oracle11gR2的图文教程

CentOS7安装Oracle11gR2的图文教程

2018年10月03日  | 移动技术网IT编程  | 我要评论

青峰写的歌,企业价值观的作用,唐代法曲典范

最近要运维一个项目,准备在家办公,公司无远程作业环境,个人本本不喜欢别人碰,第一次在centos上安装,本案留以后使用,毕竟不是经常安装。

注:oracle11gr2 x64安装

一、环境准备

安装包:

1.vmware-workstation-full-11.1.0-2496824.exe
2.centos-7-x86_64-dvd-1511.iso
3.linux.x64_11gr2_database_1of2.zip
  linux.x64_11gr2_database_2of2.zip

二、安装oracle前准备

1.创建运行oracle的用户和用户组

[sonny@localhost ~]$ su root  #切换到root
password: 
[root@localhost sonny]# groupadd oinstall  #创建用户组oinstall
[root@localhost sonny]# groupadd dba  #创建用户组dba
[root@localhost sonny]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
[root@localhost sonny]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在centos的图形登陆界面没法登陆
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@localhost sonny]# id oracle # 查看新建的oracle用户
uid=1001(oracle) gid=1002(dba) groups=1002(dba)
[root@localhost sonny]# 

为啥要创建oinstall用户组及dba组? 参考:https://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-2-092412-zhs.html#13

理论上单例按照需要3种用户组,实际只建两个oinstall和dba,后面再安装oracle数据库的时候把osoper组也设置是dba组。

a.oracle 清单组(一般为oinstall):
 oinstall 组的成员被视为 oracle 软件的“所有者”,拥有对 oracle 中央清单 (orainventory) 的写入权限。在一个 linux 系统上首次安装 oracle 软件时,
 oui 会创建 /etc/orainst.loc 文件。该文件指定 oracle 清单组的名称(默认为 oinstall)以及 oracle 中央清单目录的路径。
b.数据库管理员(osdba,一般为 dba):
 osdba 组的成员可通过操作系统身份验证使用 sql 以 sysdba 身份连接到一个 oracle 实例。该组的成员可执行关键的数据库管理任务,如创建数据库、启动和关
 闭实例。该组的默认名称为dba。sysdba 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。不要混淆 sysdba 
 系统权限与数据库角色 dba。dba 角色不包括 sysdba 或 sysoper 系统权限。
c.数据库操作员组(osoper,一般为 oper):
 osoper 组的成员可通过操作系统身份验证使用 sql 以 sysoper 身份连接到一个 oracle 实例。这个可选组的成员拥有一组有限的数据库管理权限,如管理和运行备份。
 该组的默认名称为oper。sysoper 系统权限甚至在数据库未打开时也允许访问数据库实例。对此权限的控制完全超出了数据库本身的范围。要使用该组,选择 advanced 安装类型来安装 oracle 数据库软件。

2.创建oracle数据库安装目录

[sonny@localhost ~]$ su root
password: 
[root@localhost sonny]# mkdir -p /data/oracle  #oracle数据库安装目录
[root@localhost sonny]# mkdir -p /data/orainventory  #oracle数据库配置文件目录
[root@localhost sonny]# mkdir -p /data/database  #oracle数据库软件包解压目录
[root@localhost sonny]# cd /data
[root@localhost data]# ls  #创建完毕检查一下(强迫症)
database  oracle  orainventory
[root@localhost data]# chown -r oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
[root@localhost data]# chown -r oracle:oinstall /data/orainventory
[root@localhost data]# chown -r oracle:oinstall /data/database
[root@localhost data]# 

3.修改os系统标识

oracle默认不支持centos系统安装,oracle database 11g release 2 的 os要求参考:https://docs.oracle.com/cd/e11882_01/install.112/e47689/pre_install.htm#ladbi1106

我安装是64位数据库,on linux x86-64:red hatenterprise linux 7 (rhel 7)

另外,centos7.0.1511 基于 rhel7.2 参考:https://www.linuxidc.com/linux/2015-12/126283.htm

修改文件/etc/redhat-release

[sonny@localhost data]$ su root
password: 
[root@localhost data]# cat /proc/version 
linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (red hat 4.8.3-9) (gcc) ) #1 smp thu nov 19 22:10:57 utc 2015
[root@localhost data]# cat /etc/redhat-release  
centos linux release 7.2.1511 (core) 
[root@localhost data]# vi /etc/redhat-release
[root@localhost data]# cat /etc/redhat-release 
redhat-7 
[root@localhost data]# 

4.安装oracle数据库所需要的软件包

重复一遍,我安装时oracle database 11g release 2 64位数据库。

oracle database package requirements for linux x86-64

操作系统:oracle linux 7 and red hat enterprise linux 7
the following packages (or later versions) must be installed:
binutils-2.23.52.0.1-12.el7.x86_64 
compat-libcap1-1.10-3.el7.x86_64 
gcc-4.8.2-3.el7.x86_64 
gcc-c++-4.8.2-3.el7.x86_64 
glibc-2.17-36.el7.i686 
glibc-2.17-36.el7.x86_64 
glibc-devel-2.17-36.el7.i686 
glibc-devel-2.17-36.el7.x86_64 
ksh
libaio-0.3.109-9.el7.i686 
libaio-0.3.109-9.el7.x86_64 
libaio-devel-0.3.109-9.el7.i686 
libaio-devel-0.3.109-9.el7.x86_64 
libgcc-4.8.2-3.el7.i686 
libgcc-4.8.2-3.el7.x86_64 
libstdc++-4.8.2-3.el7.i686 
libstdc++-4.8.2-3.el7.x86_64 
libstdc++-devel-4.8.2-3.el7.i686 
libstdc++-devel-4.8.2-3.el7.x86_64 
libxi-1.7.2-1.el7.i686 
libxi-1.7.2-1.el7.x86_64 
libxtst-1.2.2-1.el7.i686 
libxtst-1.2.2-1.el7.x86_64 
make-3.82-19.el7.x86_64 
sysstat-10.1.5-1.el7.x86_64

老实人,第一次搞,一个一个的安装,命令也很简单,反正文档要求高版本也可以:

[sonny@localhost data]$ su root
password: 
[root@localhost data]# yum install binutils
省略...

5.关闭防火墙centos 7.2默认使用的是firewall作为防火墙

[sonny@localhost /]$ su root
password: 
[root@localhost /]# systemctl status firewalld.service  #查看防火墙状态,运行中
● firewalld.service - firewalld - dynamic firewall daemon
   loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   active: active (running) since thu 2016-04-07 18:54:29 pdt; 2h 20min ago
 main pid: 802 (firewalld)
   cgroup: /system.slice/firewalld.service
           └─802 /usr/bin/python -es /usr/sbin/firewalld --nofork --nopid

apr 07 18:54:25 localhost.localdomain systemd[1]: starting firewalld - dynamic firewall daemon...
apr 07 18:54:29 localhost.localdomain systemd[1]: started firewalld - dynamic firewall daemon.
[root@localhost /]# systemctl stop firewalld.service  #关闭防火墙
[root@localhost /]# systemctl status firewalld.service  #再次查看防火墙状态,发现已关闭
● firewalld.service - firewalld - dynamic firewall daemon
   loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   active: inactive (dead) since thu 2016-04-07 21:15:34 pdt; 9s ago
 main pid: 802 (code=exited, status=0/success)

apr 07 18:54:25 localhost.localdomain systemd[1]: starting firewalld - dynamic firewall daemon...
apr 07 18:54:29 localhost.localdomain systemd[1]: started firewalld - dynamic firewall daemon.
apr 07 21:15:33 localhost systemd[1]: stopping firewalld - dynamic firewall daemon...
apr 07 21:15:34 localhost systemd[1]: stopped firewalld - dynamic firewall daemon.
[root@localhost /]# systemctl disable firewalld.service  #禁止使用防火墙(重启也是禁止的)
removed symlink /etc/systemd/system/dbus-org.fedoraproject.firewalld1.service.
removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost /]# 

防火墙先禁用,搞好之后再配置,个人,要毛线防火墙~~

6.关闭selinux(需重启生效)

[root@localhost /]# vi /etc/selinux/config
[root@localhost /]# cat /etc/selinux/config

# 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   #此处修改为disabled
# selinuxtype= can take one of three two values:
#     targeted - targeted processes are protected,
#     minimum - modification of targeted policy. only selected processes are protected. 
#     mls - multi level security protection.
selinuxtype=targeted 


[root@localhost /]# 

为啥要关闭selinux?因为selinux太高深,非专业人士搞不懂~~

7.修改内核参数

红色部分为添加代码

[sonny@localhost /]$ su root
password: 
[root@localhost /]# vi /etc/sysctl.conf 
[root@localhost /]# cat /etc/sysct.conf
cat: /etc/sysct.conf: no such file or directory
[root@localhost /]# cat /etc/sysctl.conf 
# system default settings live in /usr/lib/sysctl.d/00-system.conf.
# to override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# for more information, see sysctl.conf(5) and sysctl.d(5).
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 #共享内存的总量,8g内存设置:2097152*4k/1024/1024
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
[root@localhost /]# 

使配置参数生效

[root@localhost /]# sysctl -p
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
sysctl: setting key "fs.file-max": invalid argument
fs.file-max = 6815744 #设置最大打开文件数
fs.aio-max-nr = 1048576
sysctl: setting key "kernel.shmall": invalid argument
kernel.shmall = 2097152 #共享内存的总量,8g内存设置:2097152*4k/1024/1024
sysctl: setting key "kernel.shmmax": invalid argument
kernel.shmmax = 2147483648 #最大共享内存的段大小
sysctl: setting key "kernel.shmmni": invalid argument
kernel.shmmni = 4096 #整个系统共享内存端的最大数
kernel.sem = 250 32000 100 128
sysctl: setting key "net.ipv4.ip_local_port_range": invalid argument
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
[root@localhost /]# 

8.对oracle用户设置限制,提高软件运行性能(红色为添加部分)

[sonny@localhost /]$ su root
password: 
[root@localhost /]# vi /etc/security/limits.conf 
[root@localhost /]# cat /etc/security/limits.conf
# /etc/security/limits.conf
#
#this file sets the resource limits for the users logged in via pam.
#it does not affect resource limits of the system services.
#
#also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#that means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#each line describes a limit for a user in the form:
#
#            
#
#where:
# can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
# can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
# can be one of the following:
#        - core - limits the core file size (kb)
#        - data - max data size (kb)
#        - fsize - maximum filesize (kb)
#        - memlock - max locked-in-memory address space (kb)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (kb)
#        - stack - max stack size (kb)
#        - cpu - max cpu time (min)
#        - nproc - max number of processes
#        - as - address space limit (kb)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by posix message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#                 
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

# end of file
[root@localhost /]# 

9.配置用户的环境变量(红色部分为添加代码)

[root@localhost /]# vi /home/oracle/.bash_profile 
[root@localhost /]# cat /home/oracle/.bash_profile 
# .bash_profile

# get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# user specific environment and startup programs

path=$path:$home/.local/bin:$home/bin

export path

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安装时设置的字符集保持一致,如:zhs16gbk,否则出现数据导入导出中文乱码问题
[root@localhost /]# 

使上述配置立即生效:

[oracle@localhost /]$ su root
password: 
[root@localhost /]# source /home/oracle/.bash_profile 
[root@localhost /]# 

10.上述都搞定了,上传安装包我喜欢xftp,将oracle安装包上传到/usr/local/src

11.解压安装包

[oracle@localhost /]$ cd /usr/local/src  #进入/usr/local/src目录
[oracle@localhost src]$ ls
linux.x64_11gr2_database_1of2.zip  linux.x64_11gr2_database_2of2.zip
[oracle@localhost src]$ unzip linux.x64_11gr2_database_1of2.zip -d /data/database/  #解压
(省略...)
[oracle@localhost src]$ unzip linux.x64_11gr2_database_2of2.zip -d /data/database/  #解压
(省略...)
[oracle@localhost src]$ su root
password: 
[root@localhost src]# chown -r oracle:oinstall /data/database/database/
[root@localhost src]# 

三、oracle安装

1.登陆oracle环境

2.启动oralce安装,到/data/database/database/目录下,执行runinstaller



3.去掉勾,懒得填,个人使用环境不需要自动接收oracle的安全更新


4.下一步,只安装数据库软件,个人用不要那些玩意~~

\

5.选择单例安装,前面的所有配置均为单例安装。

\

6.添加语言

\

7.默认安装版本企业版-enterprise edition

\

8.确定数据软件的安装路径,自动读取前面oracle环境变量中配置的值

\

9.理论上要创建database operation(osoper)group:oper ,个人用,懒得建,就使用dba用户组

\

\

10.安装检查,按照提示信息一个一个解决。

如果出现提示交换空间不够请参考上一篇进行修改

点击checkagain

\

编辑/etc/sysctl.conf

\

保存,运行sysctl -p使修改生效

\

接下来解决软件包问题

运行 yum install 所缺软件包名

发现系统已经安装了高版本的,由于高版本支持,所以我们忽略这些报错

\

\

出现

\

出现上述问题解决方法:
/lib64/libstdc++.so中memcpy@glibc_2.4找不到。
问题:glibc是2.17的库,连接找的是2.14的库。
解决办法:改成静态链接。
查看 /usr/lib64/libc.a是否存在。

修改oracle安装目录下:$oracle_home/ctx/lib/ins_ctx.mk

ctxhx: $(ctxhxobj)
        $(link_ctxhx) $(ctxhxobj) $(inso_link)
修改为:
ctxhx: $(ctxhxobj)
        -static $(link_ctxhx) $(ctxhxobj) $(inso_link) /usr/lib64/libc.a

\

保存 重试又报如下错误

\

出现上述问题解决方法:
问题:undefinied reference symbol’b_destroykeyobject’,查看日志,实际就是没有找到nnz11这个库。
解决办法:

修改$oracle_home/sysman/lib/ins_emagent

$(mk_emagent_nmectl)
1

修改为:

$(mk_emagent_nmectl) -lnnz11

\

然后点击retry通过。

\

等待。。。。

等待。。。。。。。

最讨厌等。。。。。。。

\

终于

\

点ok

\

执行:

sh /data/orainventory/orainstroot.sh
sh /data/oracle/product/11.2.0/dbhome_1/root.sh 

\

\

结束

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网