http://www.web008.net

美高梅163888Centos7下安装Oracle11g r2

  我的centos7是在virtualbox下安装的,安装Oracle安装了好久好久,最开始的时候在网上找的两个文章,按照步骤装,有一篇写着装的时候有灰色的竖线,直接按space键或者鼠标右键closed关闭掉就OK,我想着这多好,安装了好几次,都失败了,而且,在安装之前我也没有备份,我又有强迫症,稍有和步骤不一样,或者安装依赖包失败了,就又要从头再来,有时候会很生气,真的就把它们统统卸载了,又重新安装virtualbox,centos,安装Oracle之前的准备工作,安装Oracle,折腾了特别久,我要写一个安装步骤记录下来我经过惨痛的教训之后得到的经验。

1.下载软件

 官网下载

 

解压到Linux本地目录。

安装完成后的两个小问题

4, 创建用户 ,用户组

[root@localhost ~]# groupadd oinstall 

[root@localhost ~]# groupadd dba 

[root@localhost ~]# useradd -g oinstall -G dba oracle 

[root@localhost ~]# passwd oracle

[root@localhost ~]# su - oracle 

二、环境准备

安装包:

  • linux.x64_11gR2_database_1of2.zip
  • linux.x64_11gR2_database_2of2.zip

  Oracle下载地址:  

  我centos安装的是64位的,但是我电脑是32位的,所以惯性使然竟然下了32位的安装包,之后把安装前的那些准备工作都做了,运行Oracle的安装包,竟然失败了,我最开始的时候都不知道什么原因,最后恍然发觉安装包弄错了,应该下64位的。就因为这个折腾了好久,弄得我心里都有火了,因为没有给virtualbox做备份,也没有给它设置共享文件夹,所以就一遍遍的重复下载,安装前的准备步骤,而且我有强迫症,比如说yum安装没成功或者怎么样,都要重头来过,所以做了特别多遍,竟然都做了无用功,特生自己的气。所以一定要多备份,下之前看仔细了。

 

三、安装Oracle前的准备

 

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

 1 [cindyma@localhost ~]$ su root  #切换到root
 2 Password:
 3 [root@localhost]# groupadd oinstall  #创建用户组oinstall
 4 [root@localhost]# groupadd dba  #创建用户组dba
 5 [root@localhost]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
 6 [root@localhost]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
 7 Changing password for user oracle.
 8 New password:   # 密码
 9 BAD PASSWORD: The password is shorter than 8 characters
10 Retype new password:   # 确认密码
11 passwd: all authentication tokens updated successfully.
12 [root@localhost]# id oracle # 查看新建的oracle用户
13 uid=1001(oracle) gid=1002(dba) groups=1002(dba)

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

 1 [root@localhost]# cd /.        #进入根目录
 2 [root@localhost]# mkdir -p /data/oracle  #oracle数据库安装目录
 3 [root@localhost]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录
 4 [root@localhost]# mkdir -p /data/database  #oracle数据库软件包解压目录
 5 [root@localhost]# cd /data
 6 [root@localhost data]# ls  #创建完毕检查一下(强迫症)
 7 database oracle oraInventory
 8 [root@localhost data]# chown -R oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
 9 [root@localhost data]# chown -R oracle:oinstall /data/oraInventory
10 [root@localhost data]# chown -R oracle:oinstall /data/database
11 [root@localhost data]#

3.修改OS系统标识(oracle默认不支持CentOS系统安装,但是centos其实就是redhat)

1 [root@localhost data]# cat /proc/version
2 Linux version 3.10.0-514.26.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017
3 [root@localhost data]# cat /etc/redhat-release
4 CentOS Linux release 7.3.1611 (Core)
5 [root@localhost data]# vi /etc/redhat-release
6 [root@localhost data]# cat /etc/redhat-release
7 redhat-7

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

