1. 首页
  2. IT资讯

asm命令及安装

OS Version RHEL4 U4 2.6.9-42 ASM是ORACLE10G引入的一项新的存储管理技术,借助一个新增的ASM实例来实现对原始设备的管理,多个原始设备被组织为一个或多个ASM磁盘卷组,存储的操作以ASM磁盘卷组为单位进行,

所需软件包:oracleasm-support-2.0.3-1.i386.rpmoracleasm-2.6.9-42.EL-2.0.3-1.i686.rpmoracleasmlib-2.0.2-1.i386.rpm

2、配置ASMLib#/etc/init.d/oracleasm configureDefault user to own the driver interface [oracle]: oracleDefault group to own the driver interface [oinstall]: oinstallStart Oracle ASM library driver on boot (y/n) [y]: yFix permissions of Oracle ASM disks on boot (y/n) [y]: yWriting Oracle ASM library driver configuration: [ OK ]Loading module “oracleasm”: [ OK ]Mounting ASMlib driver filesystem: [ OK ]Scanning system for ASM disks: [ OK ]

Zx:#ls -l /etc/init.d/*asm*-rwxr-xr-x 1 root root 1861 Jul 6 2006 /etc/init.d/ibmasm-rwxr-xr-x 1 root root 18084 Jul 25 2006 /etc/init.d/oracleasm

查看oracleasm启动时是否被加载:#cd /etc/rc3.dls -l /etc/rc3.d/*oracleasm

查看ASM命令选项:# /etc/init.d/oracleasm

若服务没有加载加入链接:#ln -s ../init.d/oracleasm S29oracleasm#ln -s ../init.d/oracleasm K01oracleasm

创建ASM磁盘:[root@dbrac bin]# service oracleasm createdisk vol19 /dev/hda19Marking disk “/dev/hda19” as an ASM disk: [ OK ][root@dbrac bin]# service oracleasm createdisk vol20 /dev/hda20Marking disk “/dev/hda20” as an ASM disk: [ OK ]

查看ASM磁盘:[root@dbrac bin]# /etc/init.d/oracleasm listdisksVOL19VOL20

如何查看ASM磁盘VOL19中有哪些设备:[root@dbrac bin]# service oracleasm querydisk VOL19Disk “VOL19” is a valid ASM disk on device [3, 19]

[root@dbrac bin]# ls -l /dev/hda* | grep ‘3, 19’brw-rw—- 1 root disk 3, 19 Apr 20 2010 /dev/hda19

修改oracleasm脚本看看ASM信息写在系统什么位置:vi /etc/init.d/oracleasm/listdisks

listdisks) if [ -d “${ORACLE_ASMMANAGER}/disks/” ] then ls -1 “${ORACLE_ASMMANAGER}/disks/” # echo “${ORACLE_ASMMANAGER} = ${ORACLE_ASMMANAGER} ” #将信息打印出来 fi ;;

[root@stu6 ~]# service oracleasm listdisksVOL19VOL20${ORACLE_ASMMANAGER} = /dev/oracleasm #打印出来了吧!原来ASM信息写在这!

[root@dbrac bin]# cd /dev/oracleasm[root@dbrac oracleasm]# lsdisks iid

[root@stu6 oracleasm]# cd disks[root@dbrac disks]# ls -ltotal 0brw-rw—- 1 oracle oinstall 3, 19 Apr 19 21:13 VOL19brw-rw—- 1 oracle oinstall 3, 20 Apr 19 21:13 VOL20ASM磁盘的信息在系统中都得到了!

使用oracleasm删除ASM磁盘#/etc/init.d/oracleasm deletedisk VOL4

创建ASM数据库:用向导建库,存储模式选择ASMdbca在建库过程中会出现一个提示要求启动oracle集群同步服务(CSS),启动方法是在root用户运行一个脚本:#/u01/app/oracle/product/10.2.0/db_1/bin/localconfig add

ASM网络配置listener.ora########################SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = siemens) (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1) (SID_NAME = siemens) ) (SID_DESC = (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1) (SID_NAME = +ASM) ) )

LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521)) )

#######################tnsnames.ora#######################SIEMENS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = siemens) ) )

ASM = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = +ASM) ) )########################

启动时先起ASM,停库时先停数据库

启动ASM实例问题:create and start ASM instance:ORA-01034:ORACLE not available 重新启动后问题解决!

查看磁盘组信息:col name for a10SELECT group_number,name,type,state,total_mb,free_mb,offline_disks FROM V$ASM_diskgroup;

GROUP_NUMBER NAME TYPE STATE TOTAL_MB FREE_MB OFFLINE_DISKS———— —– —— ———– ———- ———- ————- 1 DGA NORMAL CONNECTED 4000 1420 0

查看ASM磁盘的信息:col group# for 99col disk# for 99col name for a5col path for a11col LABEL for a7col FAILGROUP for a10select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

GROUP# DISK# LABEL REDUNDA STATE FAILGROUP NAME PATH TOTAL_MB FREE_MB—— —– ——- ——- ——– ———- —– ———– ———- ———- 1 1 VOL19 UNKNOWN NORMAL FG1 DGA1 ORCL:VOL19 2000 710 1 0 VOL20 UNKNOWN NORMAL FG2 DGA2 ORCL:VOL20 2000 710

