Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

38
1 / 38 QQ:5210377 www.royalwzy.com ASM 上安装和配置 11gR2 1. 实验目标 1. 为安装 Grid Infrastructure Oracle Database Installation 分别创建 OS 组和 OS 用户; 2. 安装 Oracle Grid Infrastructure 11gR2,安装和开启 OHAS 服务,使用 OUI ASM 实例和磁盘组; 3. 11gr2 数据库软件的安装和基于 ASM 的数据库的创建; 4. 注意:如果要使用 11gR2 ASM 创建 10gR2 或者 11gR1 的数据库,在执行 dbca 之前 要设置 ASM GID 参数到数据库内核($ORACLE_HOME/bin/oracle); 2. 实验环境 1. OS:RHEL5.3; 2. kernel:2.6.18-128.el5; 3. hostname:singleton.snda.com; 4. ip:192.168.10.112; 5. RAM:2g(grid infrastructure 最小 1.5g,grid infrastructure for rac 最小 2.5g); 6. swap:2g; 3. 安装 grid oracle database 的准备工作: 1. 创建 oinstall,dba,oper,asmadmin,asmdba,asmoper 用户组和 grid,oracle 用户;(11gR2 Grid Infrastructure Standalone(non-RAC)配置中,grid 用户必须在 OSDBA(dba)的系统组中,因为 grid 的组件必须可以以 SYSDBA 的角色开 启和停止数据 ;) 2. 创建安装 grid oracle 的目 ; 3. 安装 ASMLib(Linux Only) 1. 下载 ASMLib RMPs:下载的版本必须跟内核版本一 ;

description

Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

Transcript of Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

Page 1: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

1 / 38 QQ:5210377 www.royalwzy.com

在 ASM上安装和配置 11gR2

1. 实验目标

1. 为安装 Grid Infrastructure和 Oracle Database Installation分别创建 OS

组和 OS用户;

2. 安装 Oracle Grid Infrastructure 11gR2,安装和开启 OHAS服务,使用 OUI创

建 ASM实例和磁盘组;

3. 11gr2数据库软件的安装和基于 ASM的数据库的创建;

4. 注意:如果要使用 11gR2的 ASM创建 10gR2或者 11gR1的数据库,在执行 dbca之前

要设置 ASM GID参数到数据库内核($ORACLE_HOME/bin/oracle);

2. 实验环境

1. OS:RHEL5.3;

2. kernel:2.6.18-128.el5;

3. hostname:singleton.snda.com;

4. ip:192.168.10.112;

5. RAM:2g(装 grid infrastructure最小 1.5g,装 grid infrastructure for rac

最小

2.5g);

6. swap:2g;

3. 安装 grid和 oracle database的准备工作:

1. 创建 oinstall,dba,oper,asmadmin,asmdba,asmoper用户组和 grid,oracle

用户;(在 11gR2 Grid Infrastructure Standalone(non-RAC)配置中,grid

用户必须在 OSDBA(dba)的系统组中,因为 grid的组件必须可以以 SYSDBA的角色开

启和停止数据

库;)

2. 创建安装 grid和 oracle的目

录;

3. 安装 ASMLib(Linux Only)

1. 下载 ASMLib RMPs:下载的版本必须跟内核版本一

致;

Page 2: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

2 / 38 QQ:5210377 www.royalwzy.com

2. 安装 ASMLib RMPs:rpm -Uvh oracleasm*,安装和操作说

明;

Page 3: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

3 / 38 QQ:5210377 www.royalwzy.com

4. 添加 3块 5G的 SCSI硬盘/dev/sd[b-d],每块硬盘只创建一个分区

/dev/sd[b-d]1;

5. 安装 Oracle ASMLib:service oracleasm configure;(我们可以使用 ASMLIB

磁盘,裸设备,块磁盘,LUNs或者 NAS设备,这些都必须属于 grid用户和 asmadmin组.

因为采用的是角色分离,所以 ASM磁盘的拥有者应该是

grid:asmadmin;)