1 [root@localhost data]# yum -y install binutils* compat-libcap1* compat-libstdc++* gcc* gcc-c++* glibc* glibc-devel* ksh* libaio* libaio-devel* libgcc* libstdc++* libstdc++-devel* libXi* libXtst* make* sysstat* elfutils* unixODBC*

  centos7需要的安装包,可以在Oracle上查看:
  我的版本当然对应的是这个版本:Oracle Linux 7 and Red Hat Enterprise Linux 7
  它没有要求说要安装elfutils和unixODBC包,但是等安装Oracle检查安装前准备时,会提示说缺少这两个包,所以一并安装
  有时候使用yum安装的时候,会提示another app is currently holding the yum lock,这个时候打开另外一个terminal,在root用户下输入
  #rm -f /var/run/yum.pid
  强制关掉yum进程

5.关闭防火墙

 1 [root@localhost data]# systemctl status firewalld.service    #查看防火墙状态(运行中)
 2 ● firewalld.service - firewalld - dynamic firewall daemon
 3    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
 4    Active: active (running) since Wed 2017-09-13 09:23:08 CST; 25min ago
 5      Docs: man:firewalld(1)
 6  Main PID: 641 (firewalld)
 7    CGroup: /system.slice/firewalld.service
 8            └─641 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
 9 
10 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami...
11 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
12 Hint: Some lines were ellipsized, use -l to show in full.
13 [root@localhost data]# systemctl stop firewalld.service    #关闭防火墙
14 [root@localhost data]# systemctl status firewalld.service    #查看防火墙状态(已关闭)
15 ● firewalld.service - firewalld - dynamic firewall daemon
16    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
17    Active: inactive (dead) since Wed 2017-09-13 09:48:55 CST; 10s ago
18      Docs: man:firewalld(1)
19   Process: 641 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
20  Main PID: 641 (code=exited, status=0/SUCCESS)
21 
22 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami...
23 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
24 Sep 13 09:48:54 localhost.localdomain systemd[1]: Stopping firewalld - dynami...
25 Sep 13 09:48:55 localhost.localdomain systemd[1]: Stopped firewalld - dynamic...
26 Hint: Some lines were ellipsized, use -l to show in full.
27 [root@localhost data]# systemctl disable firewalld.service   #禁止使用防火墙(重启也是禁止的)         
28 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
29 Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

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

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

/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.
style="font-family: Microsoft YaHei; font-size: 16px">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、修改内核参数(加入斜体部分)

1 [root@local++host data]# vi /etc/sysctl.conf
2 [root@localhost data]# cat /etc/sysctl.conf

 

# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.

#
# For more information, see sysctl.conf(5) and sysctl.d(5).
style="font-family: Microsoft YaHei; font-size: 16px">net.ipv4.icmp_echo_ignore_broadcasts = 1
style="font-family: Microsoft YaHei; font-size: 16px">net.ipv4.conf.all.rp_filter = 1
style="font-family: Microsoft YaHei; font-size: 16px">fs.file-max = 6815744 #设置最大打开文件数
style="font-family: Microsoft YaHei; font-size: 16px">fs.aio-max-nr = 1048576
style="font-family: Microsoft YaHei; font-size: 16px">kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024
style="font-family: Microsoft YaHei; font-size: 16px">kernel.shmmax = 2147483648 #最大共享内存的段大小
style="font-family: Microsoft YaHei; font-size: 16px">kernel.shmmni = 4096 #整个系统共享内存端的最大数
style="font-family: Microsoft YaHei; font-size: 16px">kernel.sem = 250 32000 100 128
style="font-family: Microsoft YaHei; font-size: 16px">net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围
style="font-family: Microsoft YaHei; font-size: 16px">net.core.rmem_default = 262144
style="font-family: Microsoft YaHei; font-size: 16px">net.core.rmem_max= 4194304
style="font-family: Microsoft YaHei; font-size: 16px">net.core.wmem_default= 262144
style="font-family: Microsoft YaHei; font-size: 16px">net.core.wmem_max= 1048576

8、使配置修改内核的参数生效

1 [root@localhost data]# sysctl -p

 

style="font-family: Microsoft YaHei; font-size: 16px">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

9、对oracle用户设置限制,提高软件运行性能(斜体为添加部分)

1 [root@localhost data]# vi /etc/security/limits.conf
2 [root@localhost data]# cat /etc/security/limits.conf

  在最下面部分添加内容(斜体为添加的内容)

