• 安装ASM


    配置ASMLIB 
    (1)划分磁盘分区
    [root@localhost ~]# fdisk /dev/sdb
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-522, default 1): 
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): 
    Using default value 522
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    同上
    fdisk /dev/sdc   /dev/sdd
    
    不需要分区
    
    
    (2)
    /etc/init.d/oracleasm  用法
    {start|stop|restart|enable|disable|configure|
    createdisk|deletedisk|querydisk|listdisks|scandisks|status}
    
    [root@localhost ~]# /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 <ENTER> 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
    Scan for Oracle ASM disks on boot (y/n) [y]: y
    Writing Oracle ASM library driver configuration: done
    Initializing the Oracle ASMLib driver:                     [  OK  ]
    Scanning the system for Oracle ASMLib disks:               [  OK  ]
    
    (3)系统添加磁盘(注意是root用户)
    [root@localhost dbs]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
    Marking disk "VOL1" as an ASM disk:                        [  OK  ]
    [root@localhost dbs]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
    Marking disk "VOL2" as an ASM disk:                        [  OK  ]
    [root@localhost dbs]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
    Marking disk "VOL3" as an ASM disk:                        [  OK  ]
    
    
    (4)创建ASM初始化文件init+ASM.ora,在$ORACLE_HOME/dbs目录下
    (可以理解为是ASM实例的pfile文件):(注意是oracle用户)
    [oracle@localhost ~]$ cd  $ORACLE_HOME
    [oracle@localhost db_1]$vim init+ASM.ora
    *.asm_diskstring='ORCL:VOL*'
    *.background_dump_dest='/db/oracle/admin/+ASM/bdump'
    *.core_dump_dest='/db/oracle/admin/+ASM/cdump'
    *.instance_type='asm'
    *.large_pool_size=24M
    *.remote_login_passwordfile='SHARED'
    *.user_dump_dest='/db/oracle/admin/+ASM/udump'
    
    (5)创建结构目录 (注意是oracle用户)
    [oracle@localhost dbs]$ mkdir -p /db/oracle/admin/+ASM/udump
    
    [oracle@localhost dbs]$ mkdir -p /db/oracle/admin/+ASM/bdump
    
    [oracle@localhost dbs]$ mkdir -p /db/oracle/admin/+ASM/cdump
    
    
    (6)创建asm实例的密码文件:
    
    [oracle@localhost dbs]$ orapwd file=orapw+ASM password=dba
    
    (7)添加css
     用root登陆
    用法/db/oracle/product/10.2.0/db_1/bin/localconfig add/delet/reset
    [root@localhost dbs]# /db/oracle/product/10.2.0/db_1/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
    。。。。。。。
    Oracle CSS service is installed and running under init(1M)
    
    
    
    
    14.启动ASM实例
    
    export ORACLE_SID=+ASM
    [oracle@localhost dbs]sqlplus /nolog
    SQL>conn / as sysdba
    Connected to an idle instance.
    初始化参数
    SQL> create pfile from spfile;
    SQL> show parameter asm;
    SQL> startup
    ASM instance started
    
    Total System Global Area  142606336 bytes
    Fixed Size		    2019128 bytes
    Variable Size		  115421384 bytes
    ASM Cache		   25165824 bytes
    ORA-15110: no diskgroups mounted
    
    
    
    15.创建磁盘组
    SQL> create diskgroup 	dgroup1 normal redundancy 
      2  failgroup  fgroup1 disk 'ORCL:VOL1','ORCL:VOL2'
      3  failgroup  fgroup2 disk'ORCL:VOL3','ORCL:VOL4';
      查看:
    
    SQL> select name,state from v$asm_diskgroup;
    
    如果没有mount上,只能手工挂载diskgroup
    SQL>alter DISKGROUP  dgroup1 mount;
    此时坚持asm_diskgroups参数值已经自动设置为DGPOUP1
    这表明在下次启动asm实例的时候,这个diskgroup会自动挂载。
    SQL>col name for a10
    SQL>col type for a10
    SQL>col value for a20
    SQL> show parameter asm_diskgroups;
    
    如果要卸载diskgroup,使用下面命令
    SQL>alter diskgroup all dismount;
    
    16.创建数据库实例
    
      第六步:选择asm
    
     第七步:如果磁盘组不是mount状态,则点击下面按钮,使之处于mount状态
    
     
    17.启动ASM数据库
    
    [oracle@localhost dbs]$ export ORACLE_SID=+ASM
    [oracle@localhost dbs]sqllplus /nolog
    SQL>conn / as sysdba
    SQL> startup
    
    
    18.关闭ASM数据库
    
    先关闭实例,再关闭ASM实例
    
    SQL>shutdown immediate
    
    
    
    
    登陆ORCL实例
    
    [oracle@server3 ~]$ export ORACLE_SID=ycj
    
    [oracle@server3 ~]$ sqlplus
      
      Enter user-name: sys as sysdba
    Enter password: 
    
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    
    SQL> select instance_name from v$instance;
    
    INSTANCE_NAME
    ----------------
    ycj
    
    SQL> select FILE_NAME ,TABLESPACE_NAME from dba_data_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    TABLESPACE_NAME
    ------------------------------
    +DATA1/ycj/datafile/users.259.780498043
    USERS
    
    +DATA1/ycj/datafile/sysaux.257.780498043
    SYSAUX
    
    +DATA1/ycj/datafile/undotbs1.258.780498043
    UNDOTBS1
    
    
    FILE_NAME
    --------------------------------------------------------------------------------
    TABLESPACE_NAME
    ------------------------------
    +DATA1/ycj/datafile/system.256.780498041
    SYSTEM
    
    +DATA1/ycj/datafile/example.269.780498169
    EXAMPLE
    
    
    数据库的简单测试,测试ASM数据库的 automatic rebalance功能
    添加两个虚拟硬盘,分别是sdf 和sdg,大小500M 
    启动系统,启动ASM 实例,启动数据库实例 
    创建ASM 磁盘 
    #/etc/init.d/oracleasm createdisk VOL5 /dev/sdf 
    #/etc/init.d/oracleasm createdisk VOL6 /dev/sdg 
    登入ASM 实例检查v$asm_disk 视图,发现这两个新加的硬盘已经找到了 
    将硬盘添加到磁盘组中 
    SQL> ALTER DISKGROUP DGROUP1 ADD FAILGROUP FGROUP1 DISK 
    'ORCL:VOL5' FAILGROUP FGROUP2 DISK 'ORCL:VOL6'; 
    Diskgroup altered. 
    检查数据库的auto rebalance 工作进度,数据库正在将原来分布在两个磁盘上的数据平均 
    分配到三个磁盘上 
    SQL> select  group_name,operation,state,est_work,sofar,
          2  est_rate,est_minutes from v$asm_operation; 
    GROUP_NUMBER OPERATION STATE EST_WORK SOFAR 
    EST_RATE EST_MINUTES 
    ------------ ---------- -------- ---------- ---------- ---------- ----------- 
    1 REBAL RUN 416 0 0 
    0 
    SQL> / 
    GROUP_NUMBER OPERATION STATE EST_WORK SOFAR 
    EST_RATE EST_MINUTES 
    ------------ ---------- -------- ---------- ---------- ---------- ----------- 
    1 REBAL RUN 275 39 148 
    1 
    SQL> / 
    以上表示数据重新分配的工作已经成功完成 
    SQL> select name,allocation_unit_size,total_mb from v$asm_diskgroup; 
    NAME ALLOCATION_UNIT_SIZE TOTAL_MB 
    ------------------------------ -------------------- ---------- 
    DGROUP1 1048576 5120 
    现在磁盘组空间总共是5120M 
    
    
    
    登入数据库实例 
    创建一个自己的表空间,创建一个用户,创建一个表 
    SQL> create tablespace ts_test datafile '+DGROUP1' size 200M; 
    Tablespace created. 
    SQL> create user kamus identified by pass default tablespace ts_test; 
    User created. 
    SQL> grant dba to kamus; 
    Grant succeeded. 
    SQL> conn kamus/pass 
    Connected. 
    SQL> create table t_test as select * from dba_objects; 
    Table created. 
    SQL> select count(*) from t_test; 
    COUNT(*) 
    ---------- 
    10319 
    登入ASM 实例,将磁盘从磁盘组中删除 
    SQL> alter diskgroup dgroup1 drop disk VOL4; 
    Diskgroup altered. 
    SQL> SELECT group_number, operation, state, est_work, sofar, est_rate, 
    est_minutes FROM v$asm_operation; 
    GROUP_NUMBER OPERATION STATE EST_WORK SOFAR 
    EST_RATE EST_MINUTES 
    ------------ ---------- -------- ---------- ---------- ---------- ----------- 1 REBAL RUN 566 46 151 
    3 
    SQL> select name,allocation_unit_size,total_mb from v$asm_diskgroup; 
    NAME ALLOCATION_UNIT_SIZE TOTAL_MB 
    ------------------------------ -------------------- ---------- 
    DGROUP1 1048576 4096 
    Executed in 0.13 seconds 
    SQL> select label,failgroup from v$asm_disk; 
    LABEL FAILGROUP 
    --------------------×××××----------- ------------------------------ 
    VOL1 FGROUP1 
    VOL2 FGROUP1 
    VOL3 FGROUP2 
    VOL5 FGROUP1 
    VOL6 FGROUP2 
    可以看到磁盘组的总容量已经减少了,磁盘数目也减少了 
    有些文档上说删除了磁盘之后要执行:ALTER DISKGROUP REBALANCE 
    但是发现不需要手动执行,整个REBALANCE 的工作确实是自动的,当删除磁盘以后,数 
    据库自动开始作REBALANCE 了 
    为了两个FAILGROUP 的大小相同,再删除一个磁盘 
    SQL> alter diskgroup dgroup1 drop disk VOL2; 
    Diskgroup altered. 
    我们可以从下面的SQL 知道在ASM 实例中可以查询到所有可以用的磁盘,而在数据库实 
    例中只可以查询到让自己使用的磁盘 
    ASM 实例: 
    SQL> SELECT disk_number, label FROM V$asm_disk; 
    DISK_NUMBER LABEL 
    ----------- -------------------------------------------------------------- 
    0 VOL4 
    1 VOL2 
    0 VOL1 
    2 VOL3 
    4 VOL5 
    5 VOL6 
    数据库实例: 
    SQL> SELECT disk_number, label FROM V$asm_disk; 
    DISK_NUMBER LABEL 
    

      

  • 相关阅读:
    JavaScript学习
    jenkins 的 ProcessTreeKiller----无法启动子进程的解决办法
    Zend studio 10.6 配置XDEBUG
    建立php开发环境(XAMPP + Xdebug+Zend Studio)
    [转]linux(centos)搭建SVN服务器
    【转】单身是最好的增值时期
    Hadoop核心组件
    数据节点中数据库的存储
    HDFS
    CSS:IE,Chrome,Firefox兼容性和CSS Hack(转载)
  • 原文地址:https://www.cnblogs.com/yuchunju/p/2530960.html
Copyright © 2020-2023  润新知