RedHat Enterprise Linux 6 FOR RedHORACLE 11g安装手册

一、系统环境
操作系统:RedHat Enterprise Linux 6 for i386 或 x86_64
数据库:Oracle 11g R2
解压缩安装包:
用root用户登录系统,进入Oracle安装包目录
zip文件解压缩命令:unzip <文件名> ,
比如: unzip p10404530_112030_Linux-x86-64_1of7.zip
unzip p10404530_112030_Linux-x86-64_2of7.zip
其中单机环境安装只要解压这2个压缩文件就可以了。
二、安装过程
1、 查看swap是否足够?
引用

free

        total       used       free     shared    buffers     cached

Mem: 1034332 50752 983580 0 7288 21052
-/+ buffers/cache: 22412 1011920
Swap: 1992012 0 1992012

swap最少1.8G以上,否则Oracle安装到最后会报错。
2、 查看空间是否足够?
引用

df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 7.4G 3.3G 3.8G 47% /
none 506M 0 506M 0% /dev/shm
/dev/sdb2 6.5G 47M 6.2G 1% /opt

Oracle安装最少需要5G空间。
3、 配置固定IP和主机名,并设置对应
设置固定IP:
引用

cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.10.10
NETMASK=255.255.255.0

设置主机名:

echo "kernel.hostname=ora01" >> /etc/sysctl.conf

对于多网卡的服务器,不建议修改/etc/sysconfig/network来设置主机名,因为一旦修改网络配置,可能会导致主机名也一同修改,所以建议直接设置kernel参数,让其固定不变,这对于Oracle的安装和运行都非常重要。
保存设置,并检查:
引用

/sbin/sysctl -p

hostname

ora01

然后,设置主机名和IP对应关系:

echo "10.168.3.164 ora01" >> /etc/hosts

4、 准备安装介质
这个看上去很简单,但确实一个常见的问题。最常见就是用户把安装介质解压到/root目录。而由于安装必须使用oracle用户进行,而oralce用户是不能访问/root目录的,就会导致安装报错。
建议先检查一下:
引用

pwd

/tmp/database

5、 创建dba组
引用

groupadd dba

6、 创建oracle用户,归属于dba组,并修改oracle用户密码
引用

useradd –g dba oracle

passwd oracle

7、 修改 /opt 目录的属性
引用

chown oracle.dba /opt

8、 修改Linux内核参数,以适应oracle的安装环境
引用

vi /etc/sysctl.conf

修改 /etc/sysctl.conf 增加以下内容:

kernel.shmmax = 2147483648

注:2147483648为共享内存的最大可用值,一般按实际内存的1/2到2/3之间来设定,4G内存的参考值为2147483648。Oracle安装最小的设置为536870912,如小于536870912则无法安装。
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 262144 262144 262144
编辑完成并保存后,重启动系统后就可生效,如不想重启而立即生效,在# 提示符下输入:
引用

/sbin/sysctl -p

验证是否生效的方法:
cat /proc/sys/kernel/shmmax 看是否为你设置的值

9、 确认关闭SELINUX
引用

vi /etc/selinux/config

确认 SELINUX=disabled ,如果不是,请将该参数改为 disabled 并保存后重新启动操作系统

10、 修改用户限制
引用

vi /etc/security/limits.conf

用root用户修改/etc/security/limits.conf文件,加上下面的参数
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

11、 修改用户验证选项

vi /etc/pam.d/login

用root用户修改/etc/pam.d/login文件加上如下参数
session required pam_limits.so
session required /lib/security/pam_limits.so(32位操作系统时添加该参数)
session required /lib64/security/pam_limits.so (64位操作系统时添加该参数)
12、 修改用户配置文件

vi /etc/profile

用root用户修改/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
13、 使用系统光盘安装包示例如下:
引用

cd /media/cdrom/Server /Packages

如果是64位操作系统时 # cd /media/cdrom/Packages

rpm -Uvh compat-libstdc++-33-3*.rpm

rpm -Uvh compat-libstdc++-33-3*64.rpm (64位操作系统时安装)

rpm -Uvh compat-gcc-34-3*

rpm -Uvh compat-gcc-34-c++-3*

rpm -Uvh libXp-1*

rpm -Uvh compat-db-4*

rpm -Uvh libaio-devel-0.3*

rpm -Uvh unixODBC-libs-2.2.*

rpm -Uvh unixODBC-2.2.*

rpm -Uvh unixODBC-devel-2.2.*

可选参数 –nodeps :忽略依赖关系

