CentOS7安装Oracle 11gR2 图文详解(改)

一、安装Oracle前准备

1.创建运行oracle数据库的系统用户和用户组

[[email protected] ~]$ su root  #切换到root
Password: 
[[email protected] sonny]# groupadd oinstall  #创建用户组oinstall
[[email protected] sonny]# groupadd dba  #创建用户组dba
[[email protected] sonny]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
[[email protected] 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.
[[email protected] sonny]# id oracle # 查看新建的oracle用户
uid=1001(oracle) gid=1002(dba) groups=1002(dba)

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

[[email protected] ~]$ su root
Password: 
[[email protected] sonny]# mkdir -p /data/oracle  #oracle数据库安装目录
[[email protected] sonny]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录
[[email protected] sonny]# mkdir -p /data/database  #oracle数据库软件包解压目录
[[email protected] sonny]# cd /data
[[email protected] data]# ls  #创建完毕检查一下(强迫症)
database  oracle  oraInventory
[[email protected] data]# chown -R oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
[[email protected] data]# chown -R oracle:oinstall /data/oraInventory
[[email protected] data]# chown -R oracle:oinstall /data/database
[[email protected] 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

修改文件 /etc/RedHat-release 

[[email protected] data]$ su root
Password: 
[[email protected] data]# cat /proc/version 
Linux version 3.10.0-327.el7.x86_64 ([email protected]) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
[[email protected] data]# cat /etc/redhat-release  
CentOS Linux release 7.2.1511 (Core) 
[[email protected] data]# vi /etc/redhat-release
[[email protected] data]# cat /etc/redhat-release 
redhat-7 
[[email protected] data]#  

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

rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh

libaio libaio-devel libgcc libstdc++ libstdc++-devel make numactl-devel sysstat  unixODBC unixODBC-devel

yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc.i686

glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat  ld-linux.so.2  unixODBC unixODBC-devel

5.关闭防火墙 CentOS 7.2默认使用的是firewall作为防火墙
[[email protected] /]$ su root
Password: 
[[email protected] /]# 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.
[[email protected] /]# systemctl stop firewalld.service  #关闭防火墙
[[email protected] /]# 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.
[[email protected] /]# systemctl disable firewalld.service  #禁止使用防火墙(重启也是禁止的)
Removed symlink /etc/systemd/system/dbus-org.Fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[[email protected] /]# 

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

[[email protected] /]# vi /etc/selinux/config
[[email protected] /]# 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 

7.修改内核参数

红色部分为添加代码

[[email protected] /]$ su root
Password: 
[[email protected] /]# vi /etc/sysctl.conf 
[[email protected] /]# cat /etc/sysct.conf
cat: /etc/sysct.conf: No such file or directory
[[email protected] /]# 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/<name>.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
[[email protected] /]# 

使配置参数生效

[[email protected] /]# 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
[[email protected] /]#  

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

[[email protected] /]$ su root
Password: 
[[email protected] /]# vi /etc/security/limits.conf 
[[email protected] /]# 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:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> 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
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> 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
#
#<domain>      <type>  <item>         <value>
#

#*               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
[[email protected] /]#  

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

[[email protected] /]# vi /home/oracle/.bash_profile 
[[email protected] /]# 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 #添加系统环境变量
exprot CLASSPATH=$ORACLE_HOME/
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/jilib:$ORACLE_HOME/network/lib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系统环境变量
export LANG=C #防止安装过程出现乱码
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK  #设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致,如:ZHS16GBK,否则出现数据导入导出中文乱码问题
[[email protected] /]#  

10.解压解压包

[email protected] src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/  #解压
(省略...)
[[email protected] src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/  #解压
(省略...)



二、oracle安装 

1.图形界面登陆oracle用户:

CentOS7安装Oracle 11gR2 图文详解(改)

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

CentOS7安装Oracle 11gR2 图文详解(改)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

CentOS7安装Oracle 11gR2 图文详解(改)

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

CentOS7安装Oracle 11gR2 图文详解(改)

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

CentOS7安装Oracle 11gR2 图文详解(改)

6.添加语言

CentOS7安装Oracle 11gR2 图文详解(改)

7.默认安装版本企业版-Enterprise Edition --图没了。

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

CentOS7安装Oracle 11gR2 图文详解(改)

9.理论上要创建Database Operation(OSOPER)Group:oper ,个人用,懒得建,就使用dba用户组

CentOS7安装Oracle 11gR2 图文详解(改)

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

CentOS7安装Oracle 11gR2 图文详解(改)

swap空间不足解决 :(要求2.67G 实际2G)

[[email protected] oracle]# free -m  #查看当前虚拟内存
              total        used        free      shared  buff/cache   available
Mem:           1824        1369          93          10         361         250
Swap:          2048          20        2028
[[email protected] oracle]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000  #将当前swap空间由2048M 增加到 3048M 新增一个2014的swap文件
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 29.4051 s, 35.7 MB/s
[[email protected] oracle]# mkswap /home/swap
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=5e3d39d7-285e-4c74-b321-1e2b3ffabf83
[[email protected] oracle]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1824        1275          95          10         454         342
Swap:          2048         141        1907
[[email protected] oracle]# swapon /home/swap  #增加并启用虚拟内容
swapon: /home/swap: insecure permissions 0644, 0600 suggested.
[[email protected] oracle]# free -m  #再次查看
              total        used        free      shared  buff/cache   available
Mem:           1824        1275          94          10         454         342
Swap:          3048         141        2907 

11.一个一个检查package,在准备阶段中漏掉的,此处再安装,有些系统报错是因为现有的包的版本比检测要高,最后忽略即可。(点击Check_Again 多检查几次)

CentOS7安装Oracle 11gR2 图文详解(改)

12.准备完毕,fuck “Finish”开始安装。

CentOS7安装Oracle 11gR2 图文详解(改)

13.安装过程是一个漫长的过程,中间有几次卡住,没有出现任何画面,屏幕中间有条小线,尝试多次,发现光标在该线上,右键点击Closed,不知道关闭了啥,又能继续安装了。先装吧,到时看安装日志再说。

CentOS7安装Oracle 11gR2 图文详解(改)

 14.提示安装成功。安装日志懒得看,再说。

CentOS7安装Oracle 11gR2 图文详解(改)

四、配置监听listener

1.执行netca 报错

[Oracle@localhost ~]$ netca

Oracle Net Services Configuration:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0x00007f69a69fcb9d, pid=8033, tid=140092892297024
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_17-b03 mixed mode)
# Problematic frame:
# C  [libclntsh.so.11.1+0x62ab9d]  snlinGetAddrInfo+0x1b1
#
# An error report file with more information is saved as hs_err_pid8033.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
/data/oracle/product/11.2.0/db_1/bin/netca: line 178:  8033 Aborted                 (core dumped) $JRE $JRE_OPTIONS -classpath $CLASSPATH oracle.net.ca.NetCA $*
[[email protected] ~]$  

错误原因:安装操作系统是默认主机名localhost造成错误

解决办法:

racle]# cat /etc/sysconfig/network
# Created by anaconda

[[email protected] oracle]# vi /etc/sysconfig/network  #增加HOSTNAME
[[email protected] oracle]# cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=odb-sonny
[[email protected] oracle]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] oracle]# vi /etc/hosts  #增加HOSTNAME
[[email protected] oracle]# cat /etc/hosts     
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 odb-sonny
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] oracle]# hostname odb-sonny  #执行
[[email protected] oracle]#  

