ITPub博客

首页 > 数据库 > Oracle > DBA强化实战系列第一期:centos6.4安装oracle11.2.0.4单实例asm

DBA强化实战系列第一期:centos6.4安装oracle11.2.0.4单实例asm

原创 Oracle 作者:datapeng 时间:2013-12-10 18:23:27 0 删除 编辑

DBA强化实战系列第一期:centos6.4安装oracle11.2.0.4单实例asm

最近有不少朋友说在linux6.4上安装oracle11.2.0.4失败,所以特别测试一下,网络首发,转载请注明出处
后面有更多精彩日记更新,敬请关注或http://blog.itpub.net/29371470/或www.datapeng.com

 

1、确定操作系统

[root@mytest yum.repos.d]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@mytest yum.repos.d]# uname -a
Linux mytest 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@mytest yum.repos.d]# free -m
             total       used       free     shared    buffers     cached
Mem:         48269       1192      47077          0         43        328
-/+ buffers/cache:        819      47450
Swap:        40959          0      40959

[root@mytest yum.repos.d]# vi /etc/hosts
127.0.0.1   mytest mytest mytest.localdomain mytest4 mytest4.localdomain4
::1         mytest mytest.localdomain mytest6 mytest6.localdomain6
192.168.92.161  mytest
注意,这里要编辑,否则在配置监听的时候会报错,vip服务无法注册

2、建用户授权

[root@mytest yum.repos.d]# groupadd oinstall
[root@mytest yum.repos.d]# groupadd dba
[root@mytest yum.repos.d]# useradd -g oinstall -G dba oracle
[root@mytest yum.repos.d]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: it is based on your username
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mytest yum.repos.d]# mkdir /u01
[root@mytest yum.repos.d]# mkdir /u02
[root@mytest yum.repos.d]# mkdir -p /u01/app/oracle/product/11.2.0/db1
[root@mytest yum.repos.d]# mkdir -p /u01/app/grid/product/11.2.0/crs
[root@mytest yum.repos.d]# chown -R oracle:oinstall /u01
[root@mytest yum.repos.d]# cd /u01
[root@mytest u01]# chmod 777 /u02

3、编辑用户环境变量
[root@mytest u01]# su - oracle
[oracle@mytest ~]$ vi .bash_profile
# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db1; export ORACLE_HOME
ORACLE_SID=oradb; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
export PATH
if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
         ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
        umask 022
fi
".bash_profile" 32L, 968C written

4、设置系统环境变量

[root@mytest u01]# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608                   --注意,我这里的内存比较大,所以要大一点,否则会报错
kernel.shmmax = 30064771072
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 = 1048586
vm.min_free_kbytes = 51200

[root@mytest u01]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle hard stack 10240

[root@mytest u01]# vi /etc/selinux/config
SELINUX=disabled

[root@mytest u01]# vi /etc/pam.d/login
session    required     pam_limits.so

系统环境已经配置结束!

5、打补丁包
配置yum源
[root@mytest ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@mytest ~]# vim /etc/yum.repos.d/CentOS-Media.repo
修改的结果如下:
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS_6.4_Final
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

--清除原有的yum信息

