Oracle创建ASM的详细操作文档

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1830

本帖最后由 paulyi 于 2014-1-19 17:38 编辑

Oracle创建ASM数据库操作文档

1.首先在虚拟机器上安装rhel4 操作系统,安装完成后 关闭操作系统

2.添加4块硬盘 做asm磁盘 通过EDIT virtual machine setting
把鼠标移到hard disk 点击 add 按钮 分配大小为2g
按此操作 添加4块硬盘分别为SCSI 0:1 SCSI 0:2 SCSI 0:3 SCSI 0:4

3.下载ASMlib包和启动rh4 虚拟机器上的操作系统

去oracle官方网站下载对应内核的oracle asmlib管理包
http://otn.oracle.com/software/tech/linux/asmlib/ 选择对应的linux操作系统和内核包
[root@rac1 ~]# uname -r
2.6.9-42.ELsmp
[root@rac1 ~]# more /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
下载对应的asmlib有以下文件:
oracleasm-2.6.9-42.EL-2.0.3-1.i686.rpm
oracleasm-2.6.9-42.ELhugemem-2.0.3-1.i686.rpm
oracleasm-2.6.9-42.ELsmp-2.0.3-1.i686.rpm
oracleasmlib-2.0.2-1.i386.rpm
oracleasm-support-2.0.3-1.i386.rpm

4.用root用户创建oracle用户、组和存放oralcle软件路径
vi /etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 268435456
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
[root@rac1 etc]# groupadd dba
[root@rac1 etc]# groupadd oinstall
[root@rac1 etc]# useradd -g oinstall -G dba oracle
[root@rac1 etc]# mkdir -p /oracle/product/10.2/db
[root@rac1 etc]# chown oracle:oinstall /oracle/product/10.2/db
[root@rac1 etc]# chown -R oracle:oinstall /oracle/product/10.2/db
[root@rac1 etc]# chmod -R 755 /oracle/product/10.2/db
[root@rac1 10.2]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

5.安装ASMlib包和创建asm需要的磁盘 需要root身份登录
[root@rac1 RPMS]# rpm -Uvh /ASMlib/oracleasm*
error: Failed dependencies:
kernel-hugemem = 2.6.9-42.EL is needed by oracleasm-2.6.9-42.ELhugemem-2.0.3-1.i686
Suggested resolutions:
kernel-hugemem-2.6.9-42.EL.i686.rpm
[root@rac1 RPMS]# rpm -Uvh kernel-hugemem-2.6.9-42.EL.i686.rpm
warning: kernel-hugemem-2.6.9-42.EL.i686.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:kernel-hugemem ########################################### [100%]
[root@rac1 RPMS]# rpm -Uvh /ASMlib/oracleasm*
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [ 20%]
2:oracleasm-2.6.9-42.ELsm########################################### [ 40%]
3:oracleasm-2.6.9-42.EL ########################################### [ 60%]
4:oracleasm-2.6.9-42.ELhu########################################### [ 80%]
5:oracleasmlib ########################################### [100%]

6.配置ASMlib
[root@rac1 etc]# /etc/init.d/oracleasm config
Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@rac1 etc]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]

[root@rac1 etc]# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: [ OK ]
Unmounting ASMlib driver filesystem: [ OK ]
Unloading module "oracleasm": [ OK ]
[root@rac1 etc]# /etc/init.d/oracleasm enable
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
可以用以下方法检查asm进程启动没
[root@rac1 ~]# lsmod | grep oracleasm
oracleasm 48020 1
[root@rac1 ~]# dmesg | grep oracleasm
ASM: oracleasmfs mounted with options:

7.创建ASM磁盘 首先对新建的那四个磁盘划分主分区 但不格式化 如果格式化后 会导致创建asm磁盘不成功
在新添加的硬盘成功后 在/dev目录下会自动命名为devsdb,sdc,sde,sdf 依此类推,下面我们对这四个硬盘进行分区
[root@rac1 dev]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 dev]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): p
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 261 2096451 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 dev]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): p
Disk /dev/sdd: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 261 2096451 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rac1 dev]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w^H^H
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
开始创建ASM磁盘
[root@rac1 dev]# /etc/init.d/oracleasm createdisks VOL1 /dev/sdc1
Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@rac1 dev]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [ OK ]
[root@rac1 dev]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
[root@rac1 dev]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
[root@rac1 dev]# /etc/init.d/oracleasm createdisk VOL4 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]
查看asm磁盘 创建成功
[root@rac1 dev]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
[root@rac1 dev]#

