Linux环境的Oracle11gR2(ASM)的单实例搭建安装

来源:互联网 时间:1970-01-01

本次演示是在linux环境下安装oracle11gR2数据库的操作,包括grid,asm等


环境: VM + rhel6.3 + oracle11gR2 + grid


Rhel6安装包:rhel-server-6.3-x86_64-dvd.iso

oracle11gR2安装包:p13390677_112040_Linux-x86-64_1of7.zip      p13390677_112040_Linux-x86-64_2of7.zip

grid安装包:linux.x64_11gR2_grid.zip

 

rhel6 安装包目录为:   /setup/rhel6Setup

oracle安装包目录为:  /setup/oracleSetup

grid安装包目录为:   /setup/gridSetup

 

一:安装linux


1)linux安装包

  • Base System > Base
  • Base System > Client management tools
  • Base System > Compatibility libraries
  • Base System > Hardware monitoring utilities
  • Base System > Large Systems Performance
  • Base System > Network file system client
  • Base System > Performance Tools
  • Base System > Perl Support
  • Servers > Server Platform
  • Servers > System administration tools
  • Desktops > Desktop
  • Desktops > Desktop Platform
  • Desktops > Fonts
  • Desktops > General Purpose Desktop
  • Desktops > Graphical Administration Tools
  • Desktops > Input Methods
  • Desktops > X Window System
  • Development > Additional Development
  • Development > Development Tools
  • Applications > Internet Browser



二:安装准备


1)修改 /etc/hosts文件

[[email protected] Server]# more /etc/hosts127.0.0.1 localhost.localdomain localhost::1 localhost6.localdomain6 localhost6192.168.1.102 localhost.localdomain localhost

 

2)修改防火墙设置

重启后生效

开启: chkconfig iptables on

关闭: chkconfig iptables off


即时生效,重启后失效

开启: service iptables start

关闭: service iptables stop



3)修改 /etc/selinux/config文件

SELINUX=disabled

4)指定本地yum源

对/etc/yum.repos.d/rhel-source.repo 进行修改

[[email protected] ~]# vi /etc/yum.repos.d/rhel-source.repo[rhel-source]name=Red Hat Enterprise Linux $releasever -$basearch - Sourcebaseurl=file:///setup/rhel6Setup/Serverenabled=1gpgcheck=1gpgkey=file:///setup/rhel6Setup/RPM-GPG-KEY-redhat-release

5)添加内核参数  /etc/sysctl.conf

fs.suid_dumpable = 1fs.aio-max-nr = 1048576 --文件系统最大异步iofs.file-max = 6815744 --文件系统中最大文件个数#kernel.shmall = 2097152#kernel.shmmax = 536870912kernel.shmmni = 4096 --最小共享内存大小 bytes# semaphores: semmsl, semmns, semopm,semmnikernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500 --端口的范围net.core.rmem_default=262144net.core.rmem_max=4194304net.core.wmem_default=262144net.core.wmem_max=1048586

修改完成后执行 /sbin/sysctl -p  

 

6)添加 /etc/security/limits.conf

oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240grid soft nproc 2047grid hard nproc 16384grid soft nofile 1024grid hard nofile 65536grid soft stack 10240

7)添加oracle和grid用户和组

添加用户组

groupadd -g 501 oinstallgroupadd -g 502 dbagroupadd -g 503 opergroupadd -g 504 asmadmingroupadd -g 505 asmopergroupadd -g 506 asmdba

添加用户

useradd -u 501 -g oinstall -Gdba,asmdba,oper oracleuseradd -u 502 -g oinstall -Gasmadmin,asmdba,asmoper,oper,dba grid

更改用户密码

passwd oraclepasswd grid

 

8)添加目录和权限

mkdir -p /u01/app/oracle/product/11.2.0/db_1chown -R oracle:oinstall /u01/app/oraclemkdir -p /u01/app/grid/11.2.0chown -R grid:oinstall /u01/app/gridchmod -R 775 /u01mkdir -p /u01/app/oraInventorychown -R grid:oinstall/u01/app/oraInventory/

9)添加Oracle和grid环境变量    

切换oracle用户,并添加目录下的.bash_profile文件

export ORACLE_SID=orclexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export LD_LIBRARY_PATH=$ORACLE_HOME/libexport PATH=$PATH:$ORACLE_HOME/binexport TMP=/tmpexport TMPDIR=$TMPumask 022

切换grid用户,并添加目录下的.bash_profile文件