style="font-family: Microsoft YaHei; font-size: 16px">@student - maxlogins 4

 

  • style="font-family: Microsoft YaHei; font-size: 16px">oracle soft nproc 2047*

  • style="font-family: Microsoft YaHei; font-size: 16px">oracle hard nproc 16384*

  • style="font-family: Microsoft YaHei; font-size: 16px">oracle soft nofile 1024*

  • style="font-family: Microsoft YaHei; font-size: 16px">oracle hard nofile 65536*

 

style="font-family: Microsoft YaHei; font-size: 16px">End of ``file

10、配置用户的环境变量(斜体部分为添加代码)

1 [root@localhost data]# vi /home/oracle/.bash_profile
2 [root@localhost data]# 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_UNQNAME=orcl
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安装时设置的字符集保持一致

style="font-family: Microsoft YaHei; font-size: 16px">    

  export ORACLE_UNQNAME=orcl (in 11.2 dbconsole, the $ORACLE_UNQNAME needs to be set rather than $ORACLE_SID)  

  报错:   

  ERROR:export '=' not a valid identifier

  如果你给添加语句写成这样(等号两边带空格):export LANG = C就会报错

  不能给/etc/profile文件里加空格

 

11、使用户的环境变量配置立即生效

1 [root@localhost data]# source /home/oracle/.bash_profile

12.将安装包移动到/usr/local/src路径下

1 [root@localhost ~]# cd /.
2 [root@localhost /]# cd /home/anzerong/Desktop/
3 [root@localhost Desktop]# ls
4 linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip
5 [root@localhost Desktop]# mv linux.x64_11gR2_database_1of2.zip /usr/local/src
6 [root@localhost Desktop]# ls
7 linux.x64_11gR2_database_2of2.zip
8 [root@localhost Desktop]# mv linux.x64_11gR2_database_2of2.zip /usr/local/src

13.重启系统,确保所有设置生效

1 [root@localhost Desktop]# reboot

14.从oracle用户进入/usr/local/src目录

1 [oracle@localhost /]$ cd /usr/local/src
2 [oracle@localhost src]$ ls
3 linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip

15.解压两个软件包至/data/database/目录下

1 [oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/  #解压
2 (省略...)
3 [oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/  #解压
4 (省略...)

16.进入管理员权限,设置目录所有者为oinstall用户组的oracle用户,执行安装脚本

1 [oracle@localhost src]$ su root
2 Password:
3 [root@localhost src]# chown -R oracle:oinstall /data/database/database/
4 [oracle@localhost /]$ cd /data/database/database/
5 [oracle@localhost database]$ ls
6 doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
7 [oracle@localhost database]$ ./runInstaller 
8 Starting Oracle Universal Installer...
9 (省略...)

3.修改系统参数

 [root@localhost ~]# vi /etc/sysctl.conf 

fs.aio-max-nr = 1048576 

fs.file-max = 6815744 

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 = 262144 

net.core.rmem_max = 4194304 

net.core.wmem_default = 262144 

net.core.wmem_max = 1048576

[root@localhost ~]# sysctl -p 

[root@localhost ~]# vi /etc/security/limits.conf 

# /etc/security/limits.conf

*      soft    nproc  65536

*      hard    nproc  65536

*      soft    nofile  65536

*      hard    nofile  65536

2.vim中文乱码

设置~下或者oracle用户下的.vimrc文件,加上fileencodings、enc、fencs,代码如下:

vim ~/.vimrc    #或者vim /home/oracle(用户名)/.vimrc
#添加如下代码
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set enc=utf8
set fencs=utf8,gbk,gb2312,gb18030

 

 参考:

1.
2.
3.
4.
5.

 

5,设置oracle用户的环境变量

[oracle@localhost~] $ vim .bash_profile

# .bash_profile 

export PATH 

unset USERNAME 

export ORACLE_BASE=/u01/app/oracle 

export ORACLE_HOME= $ORACLE_BASE/product/11.2.0/db_1 

export ORACLE_SID=ora11g 

export PATH=$PATH:$HOME/BIN:$ORACLE_HOME/bin 

# Get the aliases and functions 

if [ -f ~/.bashrc ]; then 

. ~/.bashrc 

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH 

unset USERNAME

Vim /etc/profile 

export LD_BIND_NOW=1

郑重声明:本文版权归美高梅163888所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。