8.安装oracle 10g r2 软件 这里选择 install database software only 注意oracle要求的包要安装齐全 否则安装软件过程中会出错
vi /home/oracle/.bash_profile 加上以下环境变量
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2/db; export ORACLE_HOME
ORACLE_SID=orcl; 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

[oracle@rac1 database]$ ./runInstaller
You do not have sufficient permissions to access the inventory '/u01/app/oracle/oraInventory'.
Installation cannot continue. Make sure that you have read/write permissions to the inventory directory and
restart the installer.: No such file or directory
[root@rac1 etc]# more oraInst.loc
inventory_loc=/u01/app/oracle/oraInventory
inst_group=oinstall
[root@rac1 etc]# rm oraInst.loc
rm: remove regular file `oraInst.loc'? y
删除后就可正常安装了
在软件安装结束后
以后再通过dbca 来创建ASM 实例和数据库。

9.创建ASM实例
1. 创建初始化文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ vi init+ASM.ora
创建asm 实例的初始化脚本,脚本内容如下所示:
# ******Below is init script. for asm instance******
*.asm_diskstring='ORCL:VOL*'
*.background_dump_dest='/oracle/admin/+ASM/bdump'
*.core_dump_dest='/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/oracle/admin/+ASM/udump'
# ******Above is init script. for asm instance******
2. 创建密码文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw+ASM password=dba
3. 创建目录结构
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ mkdir –p $ORALCE_BASE/admin/+ASM/udump
$ mkdir –p $ORALCE_BASE/admin/+ASM/bdump
$ mkdir –p $ORALCE_BASE/admin/+ASM/cdump
4. 启动实例
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
[oracle@rac1 dbs]$ export ORACLE_SID=+ASM
[oracle@rac1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jun 23 11:48:43 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-29701: unable to connect to Cluster Manager
用root身份登录 解决ora-29701错误
[root@d10031 bin]# pwd
/oracle/product/10.2/db/bin
[root@d10031 bin]# ./localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
d10031
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

SQL> startup
ASM instance started
Total System Global Area 100663296 bytes
Fixed Size 777616 bytes
Variable Size 99885680 bytes
Database Buffers 0 bytes
Redo Buffers 0 bytes
ORA-15110: no diskgroups mounted
因为我们是首次启动asm 实例,还没有创建diskgroup,所以显示15110 错误是正常的。

10. 创建spfile,重新启动
SQL> create spfile from pfile;
SQL> shutdown immediate;
SQL> startup;
6. 创建diskgroup
SQL> create diskgroup dgroup1 normal redundancy
2 failgroup fgroup1 disk 'ORCL:VOL1','ORCL:VOL2'
3 failgroup fgroup2 disk 'ORCL:VOL3','ORCL:VOL4';
Diskgroup created.
SQL> col name for a10
SQL> select name,state from v$asm_diskgroup;
NAME STATE
---------- ----------------------
DGROUP1 MOUNTED
如果上述命令返回的state 是DISMOUNTED,那么我们需要手工将挂载diskgroup
SQL> ALTER DISKGROUP dgroup1 MOUNT;
Diskgroup altered.
此时检查数据库初始化参数,发现asm_diskgroups 参数值已经自动设置为DGROUP1,
这表明在下次启动asm 实例的时候,这个diskgroup 会被自动挂载。
SQL> col name for a10
SQL> col type for a10
SQL> col value for a20
SQL> show parameter asm_diskgroups
NAME TYPE VALUE
------------------------------------ ---------- ------------------------------
asm_diskgroups string DGROUP1
如果要卸载diskgroup,使用下面的命令:
ALTER DISKGROUP ALL DISMOUNT;
10.创建ASM 数据库
用dbca 创建数据库
选择asm存储和创建好的DGROUP1 其他都一样

11.启动ASM 数据库的步骤由于启动ASM 数据库必须要先启动ASM 实例,所以基本上启动步骤如下。1. 以oracle 用户进入操作系统2. $ export ORACLE_SID=+ASM3. SQL> sqlplus / as sysdba4. SQL> startup5. SQL> exit6. $ export ORACLE_SID=ORCL7. SQL> sqlplus / as sysdba8. SQL> startup

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】