在ASM实例下为磁盘组dga增加磁盘(大小写敏感):alter diskgroup dgb add failgroup fg3 disk ‘ORCL:VOL5’ name vol5;

alter diskgroup dgb add failgroup fg3 disk ‘/dev/raw/raw6’ name vol6;

从组中删除磁盘:ALTER DISKGROUP dga DROP DISK vol21;

ALTER DISKGROUP dgA ADD DISK ‘/dev/rdsk/c0t4d0s2’ NAME A5, ‘/dev/rdsk/c0t5d0s2’ NAME A6, ‘/dev/rdsk/c0t6d0s2’ NAME A7, ‘/dev/rdsk/c0t7d0s2’ NAME A8;

ALTER DISKGROUP dgroupA ADD DISK ‘/devices/A*’;

在ASM实例下删除磁盘组中的磁盘同时添加新磁盘:ALTER DISKGROUP dgA DROP DISK vol21 ADD FAILGROUP fg3 DISK ‘ORCL:VOL01’ NAME VOL21;

在ASM实例下手工创建ASM磁盘组(external normal high):用 oracleasm createdisk 创建CREATE DISKGROUP dgb external REDUNDANCY DISK ‘ORCL:vol22’ name dgb1 SIZE 1000M;

CREATE DISKGROUP dga NORMAL REDUNDANCY FAILGROUP fg1 DISK ‘ORCL:VOL01’ name VOL01 FAILGROUP fg2 DISK ‘ORCL:VOL02’ name VOL02;

Vi $ORACLE_HOME/dbs/initorac.ora #control_filesDb_create_file_dest=’+DGA’

使用<裸设备> oracle 代替ASM磁盘CREATE DISKGROUP dgd NORMAL REDUNDANCY FAILGROUP controller1 DISK ‘/dev/raw/raw1’ NAME diskA1 SIZE 120G FORCE, ‘/dev/raw/raw2’, ‘/dev/raw/raw3’FAILGROUP controller2 DISK ‘/dev/raw/raw4’, ‘/dev/raw/raw5’, ‘/dev/raw/raw6’;

卸载磁盘组:ALTER DISKGROUP dgA DISMOUNT;

检测磁盘组或磁盘:ALTER DISKGROUP dga CHECK ALL;alter diskgroup dga check disk vol19;

在模板中加入新项,默认是双镜像粗条带化模式(MIRROR 双镜像;HIGH 三镜像;UNPROTECTED 无镜像)双镜像粗条带化(COARSE :1M)ALTER DISKGROUP dgc ADD TEMPLATE my_template ATTRIBUTES (COARSE);ALTER DISKGROUP dgc ADD TEMPLATE reliable ATTRIBUTES (MIRROR COARSE);无镜像粗条带化ALTER DISKGROUP dgc ADD TEMPLATE userdata ATTRIBUTES (UNPROTECTED);双镜像细条带化(FINE :128K)ALTER DISKGROUP dgc ADD TEMPLATE reliable ATTRIBUTES (MIRROR FINE);修改模板项属性alter diskgroup dgc alter template my_template attributes (fine);

使用自定义模板ALTER SYSTEM SET DB_CREATE_FILE_DEST = ‘+dgc(my_template)’;CREATE TABLESPACE test;

删除模板中的项(模板默认选项不能删除):ALTER DISKGROUP dgb DROP TEMPLATE reliable;

删除数据文件:1.数据库实例create tablespace test;alter tablespace test offline;2.ASM实例:ALTER DISKGROUP dgA DROP FILE ‘+DGA/siemens/datafile/test.271.716979429’;

在ASM实例下创建磁盘组中的目录:ALTER DISKGROUP dgB ADD DIRECTORY ‘+dgB/mydir’;为OMF文件命名别名:ALTER DISKGROUP dgroupA ADD ALIAS ‘+dgroupA/mydir/datafile.dbf’ FOR ‘+dgroupA.274.38745’;ALTER DISKGROUP dgroupA DROP ALIAS ‘+dgroupA/mydir/datafile.dbf’;

怎样查看磁盘组中的路径:(amscmd)

磁盘组dismountalter diskgroup group2 dismount;show parameter asm_diskgroups

磁盘组mountalter diskgroup group2 mount;

控制均衡容错组数据的速度:ALTER DISKGROUP dgb REBALANCE POWER 11;平衡速度控制参数:asm_power_limit = 1~11

增加容错组同时将数据从其它两组向该组平衡:ALTER DISKGROUP group1 ADD FAILGROUP fail3 DISK ‘ORCL:DISK10’ REBALANCE POWER 11;

检查数据库平衡速度:SELECT group_number, operation, state, est_work, sofar, est_rate, est_minutes FROM v$asm_operation;

修改磁盘组大小:ALTER DISKGROUP group1 RESIZE ALL SIZE 4G;

删除磁盘组:drop diskgroup group1 including contents;

取消删除:ALTER DISKGROUP group1 UNDROP DISKS;

