当前位置:   article > 正文

asm命令及安装

amscmd ls

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

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

2、配置ASMLib
#/etc/init.d/oracleasm configure
Default user to own the driver interface [oracle]: oracle
Default group to own the driver interface [oinstall]: oinstall
Start Oracle ASM library driver on boot (y/n) [y]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing 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.d
ls -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/hda19
Marking disk "/dev/hda19" as an ASM disk:                  [  OK  ]
[root@dbrac bin]# service oracleasm createdisk vol20 /dev/hda20
Marking disk "/dev/hda20" as an ASM disk:                  [  OK  ]

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

如何查看ASM磁盘VOL19中有哪些设备:
[root@dbrac bin]# service oracleasm querydisk VOL19
Disk "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 listdisks
VOL19
VOL20
${ORACLE_ASMMANAGER} = /dev/oracleasm #打印出来了吧!原来ASM信息写在这!

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

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

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

创建ASM数据库:用向导建库,存储模式选择ASM
dbca在建库过程中会出现一个提示要求启动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 a10
SELECT 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 99
col disk# for 99
col name for a5
col path for a11
col LABEL for a7
col FAILGROUP for a10
select 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_files
Db_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)

磁盘组dismount
alter diskgroup group2 dismount;
show parameter asm_diskgroups

磁盘组mount
alter 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 spfile
select name from v$datafile;
select name from v$controlfile;
select member from v$logfile;

---oracle10g----
V$ASM_TEMPLATE
V$ASM_ALIAS
V$ASM_FILE
V$ASM_CLIENT
V$ASM_DISKGROUP
V$ASM_DISKGROUP_STAT
V$ASM_DISK
V$ASM_DISK_STAT
V$ASM_OPERATION
---oracle11g----
V$ASM_ATTRIBUTE
V$ASM_DISK_IOSTAT


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

rm 删除文件
lsdg  (list diskgroup)查看 ASM 实例挂载的磁盘,分配的空间大小、可用空间大小和脱机磁盘
du    (disk utilization )查看目录内部已使用的空间大小
du +disk/test/controlfile
find -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 oracleasm
oracleasm-support-2.0.3-1
oracleasm-2.6.18-8.el5-2.0.4-1.el5
oracleasmlib-2.0.3-1.el5

2.添加磁盘

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

# 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.

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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044

Command (m for help): w
The 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 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = 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 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

3.启动rawdevices

# start_udev
Starting udev: [  OK  ]

4.配置oracleasm

以root用户登陆,执行
# /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) [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/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [  OK  ]
#
[root@server oracleasmlib]# /etc/init.d/oracleasm listdisks
VOL1
[root@server oracleasmlib]# /etc/init.d/oracleasm scandisks
Scanning 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 sysdba
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错误是正常的。

如果启动实例的时候碰到如下报错:
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://blog.itpub.net/27042095/viewspace-742332/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/347111
推荐阅读
相关标签
  

闽ICP备14008679号