export ORACLE_SID=+ASMexport ORACLE_BASE=/u01/app/gridexport ORACLE_HOME=/u01/app/grid/11.2.0export LD_LIBRARY_PATH=$ORACLE_HOME/libexport PATH=$PATH:$ORACLE_HOME/binumask 022

10)udev绑定磁盘  ASM

VM虚拟机添加新硬盘4个

 

 

查看磁盘情况,上面新增的4个磁盘对应如下 sdb,sdc,sdd,sde

 

 

格式化磁盘,以sdb举例

 

 

再次查看已格式化好的磁盘

 

查看磁盘信息,我这里取出KERNEL,SUBSYSTEM,START,SIZE作为规则

 

添加规则 /etc/udev/rules.d/99-oracle-asmdevices.rules 文件

[[email protected] rules.d]# vi /etc/udev/rules.d/99-oracle-asmdevices.rulesKERNEL=="sdb1",SUBSYSTEM=="block", SYSFS{size}=="10474317",SYSFS{start}=="63", NAME="asm-diskb",OWNER="grid", GROUP="asmdba", MODE="0660"KERNEL=="sdc1",SUBSYSTEM=="block", SYSFS{size}=="10683162",SYSFS{start}=="63", NAME="asm-diskc",OWNER="grid", GROUP="asmdba", MODE="0660"KERNEL=="sdd1",SUBSYSTEM=="block", SYSFS{size}=="10892007",SYSFS{start}=="63", NAME="asm-diskd",OWNER="grid", GROUP="asmdba", MODE="0660"KERNEL=="sde1",SUBSYSTEM=="block", SYSFS{size}=="11100852",SYSFS{start}=="63", NAME="asm-diske",OWNER="grid", GROUP="asmdba", MODE="0660" 

重启udev

[[email protected] rules.d]# start_udevStarting udev: [ OK ]

查看绑定的asm磁盘

[[email protected] ~]# ll /dev/asm*brw-rw---- 1 grid asmdba 8, 17 Oct 21 23:11/dev/asm-diskbbrw-rw---- 1 grid asmdba 8, 33 Oct 21 23:11/dev/asm-diskcbrw-rw---- 1 grid asmdba 8, 49 Oct 21 23:11/dev/asm-diskdbrw-rw---- 1 grid asmdba 8, 65 Oct 21 23:11/dev/asm-diske



三:GI安装


1)解压grid

[[email protected] grid]# unzip linux.x64_11gR2_grid.zip

2)切换grid用户,安装GI

[[email protected] grid]# su – grid[[email protected] grid]# xhost +[[email protected] grid]$ ./runInstaller

只安装GI软件,下一步

 


添加简体中文,下一步

 

 

下一步



环境变量已配置过,下一步


 

环境变量已配置过,下一步




检查

 

 

检查失败的项,需要安装缺失的包




有一些系统的包的版本已超过要求的,可忽略,下一步

 


完成,开始安装



安装中

 


已root身份执行以下脚本


第一个脚本:

[[email protected] ~]#/u01/app/oraInventory/orainstRoot.shChanging permissions of/u01/app/oraInventory.Adding read,write permissions for group.Removing read,write,execute permissions forworld.Changing groupname of /u01/app/oraInventoryto oinstall.The execution of the script is complete.

第二个脚本:

[[email protected] ~]#/u01/app/grid/11.2.0/root.sh

Running Oracle 11g root.sh script...

 

The following environment variables are setas:

   ORACLE_OWNER= grid

   ORACLE_HOME=  /u01/app/grid/11.2.0

 