6. 启动 asm:service oracleasm

start;

Page 4: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

4 / 38 QQ:5210377 www.royalwzy.com

7. 在 3块 SCSI磁盘分区上创建 ASMLIB磁

盘;

8. 上传 grid和数据库软件并解压,grid软件和 database软件要版本一致(此处都是

11.2.0.3,包 1和 2是 database软件,包 3是 grid软

件);

9. 安装必要的包:yum -y install 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 sysstat unixODBC

unixODBC-devel;

10. 修改内核参数文件

/etc/sysctl.conf;

Page 5: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

5 / 38 QQ:5210377 www.royalwzy.com

11. 修改用户限制

/etc/security/limits.conf;

12. 修改安全设置

/etc/pam.d/login;

13. 配置 grid用户的环境变量:su -

grid;

Page 6: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

6 / 38 QQ:5210377 www.royalwzy.com

14. 配置 oracle用户的环境变量:su -

oracle;

4. 11gR2 Grid Infrastructure Oracle Home Installation:

1. 切换到 grid用户下运行 OUI(Oracle Universal

Installer);

2. 为一个单独的服务器安装和配置 Grid Infrastructure(第二个选项和第四个选项的

区别在于:第二个选项安装的时候必须配置 ASM磁盘组,而第四个选项可以先不配置,之

Page 7: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

7 / 38 QQ:5210377 www.royalwzy.com

后使用 asmca配置,可以用于文件系统以后转 ASM时候使

用);

3. 选择安装的语言,默认是英语,可以选择简体中文;

4. 创建磁盘组,创建一个名为 DATA的磁盘组,正常冗余,组成员有 ORCL:ASMDISK1和

ORCL:ASMDISK2 ASMLIB磁

Page 8: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

8 / 38 QQ:5210377 www.royalwzy.com

盘;

Page 9: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

9 / 38 QQ:5210377 www.royalwzy.com

5. 为 ASM和 ASMSNMP用户设置密

码;

Page 10: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

10 / 38 QQ:5210377 www.royalwzy.com

6. 为 ASM数据库管理员指定相应的 OS

组;

Page 11: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

11 / 38 QQ:5210377 www.royalwzy.com

7. 指定 ORACLE_BASE和 ORACLE_HOME目录,会自动读取环境变量

的;

8. 指定 Oracle Inventory的目录,自动会自动检测放在 ORACLE_BASE目录下(检测的

时候如果有内核参数的问题可以通过执行 Fix&Check Again来修复,如果缺少包的话

需要自己安装);

Page 12: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

12 / 38 QQ:5210377 www.royalwzy.com

9. 安装前检查,以及安装的摘

要;

10. 走进度安装,在 root用户下执行相应的脚本(会拷贝一些工具;创建 OLR;在

/etc/inittab中添加开机启动,并运行 ohasd进

程;);

Page 13: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

13 / 38 QQ:5210377 www.royalwzy.com

Page 14: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

14 / 38 QQ:5210377 www.royalwzy.com

Page 15: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

15 / 38 QQ:5210377 www.royalwzy.com

11. 完成安

装;

12. 验证 OHAS和 CSS服务是否开启并且在运行:crsctl check has;crsctl check

css;

Page 16: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

16 / 38 QQ:5210377 www.royalwzy.com

13. 验证 ASM实例开启并且正在运行: ps -fea | grep asm_ | grep -v

grep;

Page 17: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

17 / 38 QQ:5210377 www.royalwzy.com

Page 18: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

18 / 38 QQ:5210377 www.royalwzy.com

5. 创建 RECO磁盘组:

1. 图形界面下运行 asmca,在

ORCL:ASMDISK3(/dev/oracleasm/disks/ASMDISK3)ASMLIB磁盘上来创建一个

RECO磁盘

组;

Page 19: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

19 / 38 QQ:5210377 www.royalwzy.com

2. 点击创建按

钮;

3. 使用 ORCL:ASMDISK3创建一个名为 RECO的磁盘组(作为外部的冗余磁盘组),点击高