[root@mytest ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything

--检查DVD软件列表
[root@mytest yum.repos.d]# yum list
Loaded plugins: fastestmirror
Determining fastest mirrors
c6-media | 3.7 kB 00:00 ...
c6-media/primary_db | 3.3 MB 00:00 ...
--检查一下系统中的包是否最新
[root@mytest yum.repos.d]# yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Update Process
No Packages marked for Update
注意:以下包是必须安装上去的
compat-libstdc++-33-3.2.3-69.el6.i686.rpm
compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
gcc-4.4.4-13.el6
gcc-4.4.7-3.el6.x86_64.rpm
gcc-c++-4.4.7-3.el6.x86_64.rpm
glibc-2.12-1.107.el6.i686.rpm
glibc-devel-2.12-1.107.el6.x86_64.rpm
glibc-devel-2.12-1.107.el6.i686.rpm
ksh-20100621-19.el6.x86_64.rpm
libgcc-4.4.7-3.el6.i686.rpm
libgcc-4.4.7-3.el6.x86_64.rpm
libstdc++-docs-4.4.7-3.el6.x86_64.rpm
libstdc++-devel-4.4.7-3.el6.x86_64.rpm
libstdc++-4.4.7-3.el6.x86_64.rpm
libstdc++-devel-4.4.7-3.el6.i686.rpm
libaio-0.3.107-10.el6.i686.rpm
libaio-0.3.107-10.el6.x86_64.rpm
libaio-devel-0.3.107-10.el6.i686.rpm
libaio-devel-0.3.107-10.el6.x86_64.rpm
elfutils-libelf-0.152-1.el6.i686.rpm

如果以上包不存在,就必须安装。
在我的环境中,只有以下包没有,所以进行安装
[root@mytest ~]# yum install -y libstdc++-docs
[root@mytest ~]# yum install -y ksh
[root@mytest ~]# yum install -y elfutils-libelf-devel
[root@mytest ~]# yum install -y libaio-devel
 
注意,如果安装了ksh包,那么将与pdksh-5.2.14-30.x86_64.rpm冲突,不安装pdksh不会影响安装的使用的

5、对硬盘进行分区
总共挂了5块盘,sda/sdb/sdc/sdd/sde
其中,sda做为系统盘,对其余四个盘进行分区。
[root@mytest ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x646bfece.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1017, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1017, default 1017):
Using default value 1017

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@mytest ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x87ca0cb5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1017, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1017, default 1017):
Using default value 1017

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@mytest ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x55c77081.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-40960, default 1):   
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-40960, default 40960):
Using default value 40960

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@mytest ~]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x0109de8c.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-40960, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-40960, default 40960):
Using default value 40960

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

--配置udev,使用这种方式来绑定asm裸设备
我们计划用第一盘和第二个裸设备来做crs盘,建crsdg.

[root@mytest rules.d]# cd /etc/udev/rules.d
[root@mytest rules.d]# vi 60-raw.rules

# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw4 %N"
KERNEL=="raw[1-4]", OWNER="oracle", GROUP="dba", MODE="660"

[root@mytest rules.d]# start_udev
Starting udev: [  OK  ]
[root@mytest rules.d]# raw -qa
/dev/raw/raw1:  bound to major 8, minor 17
/dev/raw/raw2:  bound to major 8, minor 33
/dev/raw/raw3:  bound to major 8, minor 49
/dev/raw/raw4:  bound to major 8, minor 65
在这里,可以看到,我们绑定已经成功了!
请注意,在有些场景中,这样的绑定方法会有局限性。linux在扫描磁盘时出现磁盘乱序,要使用绑定uuid的方法,请参阅<<linux系统 重启盘符错乱问题>>

6、安装grid软件

注意,11.2以后的版本,asm已经发生了很大的变化,包括对asm的管理也发生了很大的变化,即使安装单实例的asm,也必须安装crs软件
将:
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
p13390677_112040_Linux-x86-64_3of7.zip

grid是第三个包,unzip解压即可

上传,并解压
先安装grid,然后
运行:runInstaller

根据图形界面来做,过程很简单。
--1,skip software update
--2,configure oracle grid infrastructer for a standalone server 第二个选项
--3,以后的就直接下一步
--4,选两个盘建crsdg,本例中选择raw1及raw2,建crsdg,normal模式
--5,后面的基本是一步,就行了,注意asm密码的设置,不要忘记了!
--6,路径选择。由于我们的grid都使用的是oracle用户,所以这里的路径要手动输一下
--7,在检测的时候提示kdpsh包,选择ignore all就行了,不影响,这个与图形界面有关
--8,安装最后提示用运行orainstRoot.sh及root.sh,这个比较简单,使用root用户运行
[root@mytest u02]# sh /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@mytest u02]# sh /u01/app/grid/product/11.2.0/crs/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/grid/product/11.2.0/crs

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.
Using configuration parameter file: /u01/app/grid/product/11.2.0/crs/crs/install/crsconfig_params
Creating trace directory
LOCAL ADD MODE
Creating OCR keys for user 'oracle', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node mytest successfully pinned.
Adding Clusterware entries to upstart

mytest     2013/12/09 16:58:55     /u01/app/grid/product/11.2.0/crs/cdata/mytest/backup_20131209_165855.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
这时候,系统开始配置相关的东西,并启动crs软件,asm也将会启动起来,
至此,grid安装结束