Enter the full pathname of the local bindirectory: [/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/oratabfile as needed by

Database Configuration Assistant when adatabase is created

Finished running generic part of root.shscript.

Now product-specific root actions will beperformed.

To configure GridInfrastructure for a Stand-Alone Server run the following command as the rootuser:

/u01/app/grid/11.2.0/perl/bin/perl-I/u01/app/grid/11.2.0/perl/lib -I/u01/app/grid/11.2.0/crs/install/u01/app/grid/11.2.0/crs/install/roothas.pl

 

To configure Grid Infrastructure for aCluster perform the following steps:

1. Provide values for Grid Infrastructureconfiguration parameters in the file -/u01/app/grid/11.2.0/crs/install/crsconfig_params. For details on how to dothis, see the installation guide.

2. Run the following command as the rootuser:

 /u01/app/grid/11.2.0/perl/bin/perl -I/u01/app/grid/11.2.0/perl/lib-I/u01/app/grid/11.2.0/crs/install /u01/app/grid/11.2.0/crs/install/rootcrs.pl

To update inventory properties for GridInfrastructure, perform the following

steps. If a pre-11.2 home is alreadyconfigured, execute the following:

11.2_Home/oui/bin/runInstaller-updateNodeList -silent -local CRS=false ORACLE_HOME=pre-11.2_Home

Always execute the following to registerthe current home:

11.2_Home/oui/bin/runInstaller-updateNodeList -silent -local CRS=true ORACLE_HOME=11.2_Home.

If either home is shared, provide theadditional argument -cfs.


注:因为是单实例,所以要执行上述中红色代码的脚本

执行

[[email protected] ~]#/u01/app/grid/11.2.0/perl/bin/perl -I/u01/app/grid/11.2.0/perl/lib-I/u01/app/grid/11.2.0/crs/install /u01/app/grid/11.2.0/crs/install/roothas.pl

 

2015-10-22 00:01:06: Checking for superuser privileges

2015-10-22 00:01:06: User has super userprivileges

2015-10-22 00:01:06: Parsing the host name

Using configuration parameter file:/u01/app/grid/11.2.0/crs/install/crsconfig_params

Creating trace directory

LOCAL ADD MODE

Creating OCR keys for user 'grid', privgrp'oinstall'..

Operation successful.

CRS-4664: Node localhost successfullypinned.

Adding daemon to inittab

CRS-4123: Oracle High Availability Serviceshas been started.

ohasd is starting

ADVM/ACFS is not supported onredhat-release-server-6Server-6.3.0.3.el6.x86_64

 

localhost     2015/10/22 00:01:28    /u01/app/grid/11.2.0/cdata/localhost/backup_20151022_000128.olr

Successfully configured Oracle GridInfrastructure for a Standalone Server

 

附1:11.0.2.1版本GI的 BUG问题

在执行以下脚本时,11.0.2.1版本的GI有一个BUG会报错(11.2.0.3版本不存在这个问题)

[[email protected] ~]#/u01/app/grid/11.2.0/perl/bin/perl -I/u01/app/grid/11.2.0/perl/lib-I/u01/app/grid/11.2.0/crs/install /u01/app/grid/11.2.0/crs/install/roothas.pl

 

2015-10-22 00:01:06: Checking for superuser privileges

2015-10-22 00:01:06: User has super userprivileges

2015-10-22 00:01:06: Parsing the hostname

Using configuration parameter file: /u01/app/grid/11.2.0/crs/install/crsconfig_params

LOCAL ADD MODE

Creating OCR keys for user 'grid',privgrp 'oinstall'..

Operation successful.

CRS-4664: Node localhost successfullypinned.

Adding daemon toinittab

CRS-4124: Oracle HighAvailability Services startup failed. --报错

CRS-4000: Command Start failed, orcompleted with errors.

ohasd failed to start: Inappropriateioctl for device

ohasd failed to start: Inappropriateioctl for device at /u01/app/11.2.0/grid/crs/install/roothas.pl line 296.

 

解决方案:(重新配置crs)

首先回退之前的操作

[[email protected] ~]# /u01/app/grid/11.2.0/crs/install/roothas.pl  -deconfig  -force -verbose

 

重新执行脚本

[[email protected] ~]#/u01/app/grid/11.2.0/root.sh

 

[[email protected] ~]#/u01/app/grid/11.2.0/perl/bin/perl -I/u01/app/grid/11.2.0/perl/lib-I/u01/app/grid/11.2.0/crs/install /u01/app/grid/11.2.0/crs/install/roothas.pl

 

在上面一个脚本执行到Adding daemon to inittab 这一步骤时,新开一个窗口 执行如下脚本

[[email protected] ~]# /bin/ddif=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1

 


完成GI安装,关闭

 



四:ASM配置


配置ASM磁盘组

[[email protected] ~]$ asmca

密码及指定磁盘组,Specify Disk Group



指定磁盘路径,Change Disk Discovery Path , ok



建立磁盘组,这里选中三个磁盘,ok

 

 

创建ASM磁盘组,Create ASM

 

 

创建中

 

 

创建完成,ok

 


再创建一个FRA的磁盘组(闪回区),Create

 


创建FRA磁盘组,ok

 


创建中

 

 

创建完成,ok

 


数据和FRA磁盘组创建完成,Exit

 


通过grid用户执行crs_stat -t检查ASM是否安装好,如下所示正常。

[[email protected] ~]$ crs_stat -tName Type Target State Host ------------------------------------------------------------ora.DATA.dg ora....up.type ONLINE ONLINE localhost ora.FRA.dg ora....up.type ONLINE ONLINE localhost ora.asm ora.asm.type ONLINE ONLINE localhost ora.cssd ora.cssd.type ONLINE ONLINE localhost ora.diskmon ora....on.type ONLINE ONLINE localhost

测试登录asm,正常

[[email protected] ~]$ sqlplus / as sysasmSQL*Plus: Release 11.2.0.1.0 Production onThu Oct 22 00:44:27 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise EditionRelease 11.2.0.1.0 - 64bit ProductionWith the Automatic Storage Managementoption SQL> select name,total_mb from v$asm_diskgroup;NAME TOTAL_MB------------------------------ ----------DATA 15648FRA 5420



五:监听配置


1)建立监听