向容错组添加磁盘:纪录在+ASM/bdump/alert_+ASM.log,数据从该容错组中的其它磁盘向该盘平衡

从组中删除容错组:

如果有挂起则不能添加!提示ORA-15029: disk ‘ORCL:DISK2’ is already mounted by this instance!HUNG如何处理:除非将组删除!但数据何处去?

ALTER DISKGROUP group1 ADD FAILGROUP fail1 DISK ‘ORCL:DISK6’ REBALANCE POWER 11;

恶意测试:破坏ASM磁盘数据dd if=/dev/zero f=/dev/hda19 bs=10M count=20

删除垃圾文件:1.得到卷组中的所有文件信息(在ASM实例):select file_number,name from v$asm_alias;2.找到有用文件(在数据库实例)show parameter spfileselect name from v$datafile;select name from v$controlfile;select member from v$logfile;

—oracle10g—-V$ASM_TEMPLATEV$ASM_ALIASV$ASM_FILEV$ASM_CLIENTV$ASM_DISKGROUPV$ASM_DISKGROUP_STATV$ASM_DISKV$ASM_DISK_STATV$ASM_OPERATION—oracle11g—-V$ASM_ATTRIBUTEV$ASM_DISK_IOSTAT

ASMCMD:export ORACLE_SID=+ASMasmcmd -p (-p 选项可以在提示中显示当前路径)

rm 删除文件lsdg (list diskgroup)查看 ASM 实例挂载的磁盘,分配的空间大小、可用空间大小和脱机磁盘du (disk utilization )查看目录内部已使用的空间大小du +disk/test/controlfilefind -t CONRTOLFILE +group1/oraasm/ *mkalias TEST_ASM.281.637521303 TEST_ASM01.DBF

Linux RH5平台下使用Oracle ASM创建数据库

实验环境

操作系统: linux 5.4

日期:2010-09-04

实验目标

Linux RH5平台下使用Oracle ASM创建数据库

实验步骤

一、安装配置先决条件

1.安装oracleasm支持包

创建asm数据库,首先需要ASMLib驱动程序包,可以从相关的网站下载到和操作系统对应的rpm文件,分别为oracleasm-support-2.0.3-1、oracleasm-2.6.18-8.el5-2.0.4-1.el5、oracleasmlib-2.0.3-1.el5。

# rpm -Uvh oracleasm*.rpm

# rpm -qa|grep oracleasmoracleasm-support-2.0.3-1oracleasm-2.6.18-8.el5-2.0.4-1.el5oracleasmlib-2.0.3-1.el5

2.添加磁盘

关闭VMware,添加一块磁盘并格式化。

# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent won’t be recoverable.

The number of cylinders for this disk is set to 1044.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-1044, default 1): Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): Using default value 1044

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

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

[root@server oracleasmlib]# fdisk -l

Disk /dev/sda: 17.1 GB, 17179869184 bytes255 heads, 63 sectors/track, 2088 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 2088 16667437+ 8e Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System/dev/sdb1 1 1044 8385898+ 83 Linux

3.启动rawdevices

# start_udevStarting udev: [ OK ]

4.配置oracleasm

以root用户登陆,执行# /etc/init.d/oracleasm configureConfiguring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM librarydriver. The following questions will determine whether the driver isloaded on boot and what permissions it will have. The current valueswill be shown in brackets (‘[]’). Hitting without typing ananswer 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) [y]: Fix permissions of Oracle ASM disks on boot (y/n) [y]: Writing Oracle ASM library driver configuration: [ OK ]Loading module “oracleasm”: [ OK ]Mounting ASMlib driver filesystem: [ OK ]Scanning system for ASM disks: [ OK ]

# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1Marking disk “/dev/sdb1” as an ASM disk: [ OK ]# [root@server oracleasmlib]# /etc/init.d/oracleasm listdisksVOL1[root@server oracleasmlib]# /etc/init.d/oracleasm scandisksScanning system for ASM disks: [ OK ]

二、创建ASM实例

1.创建初始化文件

$ su – oracle$ cd $ORACLE_HOME/dbs$ vi init+ASM.ora

*.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’

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 sysdbaSQL> startupASM instance started

Total System Global Area 100663296 bytesFixed Size 777616 bytesVariable Size 99885680 bytesDatabase Buffers 0 bytesRedo Buffers 0 bytesORA-15110: no diskgroups mounted

因为我们是首次启动asm实例,还没有创建diskgroup,所以显示15110错误是正常的。

如果启动实例的时候碰到如下报错:ORA-29701: unable to connect to Cluster Manager那么请检查/etc/inittab 文件,看看是否有下面这行h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 如果没有请添加,如果被注释了请取消注释。

5.用dbca 创建实例数据 选择asm安装

途中需要执行这两个脚本

使用root用户来执行该脚本,分别执行/opt/app/oracle/oraInventory/orainstRoot.sh和/opt/app/oracle/product/10.2.0/db_1/root.sh

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

主题测试文章,只做测试使用。发布者:布吉卡,转转请注明出处:http://www.cxybcw.com/196072.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code