[oracle@mytest grid]$ ps -ef | grep pmon
oracle    8885     1  0 17:01 ?        00:00:00 asm_pmon_+ASM
oracle    9213  2741  0 17:01 pts/0    00:00:00 grep pmon

[oracle@mytest grid]$ ps -ef | grep -i +asm
oracle    8885     1  0 17:01 ?        00:00:00 asm_pmon_+ASM
oracle    8887     1  0 17:01 ?        00:00:00 asm_psp0_+ASM
oracle    8889     1  1 17:01 ?        00:00:01 asm_vktm_+ASM
oracle    8893     1  0 17:01 ?        00:00:00 asm_gen0_+ASM
oracle    8895     1  0 17:01 ?        00:00:00 asm_diag_+ASM
oracle    8897     1  0 17:01 ?        00:00:00 asm_dia0_+ASM
oracle    8899     1  0 17:01 ?        00:00:00 asm_mman_+ASM
oracle    8901     1  0 17:01 ?        00:00:00 asm_dbw0_+ASM
oracle    8903     1  0 17:01 ?        00:00:00 asm_lgwr_+ASM
oracle    8905     1  0 17:01 ?        00:00:00 asm_ckpt_+ASM
oracle    8907     1  0 17:01 ?        00:00:00 asm_smon_+ASM
oracle    8909     1  0 17:01 ?        00:00:00 asm_rbal_+ASM
oracle    8911     1  0 17:01 ?        00:00:00 asm_gmon_+ASM
oracle    8913     1  0 17:01 ?        00:00:00 asm_mmon_+ASM
oracle    8915     1  0 17:01 ?        00:00:00 asm_mmnl_+ASM
oracle    8927     1  0 17:01 ?        00:00:00 oracle+ASM (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    9204     1  0 17:01 ?        00:00:00 asm_fd00_+ASM

[root@mytest bin]# ./crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
ora.CRSDG.dg   ora....up.type ONLINE    ONLINE    mytest    
ora....ER.lsnr ora....er.type ONLINE    ONLINE    mytest    
ora.asm        ora.asm.type   ONLINE    ONLINE    mytest    
ora.cssd       ora.cssd.type  ONLINE    ONLINE    mytest    
ora.diskmon    ora....on.type OFFLINE   OFFLINE              
ora.evmd       ora.evm.type   ONLINE    ONLINE    mytest    
ora.ons        ora.ons.type   OFFLINE   OFFLINE

7、安装oracle软件
第一个包、第二个包是rdbms的软件,直接解压安装!
记住,要先解压1,再解压2
[oracle@mytest database]$ ./runInstaller
--1,选择skip software update
--2,选择install database software only
--3,选择single instance database installation
--4,以下动作基本是下一步就行了
--5,软件检测时,同样是忽略kdpsh这个包,紧接着,下一步
--6,到最后,要安装root.sh
[root@mytest bin]# sh /u01/app/oracle/product/11.2.0/db1/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/db1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.

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.
至此,数据库软件安装完全结束,这时候,我们可以建数据库了!

8、创建dg,准备建数据库
[oracle@mytest database]$ export ORACLE_SID=+ASM
[oracle@mytest database]$ export ORACLE_HOME=/u01/app/grid/product/11.2.0/crs
[oracle@mytest database]$ cd $ORACLE_HOME
[oracle@mytest crs]$ cd bin
[oracle@mytest bin]$ ./sqlplus / as sysasm

SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 9 17:26:38 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage Management option

SQL> create diskgroup datadg1 external redundancy disk '/dev/raw/raw3' attribute 'au_size' = '2M';

Diskgroup created.

SQL> alter diskgroup datadg1 add disk '/dev/raw/raw4';

Diskgroup altered.

9、创建数据库
[oracle@mytest ~]# export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db1
[oracle@mytest ~]# dbca
--1,选择create database
--2,选择general purpose or transaction processing
--3,在storage type时,选择automatic storage mamagement(asm)
--4,use oracle-managed files 中,点击浏览,并选择刚才建的datadg1
--5,配置sga及pga,据自己物理内存及业务设定
--6,字符集,choose from the list of character sets 中选择zhs16gbk
--7,以后的安装基本是下一步
至此,所有安装都结束了!

 

 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29371470/viewspace-1062927/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-12-06

  • 博文量
    228
  • 访问量
    2684241