启动监听配置

[[email protected] ~]$ netmgr

 

监听

 


增加一个监听

 

 

监听配置

 


数据库服务

 

 


保存配置




2)监听配置文件


目录

[[email protected] admin]$ pwd/u01/app/grid/11.2.0/network/admin

查看文件

[[email protected] admin]$ lltotal 12-rw-r--r-- 1 grid oinstall 436 Oct 22 01:04 listener.oradrwxr-xr-x 2 grid oinstall 4096 Oct 2123:48 samples-rw-r--r-- 1 grid oinstall 187 May 7 2007 shrept.lst

查看监听配置文件

[[email protected] admin]$ more listener.ora# listener.ora Network Configuration File:/u01/app/grid/11.2.0/network/admin/listener.ora# Generated by Oracle configuration tools.SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/grid/11.2.0) (SID_NAME = orcl) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) )ADR_BASE_LISTENER = /u01/app/grid


3)启动监听


启动监听

[[email protected] ~]$ lsnrctl start

监听状态

[[email protected] ~]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 -Production on 22-OCT-2015 01:05:06Copyright (c) 1991, 2009, Oracle. All rights reserved.Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version11.2.0.1.0 - ProductionStart Date 22-OCT-2015 01:01:49Uptime 0 days 0 hr. 3 min. 16 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Log File /u01/app/grid/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for thisservice...The command completed successfully

 


六:Oracle安装


1)   解压oracle

unzip p13390677_112040_Linux-x86-64_1of7.zipunzip p13390677_112040_Linux-x86-64_2of7.zip

2)切换oracle用户,安装Oracle软件

[[email protected] database]# su - oracle[[email protected] database]# xhost +[[email protected] database]$ ./runInstaller

不需要邮件

 


只安装数据库软件



 

单实例




添加简体中文



 

企业版




之前环境变量设置过

 

 


 


检查




有一些系统的包的版本已超过要求的,可忽略

 

oracle安装信息




安装中




用root用户执行脚本



 

执行脚本

[[email protected] ~]#/u01/app/oracle/product/11.2.0/db_1/root.shRunning Oracle 11g root.sh script...The following environment variables are setas: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/product/11.2.0/db_1Enter the full pathname of the local bindirectory: [/usr/local/bin]:The file "dbhome" already existsin /usr/local/bin. Overwrite it? (y/n)[n]: y Copying dbhome to /usr/local/bin ...The file "oraenv" already existsin /usr/local/bin. Overwrite it? (y/n)[n]: y Copying oraenv to /usr/local/bin ...The file "coraenv" already existsin /usr/local/bin. Overwrite it? (y/n)[n]: y Copying coraenv to /usr/local/bin ...Entries will be added to the /etc/oratabfile as needed byDatabase Configuration Assistant when adatabase is createdFinished running generic part of root.shscript.Now product-specific root actions will beperformed.Finished product-specific root actions.

安装完成

 


3)安装数据库


启动dbca安装数据库

[or[email protected] database]# dbca

 



 创建一个数据库

 

 


实例:Orcl



 


创建密码

 


选择ASM磁盘组

 


RFA的ASM磁盘组

 

 

创建模板



字符集,16GBK

 

 

数据库存储信息



创建数据库




数据库信息




创建中

 

 

创建成功

 

 

 

查看一下数据文件

