Chinaunix首页 | 论坛 | 博客
  • 博客访问: 109742
  • 博文数量: 55
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 630
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-13 10:59
文章分类
文章存档

2011年(1)

2009年(37)

2008年(17)

我的朋友

分类: Oracle

2009-05-14 17:37:43

今天,回顾了一下ASM,把之前学的拾起来,高手就不用看了。@_@
OS: Asainux 3.0 x86
oracleasm-2.6.18-128.1.1.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.3-1.el5.i386.rpm
oracleasm-support-2.1.2-1.el5.i386.rpm
安装以上包。
/etc/init.d/oracleasm configure
dd if=/dev/zero of=/tmp/max/u1 bc=1024k count=1000
dd if=/dev/zero of=/tmp/max/u2 bc=1024k count=1000
dd if=/dev/zero of=/tmp/max/u3 bc=1024k count=1000

losetup  /dev/loop1  /tmp/max/u1
losetup  /dev/loop2  /tmp/max/u2
losetup  /dev/loop3  /tmp/max/u3
模拟几个设备
[root@max ~]# losetup -a
/dev/loop1: [0302]:522567 (/tmp/max/u1)
/dev/loop2: [0302]:522569 (/tmp/max/u2)
/dev/loop3: [0302]:522580 (/tmp/max/u3)
[root@max ~]#

/etc/init.d/oracleasm createdisk max1 /dev/loop1
/etc/init.d/oracleasm createdisk max2 /dev/loop2
/etc/init.d/oracleasm createdisk max3 /dev/loop3
看一下
[root@max ~]# oracleasm listdisks
MAX1
MAX2
MAX3
[root@max ~]#

因为 ASM 也是需要一个实例,所以就手动写一个文件
[oracle@max ~]$ cat $ORACLE_HOME/dbs/init+ASM.ora
*.asm_diskstring='ORCL:*'
*.background_dump_dest='/opt/oracle/admin/+ASM/bdump/'
*.core_dump_dest='/opt/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/opt/oracle/admin/+ASM/udump'

[oracle@max ~]$
不建议的话,再加个密码,也成
orapwd  file=/opt/oracle/product/10.2.0/db_1/dbs/orapw+ASM password=max

我们要启动ASM 这个实例,所以把SID 换一下。

export ORACLE_SID=+ASM
sqlplus "/as sysdba"
下面我们就建一个普通的 ASM

create diskgroup can normal redundancy disk 'ORCL:MAX1','ORCL:MAX2';
SQL> select group_number,redundancy,total_mb,free_mb,name,path from v$asm_disk;

GROUP_NUMBER REDUNDANCY       TOTAL_MB    FREE_MB NAME
------------ -------------- ---------- ---------- ------------------------------------------------------------
PATH
------------------------------------------------------------------------------------------------------------------------------------
           0 UNKNOWN              1000          0
ORCL:MAX3

           1 UNKNOWN              1000        949 MAX1
ORCL:MAX1

           1 UNKNOWN              1000        949 MAX2
ORCL:MAX2


SQL> select name from V$asm_diskgroup;

NAME
------------------------------------------------------------
CAN

SQL>


现在我们就可以以正常的方式 打开数据库了。
为了使以后新建表空间都在我们刚才新建 的ASM 上,我们可以设置db_create_file_dest
alter system set db_create_file_dest='+CAN';

下面做一个简单的例子。
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/orcl/system01.dbf
/opt/oracle/oradata/orcl/undotbs01.dbf
/opt/oracle/oradata/orcl/sysaux01.dbf
/opt/oracle/oradata/orcl/users01.dbf
/opt/oracle/oradata/orcl/max.dbf
/opt/oracle/oradata/orcl/mmm.dbf

6 rows selected.

SQL> create tablespace can datafile size 30m;

Tablespace created.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/orcl/system01.dbf
/opt/oracle/oradata/orcl/undotbs01.dbf
/opt/oracle/oradata/orcl/sysaux01.dbf
/opt/oracle/oradata/orcl/users01.dbf
/opt/oracle/oradata/orcl/max.dbf
/opt/oracle/oradata/orcl/mmm.dbf
+CAN/orcl/datafile/can.256.686860717

7 rows selected.

SQL>

是不是很方便 呢,当然 11G的ASM 更好用,可惜 ,我没有研究。
下面我们把第三个MAX3 也添加进来,
SQL> alter diskgroup can add disk 'ORCL:MAX3';

Diskgroup altered.

SQL> select group_number,redundancy,total_mb,free_mb,name,path from v$asm_disk;

GROUP_NUMBER REDUNDANCY       TOTAL_MB    FREE_MB NAME
------------ -------------- ---------- ---------- ------------------------------------------------------------
PATH
------------------------------------------------------------------------------------------------------------------------------------
           1 UNKNOWN              1000        916 MAX1
ORCL:MAX1

           1 UNKNOWN              1000        916 MAX2
ORCL:MAX2

           1 UNKNOWN              1000        995 MAX3
ORCL:MAX3


SQL>       


新建一个目录
alter diskgroup can add directory '+CAN/max';

[oracle@max ~]$ asmcmd
ASMCMD> ls
CAN/
ASMCMD> ls CAN
ORCL/
max/
ASMCMD> ls CAN/max/
ASMCMD> lsct
DB_Name   Status        Software_Version  Compatible_version  Instance_Name
orcl      CONNECTED           10.2.0.1.0          10.2.0.1.0  orcl
ASMCMD> lsdg
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
MOUNTED  NORMAL  N      N         512   4096  1048576      3000     2779             1000             889              0  CAN/
ASMCMD>


删除磁盘组
DROP DISKGROUP dgroup1;

与ASM 相关的视图可以通过如下方式 获取;
SQL> select name,type from v$fixed_table where name like '%ASM%';

NAME                                                         TYPE
------------------------------------------------------------ ----------
GV$ASM_TEMPLATE                                              VIEW
V$ASM_TEMPLATE                                               VIEW
GV$ASM_ALIAS                                                 VIEW
V$ASM_ALIAS                                                  VIEW
GV$ASM_FILE                                                  VIEW
V$ASM_FILE                                                   VIEW
GV$ASM_CLIENT                                                VIEW
V$ASM_CLIENT                                                 VIEW
GV$ASM_DISKGROUP                                             VIEW
V$ASM_DISKGROUP                                              VIEW
GV$ASM_DISKGROUP_STAT                                        VIEW

NAME                                                         TYPE
------------------------------------------------------------ ----------
V$ASM_DISKGROUP_STAT                                         VIEW
GV$ASM_DISK                                                  VIEW
V$ASM_DISK                                                   VIEW
GV$ASM_DISK_STAT                                             VIEW
V$ASM_DISK_STAT                                              VIEW
GV$ASM_OPERATION                                             VIEW
V$ASM_OPERATION                                              VIEW

18 rows selected.

SQL>



关于ASM 我就不多说了,我也不精通 。GOOGLE,baidu,yahoo 一下,我相信,你全都知道了。
如果 这你都不愿意,那你就



































阅读(410) | 评论(0) | 转发(0) |
0

上一篇:country name

下一篇:Asianux + GFS

给主人留下些什么吧!~~