14、 检查Oracle 11g安装所依赖的软件包
检查包是否安装

rpm -q 包名

包名:
1)binutils
2)compat-libstdc++
3) elfutils-libelf
4) elfutils-libelf-devel
5) gcc
6) gcc-c++
7) glibc
8) glibc-common
9) glibc-devel
10) glibc-headers
11) pdksh
12) libaio
13) libaio-devel
14) libgcc
15) libstdc++
16) libstdc++-devel
17) make
18) sysstat
19) unixODBC
20) unixODBC-devel

rpm -ivh 包名 安装所需包

rpm -Uvh 包名 更新所需包

若包不存在则需要安装。若gcc没有安装,则需要先依次安装包(kernel-headers,glibc-headers,glibc-devel)
和(mpfr,cpp,ppl,cloog-ppl)。若gcc-c++没安装则需先安装libstdc++-devel。
15、 开始安装Oracle软件
◎ 以oracle用户登录到操作系统
用文本编辑器修改/home/oracle/.bash_profile文件,加入以下环境变量的参数:
引用
$vi /home/oracle/.bash_profile

以下蓝色部分是要添加的内容:
ORACLE_BASE=/opt/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11g/db_1; export ORACLE_HOME
NLS_LANG=American_America.ZHS16GBK; export NLS_LANG
ORACLE_SID=orcl; export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:/sbin;export PATH
BIN=$ORACLE_HOME/bin; export BIN
LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH

export LANG=en_US.UTF-8

修改并保存后退出oracle的登录。
再以oracle用户重新登录。
进入Oracle安装包所在的目录,进行Oracle软件的安装
◎ 运行runInstaller开始安装oracle
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
此处可以根据自身情况,选择是否填写email,也可以什么都不填写
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
提示“没有填写email地址”可以忽略,选择“YES”
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
选择“Skip software updates”然后点“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
选择“Install database software only”然后点击“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
因为此处是单实例安装,所以选择“Single instance database installation”然后点击“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
此处选择语言,添加“Simplified Chinese”,然后点击“Next”继续
如果你的安装界面是英文界面,必须增加简体中文,否则安装完成后的em管理工具会出现乱码。
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
选择“Enterprise Edition(4.5GB)”然后点击“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
此处选择安装oracle的目录,可以根据自身情况进行修改,默认也可以
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
点“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
填入“dba”然后点击“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
在安装ORACLE之前,安装程序会先检查系统环境是否满足安装条件,如先决条件检查失败,则应先退出安装程序,解决相应的问题后再次安装。例如上图,提示swap大小不符合(swap的大小可以根据提示进行设置,也可以选择忽略这个提醒),2个包没有安装。
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
选择如图所示点击“Fix & Check Again”进行修复并且手动安装相。、关的软件包
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
会跳出窗口,按照提示操作:
另开一个窗口用root用户登录,并且执行/tmp/CVU_11.2.0.3.0_oracle/runfixup.sh脚本

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
执行完成后,返回到刚才那个小窗口,点击“OK”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
Oracle会进行自动修复
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
所有检查条件都通过后,点“Install”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
在安装完前弹出对话框,要使用root用户去执行两个脚本的

$su - root
引用
#cd /opt/oraInventory
#./orainstRoot.sh
[root@ora01 oraInventory]# ./orainstRoot.sh
Changing permissions of /opt/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oraInventory to dba.
The execution of the script is complete.
引用

cd /opt/oracle/product/11g/db_1/

./root.sh

Performing root user operation for Oracle 11g

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/11g/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: (此处按回车即可)
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions
然后关闭提示对话框

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
Oracle数据库安装完毕。恭喜!!

16、 创建实例
◎ 15.1 修改/data权限:
以root用户登录运行命令:
#cd /data
#mkdir oradata

chown –R oracle /data

#chgrp –R dba /data

◎ 15.2 创建Listener
用Oracle 用户登录系统运行命令:
$ netca

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
点击Next直到完成
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
◎ 15.3 创建Oracle 数据库

用Oracle 用户登录系统,使用命令:
$ dbca
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
请选择“Custom Database定制数据库”,然后点“Next”,否则将不能修改块大小

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
输入数据库名,ORACLE_SID名,即实例名,然后点“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
点“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
输入SYSTEM等用户的初始密码,然后点“Next”继续
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
如果设置的秘密太过简单,oracle会跳出一个提示窗口,你可以选择“No”重新设置复杂点的密码,也可以忽略这个提示,点击“yes”继续

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
根据系统的情况,选择数据库的存储机制,一般情况下使用文件系统,点“Next”继续
将数据文件指定到 /data/oradata 目录下,然后点“Next”继续

RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
在第10步中内存采用系统的百分比,通常是40%~60%之间,不要超过60%
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
设置块大小:把块大小设置成16384字节(16K), 进程数改成600
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
设置字符集, 一定要选Choose from the list of character sets,把字符集设置为ZHS16GBK,否则建好实例后插入的中文数据都会变成乱码。
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
修改undo表空间大小为10240M
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
在步骤11中设置回滚表空间的大小, 并把回滚表空间的数据文件满后自动扩展属性关闭
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
在步骤11中调整重做日志的大小, 分别把3个日志调整到512M
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
点击Finish,开始创建oracle实例
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
点“OK”确定开始建库
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
创建数据库中
RedHat Enterprise Linux 6  FOR RedHORACLE 11g安装手册
Oracle数据库创建完毕。恭喜!!!
启动oracle

  1. 使用oracle用户login
  2. 起监听器
    Oracle]$lsnrctl start
  3. 启动数据库
    Oracle]$sqlplus “/as sysdba”
    Sql>startup
  4. 启动OEM
    [oracle@ora01 ~]$ emctl status dbconsole
    Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name
    第一次尝试启动em时出现报错,需要先设置ORACLE_UNQNAME的值
    [oracle@ora01 ~]$ export ORACLE_UNQNAME=orcl
    [oracle@ora01 ~]$ emctl start dbconsole
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
    Copyright (c) 1996, 2011 Oracle Corporation. All rights reserved.
    https://ora01:1158/em/console/aboutApplication
    Starting Oracle Enterprise Manager 11g Database Control ........... started.

    Logs are generated in directory /opt/oracle/product/11g/db_1/ora01_orcl/sysman/log
    启动之后我们就可以通过在浏览器端输入以下url访问:
    https://ip:1158/em/
    同样停止OEM可以输入如下命令
    emctl stop dbconsole

以下是停止过程:
[oracle@ora01 ~]$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
Copyright (c) 1996, 2011 Oracle Corporation. All rights reserved.
https://ora01:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
... Stopped.