SQL> select file_name fromdba_data_files;FILE_NAME--------------------------------------------------------------------------------+DATA/orcl/datafile/users.259.893746475+DATA/orcl/datafile/undotbs1.258.893746475+DATA/orcl/datafile/sysaux.257.893746473+DATA/orcl/datafile/system.256.893746473+DATA/orcl/datafile/example.265.893746687

 

附2:重启服务器时,crs也需要重新启动


解决方案:(重新配置crs)

首先回退之前的操作

[[email protected] ~]# /u01/app/grid/11.2.0/crs/install/roothas.pl -deconfig -force -verbose

重新执行脚本

[[email protected] ~]#/u01/app/grid/11.2.0/root.sh 

[[email protected] ~]#/u01/app/grid/11.2.0/perl/bin/perl -I/u01/app/grid/11.2.0/perl/lib-I/u01/app/grid/11.2.0/crs/install /u01/app/grid/11.2.0/crs/install/roothas.pl

在上面一个脚本执行到Adding daemon to inittab 这一步骤时,新开一个窗口 执行如下脚本

[[email protected] ~]# /bin/ddif=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1

然后grid用户下启动

crs_start -allcrs_start -tcrsctl check csscrsctl check has 

之后启动grid实例时,找不到磁盘组

SQL> startupORA-00099: warning: no parameter filespecified for ASM instanceASM instance startedTotal System Global Area 283930624 bytesFixed Size 2212656 bytesVariable Size 256552144 bytesASM Cache 25165824 bytesORA-15110: no diskgroups mounted

解决方案:(添加参数文件如下)

[[email protected] dbs]$ vi init+ASM.oraasm_diskstring='/dev/asm*'asm_diskgroups='DATA'asm_power_limit=1diagnostic_dest='/u01/app/grid'instance_type='asm'large_pool_size=12Mremote_login_passwordfile='EXCLUSIVE'

添加asm

[[email protected] dbs]$ srvctl add asm

这时查看crs中就有了ora.asm

[[email protected] dbs]$ crs_stat -tName Type Target State Host ------------------------------------------------------------ora.asm ora.asm.type ONLINE ONLINE localhost ora.cssd ora.cssd.type ONLINE ONLINE localhost ora.diskmon ora....on.type ONLINE ONLINE localhost

创建一个spfile参数文件

SQL> create spfile from pfile;File created.

查看参数文件

[[email protected] dbs]$ lsab_+ASM.dat hc_+ASM.dat init+ASM.ora init.ora orapw+ASM spfile+ASM.ora

关闭grid

SQL> shutdown immediateORA-15100: invalid or missing diskgroupnameASM instance shutdown

重新启动

SQL> startupASM instance startedTotal System Global Area 283930624 bytesFixed Size 2212656 bytesVariable Size 256552144 bytesASM Cache 25165824 bytesASM diskgroups mounted

可以查看asm磁盘组的信息了

SQL> show parameter asm;NAME TYPE VALUE----------------------------------------------- ------------------------------asm_diskgroups string DATAasm_diskstring string /dev/asm*asm_power_limit integer 1asm_preferred_read_failure_groups string

查看具体的asm磁盘组信息,发现fra没有mount

SQL> selectname,type,state,total_mb,free_mb from v$asm_diskgroup;NAME TYPE STATE TOTAL_MB FREE_MB------------------------------ ----------------- ---------- ----------DATA EXTERN MOUNTED 15648 15585FRA DISMOUNTED 0 0

把FRA磁盘组mount

SQL> alter diskgroup FRA mount;Diskgroup altered.

 

附3:udev的规则(uuid唯一值方式)


Uuid确定唯一值

编辑/etc/scsi_id.config 文件,如果该文件不存在,则创建该文件并添加如下行:

[[email protected] ~]# vi/etc/scsi_id.configoptions=--whitelisted--replace-whitespace 

关机,修改VM虚拟机的配置文件:

E:/vm虚拟机/lalala/rhel6.3_oracle11R2.vmx

 

使用文本编辑器编辑该文件,在尾部新增一行参数:

disk.EnableUUID="TRUE" 

查找uuid

[[email protected] ~]# scsi_id--whitelisted --replace-whitespace --device=/dev/sdb36000c29fbe57659626ee89b4fba07616 --uuid

添加硬盘的规则如下:

KERNEL=="sd*",SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted--replace-whitespace --device=/dev/$name",RESULT=="6000c29fbe57659626ee89b4fba07616",NAME="asm-diskb", OWNER="grid",GROUP="asmadmin",MODE="0660" 

 

 

 




相关阅读:
Top