最后注销当前oracle用户,重新登陆即可!!这次发现打开配置界面正常,安装windows下面配置即可。

CentOS7安装Oracle 11gR2 图文详解(改)

五、创建Oracle数据实例Orcl

执行dbca命令,启动oracle实例安装界面,剩下的与Windows上安装一样,不废话了:

注意:必须先创建监听,并且监听是启动中,否则报错。

CentOS7安装Oracle 11gR2 图文详解(改)

六、检查安装日志检查

发现有几个错误(原因未知,后续再看):

错误1:

INFO: /lib64/libstdc++.so.5: undefined reference to `[email protected]_2.14'
collect2: error: ld returned 1 exit status

INFO: make: *** [ctxhx] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'install' of makefile '/data/oracle/product/11.2.0/db_1/ctx/lib/ins_ctx.mk'. 
See '/data/oraInventory/logs/installActions2016-04-07_10-38-06PM.log' for details.
Exception Severity: 1 

错误2:

INFO: /usr/bin/ld: warning: -z lazyload ignored.
/usr/bin/ld: warning: -z nolazyload ignored.
/usr/bin/ld: /data/oracle/product/11.2.0/db_1/sysman/lib//libnmectl.a(nmectlt.o): undefined reference to symbol 'B_DestroyKeyObject'
/usr/bin/ld: note: 'B_DestroyKeyObject' is defined in DSO /data/oracle/product/11.2.0/db_1/lib/libnnz11.so so try adding it to the linker command line
/data/oracle/product/11.2.0/db_1/lib/libnnz11.so: could not read symbols: Invalid operation

INFO: collect2: error: ld returned 1 exit status

INFO: make[1]: *** [/data/oracle/product/11.2.0/db_1/sysman/lib/emdctl] Error 1

INFO: make[1]: Leaving directory `/data/oracle/product/11.2.0/db_1/sysman/lib'

INFO: make: *** [emdctl] Error 2

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'agent nmhs' of makefile '/data/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk'. 
See '/data/oraInventory/logs/installActions2016-04-07_10-38-06PM.log' for details.
Exception Severity: 1
INFO: Calling Action unixActions10.2.0.3.0  make
    registerOnly = false
    installMakePath = /usr/bin/make
    installMakeFileName = /data/oracle/product/11.2.0/db_1/rdbms/lib/ins_rdbms.mk
    installTarget = all_no_orcl
    undoMakeFileName = 
    installArguments = ORACLE_HOME=/data/oracle/product/11.2.0/db_1
    logFile = /data/oracle/product/11.2.0/db_1/install/make.log
    undoTarget = 
    progMsg = Linking RDBMS Executables