级选项,显示 AU和 Compatibility属性(ASM Compatibility表示可以访问此 ASM

磁盘组的 grid软件的最低版本;Database Compatibility表示能把文件放在此

ASM磁盘组的数据库最低版本;ADVM Compatibility表示操作 ASM磁盘的 ADVM软

件的最低版

Page 20: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

20 / 38 QQ:5210377 www.royalwzy.com

本);

Page 21: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

21 / 38 QQ:5210377 www.royalwzy.com

4. 查看结

果;

6. 11.2.0.3 RMDBS实例和数据库的安装;

1. 内核参数,环境变量,安全设置,用户限制在前面已经设置;

2. 在 oracle用户下执行 OUI来安装 11gR2实

例;

Page 22: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

22 / 38 QQ:5210377 www.royalwzy.com

3. 安装实例和数据库(推荐选择下面只安装实例,之后再创建数据

库);

Page 23: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

23 / 38 QQ:5210377 www.royalwzy.com

4. 选择 Server

class;

Page 24: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

24 / 38 QQ:5210377 www.royalwzy.com

5. 仅仅只安装一个实

例;

Page 25: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

25 / 38 QQ:5210377 www.royalwzy.com

6. 选择高级安装,自己定义安装内

容;

Page 26: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

26 / 38 QQ:5210377 www.royalwzy.com

7. 指定 ORACLE_BASE和 ORACLE_HOME,会自动读取环境变量

的;

Page 27: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

27 / 38 QQ:5210377 www.royalwzy.com

8. 指定 ORACLE_SID和全局服务名

称;

Page 28: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

28 / 38 QQ:5210377 www.royalwzy.com

9. 选择字符集和安装示例数据

库;

Page 29: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

29 / 38 QQ:5210377 www.royalwzy.com

10. 最重要的一步,指定数据库的存储选项,选择 ASM,并指定 ASMSNMP用户的密

码;

Page 30: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

30 / 38 QQ:5210377 www.royalwzy.com

11. 选择磁盘

组;

Page 31: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

31 / 38 QQ:5210377 www.royalwzy.com

12. 只用 oracle用户的密码,安装前检查,和概要信

息;

Page 32: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

32 / 38 QQ:5210377 www.royalwzy.com

13. 安装走进度,在 root用户下执行脚本,直到安装完

成;

Page 33: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

33 / 38 QQ:5210377 www.royalwzy.com

14. 访问数据库:select dbid, name, open_mode, log_mode from v$database;;

Page 34: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

34 / 38 QQ:5210377 www.royalwzy.com

15. 访问 Enterprise Manager Database Control地

址:https://192.168.10.112:1158/em;

7. 如果要在11gR2的ASM上创建11gR1 or 10gR2的数据库,在执行dbca之前,应该设置ASM GID

到 oracle内核(<10.2 or 11.1 RDBMS Oracle Home>/bin/oracle executable);

1. 仅仅当 ORACLE_HOME是基于 11.2.0.1.0 or 11.2.0.1.2版本的 Grid

Infrastructure,需要安装 9575578补丁集;

2. 以 grid用户登录,然后设置数据库的 ASM GID,修改过之后 RDBMS

$ORACLE_HOME/bin/oracle文件属于 asmadmin组;

3. 运行 dbca创建数据库;

-- 查看内存和交换分区大小;

grep MemTotal /proc/meminfo;

grep SwapTotal /proc/meminfo;

Page 35: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

35 / 38 QQ:5210377 www.royalwzy.com

-- 创建 oinstall,dba,oper,asmadmin,asmdba,asmoper用户组;

groupadd oinstall;

groupadd dba;

groupadd oper;

groupadd asmadmin;

groupadd asmdba;

groupadd asmoper;

-- 创建 grid,oracle用户;

useradd -g oinstall -G asmadmin,asmdba,asmoper,dba grid;

useradd -g oinstall -G dba,asmdba,oper oracle;

-- 创建 grid和 oacle的软件目录;