也可以直接键入emctl查看emctl支持的选项:
[oracle@ora01 ~]$ emctl
Oracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
Copyright (c) 1996, 2011 Oracle Corporation. All rights reserved.
Oracle Enterprise Manager 10g Database Control commands:
emctl start | stop dbconsole
emctl status | secure | setpasswd dbconsole
emctl config dbconsole -heap_size <size_value> -max_perm_size <size_value>
emctl status agent
emctl status agent -secure [-omsurl <http://<oms-hostname>:<oms-unsecure-port>/em/*>;]
emctl getversion
emctl reload | upload | clearstate | getversion agent
emctl reload agent dynamicproperties [<Target_name>:<Target_Type>]....
emctl config agent <options>
emctl config agent updateTZ
emctl config agent getTZ
emctl resetTZ agent
emctl config agent credentials [<Target_name>[:<Target_Type>]]
emctl gensudoprops
emctl clearsudoprops
Blackout Usage :
emctl start blackout <Blackoutname> [-nodeLevel] [<Target_name>[:<Target_Type>]].... [-d <Duration>]
emctl stop blackout <Blackoutname>
emctl status blackout [<Target_name>[:<Target_Type>]]....

The following are valid options for blackouts
<Target_name:Target_type> defaults to local node target if not specified.
If -nodeLevel is specified after <Blackoutname>,the blackout will be applied to all targets and any target list that follows will be ignored.
Duration is specified in [days] hh:mm

    emctl getemhome
    emctl ilint

Em Key Commands Usage :
emctl config emkey -emkeyfile <emkey.ora path> [-force] [-sysman_pwd <sysman password>]
emctl config emkey -emkey [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
emctl config emkey -repos [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
emctl config emkey -remove_from_repos [-sysman_pwd <sysman password>]
emctl config emkey -copy_to_repos [-sysman_pwd <sysman password>]
emctl status emkey [-sysman_pwd <sysman password>]

Secure DBConsole Usage :
emctl secure dbconsole -sysman_pwd <sysman password> [-passwd_file <abs file loc>]
[-host <slb hostname>] [-sid <service name>] [-reset] [-secure_port <secure_port>]
[-cipher_suites <comma_separated_list_of_suites>] [-sign_alg <md5|sha1|sha256|sha384|sha512>]
[-root_dc <root_dc>] [-root_country <root_country>] [-root_state <root_state>] [-root_loc <root_loc>]
[-root_org <root_org>] [-root_unit <root_unit>] [-root_email <root_email>]
[-wallet <wallet loc>] [-wallet_pwd <wallet pwd>] [-trust_certs_loc <certs loc>]
emctl secure status dbconsole
Register Targettype Usage :
emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep host> <rep port> <rep sid> OR
emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep connect descriptor>
如果启动不了,方法:

sql>emca-config dbcontrol db -repos recreate
重新配置一些参数即可

  1. 设置oracle 在开机时自动启动
    5.1. 以oracle用户登录
    打开文件/opt/oracle/product/11g/db_1/bin/dbstart
    引用
    $gedit /opt/oracle/product/11g/db_1/bin/dbstart

找到 ORACLE_HOME_LISTNER=$1 这一行,
改成 ORACLE_HOME_LISTNER=$ORACLE_HOME

同样道理修改 /opt/oracle/product/11g/db_1/bin/dbshut
引用
$gedit /opt/oracle/product/11g/db_1/bin/dbshut

找到 ORACLE_HOME_LISTNER=$1 这一行,
改成 ORACLE_HOME_LISTNER=$ORACLE_HOME

测试运行 dbshut 和 dbstart 看能否启动oracle 服务及listener服务

5.2. 以root用户登录
打开文件/etc/oratab
引用
#gedit /etc/oratab

把最后一行
orcl:/opt/oracle/product/11g/db_1:N
改成
orcl:/opt/oracle/product/11g/db_1:Y

打开文件/etc/rc.d/rc.local
在任意位置增加以下两行内容:

. /home/oracle/.bash_profile
su - oracle -c $ORACLE_HOME/bin/dbstart

附录一:实例创建后相关oracle参数的调整

数据库实例创建后,为了让数据库能够创建更多的数据文件和打开更多的游标,某些较大型的客户可能需要将相关参数调得更大些。主要需要调整的参数如下:
1、 DB_FILES
2、 OPEN_CURSORS
3、 memory_max_size 和memory_target
调整的步骤如下:
1、 备份原有的参数文件,以防止万一误操作造成数据库无法启动
引用
$cp $ORACLE_HOME/dbs/spfileSID.ora $ORACLE_HOME/dbs/spfileSID.ora.bak
注: 以上SID为数据库的实例名,需要根据实际情况进行修改
2、 修改相关参数
引用
$sqlplus “/as sysdba”
SQL> alter system set db_files=800 scope=spfile;
SQL> alter system set open_cursors=5000 scope=spfile;
SQL> alter system set memory_max_size =4G scope=spfile;
SQL> alter system set memory_target =4G scope=spfile;

注1: memory的大小应该根据数据库物理内存的大小相应作调整,一般设置为物理内存的40%左右为宜
注2:必须先将 /etc/sysctl.conf 中的 SHMMAX 内核参数设置得比memory更大
注3:若要将memory设置成大于4G,必须检查/dev/shm是否大于memory,如果/dev/shm小于memory,必须先将它设置成大于memory,更改/dev/shm大小的方法参见附录二。

3、 重启动数据库,使参数生效
附录二:如何更改/dev/shm大小
因为RHEL将共享内存放在了临时文件系统(tmpfs)中, 也就是/dev/shm, 如果你修改后的最大共享内存的值超过了/dev/shm的大小, 那/dev/shm就装不下共享内存了。因此,SGA的大小不能设置超过 /dev/shm的大小。而 /dev/shm 默认是物理内存的一半,如果想将SGA设置得更大些,就需要先调整 /dev/shm的大小。下面介绍如何调整/dev/shm的大小。
首先,通过df命令查看现有/dev/shm的大小
引用

df -h /dev/shm

Filesystem Size Used Avail Use% Mounted on
tmpfs 3.9G 0 3.9G 0% /dev/shm
以上显示/dev/shm大小为3.9G,现在如果想把它调整为10G,方法如下:
1、 备份/etc/fstab文件,以防止万一误操作造成操作系统无法启动
引用

cp /etc/fstab /etc/fstab.bak

2、 修改/etc/fstab文件,找到 tmpfs /dev/shm tmpfs defaults 0 0 这行,改成 tmpfs /dev/shm tmpfs defaults, size=10G 0 0 , 也就是在defaults后面加上size=10G, 明确的指定/dev/shm的大小
3、 修改完后, 执行 mount -o remount /dev/shm重新挂载该文件系统即可生效。

猜你喜欢

转载自blog.51cto.com/chinak/2635219