mkdir -p /u01/app/grid;

mkdir -p /u01/app/grid/product/11.2.0/grid

chown -R grid:oinstall /u01;

mkdir -p /u01/app/oracle;

mkdir -p /u01/app/oracle/product/11.2.0/db_1

chown -R oracle:oinstall /u01/app/oracle;

chmod -R 775 /u01;

-- 配置 ASM;

/etc/init.d/oracleasm configure;

or

service oracleasm configure;

-- 启动 ASM;

/etc/init.d/oracleasm start;

or

service oracleasm start;

-- 创建 ASMLIB磁盘;

/etc/init.d/oracleasm createdisk ASMDISK1 /dev/sdb1;

/etc/init.d/oracleasm createdisk ASMDISK2 /dev/sdc1;

/etc/init.d/oracleasm createdisk ASMDISK3 /dev/sdd1;

or

service oracleasm createdisk ASMDISK1 /dev/sdb1;

service oracleasm createdisk ASMDISK2 /dev/sdc1;

service oracleasm createdisk ASMDISK3 /dev/sdd1;

-- 列出 ASM磁盘;

/etc/init.d/oracleasm listdisks;

or

Page 36: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

36 / 38 QQ:5210377 www.royalwzy.com

service oracleasm listdisks;

-- 检查 ASM磁盘;

/etc/init.d/oracleasm querydisk ASMDISK1;

/etc/init.d/oracleasm querydisk ASMDISK2;

/etc/init.d/oracleasm querydisk ASMDISK3;

or

service oracleasm querydisk ASMDISK1;

service oracleasm querydisk ASMDISK2;

service oracleasm querydisk ASMDISK3;

-- root用户修改内核参数文件/etc/sysctl.conf;sysctl -p;

fs.suid_dumpable = 1

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

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

-- root用户修改用户限制/etc/security/limits.conf;

grid soft nproc 2047

grid hard nproc 16384

grid soft nofile 4096

grid hard nofile 65536

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 4096

oracle hard nofile 65536

-- root用户修改安全设置/etc/pam.d/login;

session required /lib/security/pam_limits.so

session required pam_limits.so

-- grid用户的环境变量.bash_profile

ORACLE_HOSTNAME=singleton.snda.com

ORACLE_SID=+ASM

ORACLE_BASE=/u01/app/grid

Page 37: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

37 / 38 QQ:5210377 www.royalwzy.com

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/grid

PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib

CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export ORACLE_HOSTNAME ORACLE_SID ORACLE_BASE ORACLE_HOME PATH LD_LIBRARY_PA

TH CLASSPATH

umask 022

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

alias ggsci='rlwrap ggsci'

-- oracle用户的环境变量.bash_profile

ORACLE_HOSTNAME=singleton.snda.com

ORACLE_SID=orcl

ORACLE_UNQNAME=orcl

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export ORACLE_HOSTNAME ORACLE_SID ORACLE_UNQNAME ORACLE_BASE ORACLE_HOME PATH

LD_LIBRARY_PATH CLASSPATH

umask 022

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

alias ggsci='rlwrap ggsci'

-- 验证 OHAS和 CSS服务是否开启并且在运行;

crsctl check has;

crsctl check css;

crsctl stat res;

-- 验证 ASM实例开启并且正在运行;

ps -fea | grep asm_ | grep -v grep;

sqlplus / as sysasm

show parameter instance_name

select name, state from v$asm_diskgroup;

select name, path from v$asm_disk;

srvctl status asm

srvctl status listener

Page 38: Installation and configuration 11g r2 asm using job role separation(grid & oracle os users)

38 / 38 QQ:5210377 www.royalwzy.com

-- 设置 ASM GID;

$> su - grid

$> id

$> <Oracle Grid Home>/bin/setasmgidwrap o=<10.2 or 11.1 RDBMS DB Oracle Home

>/bin/oracle

$> ls –l <10.2 or 11.1 RDBMS DB Oracle Home>/bin/oracle