轉貼:上週ORACLE RAC培訓時的安裝RAC的詳細步驟(六)

orchidllh發表於2005-03-07
  ****  ORACLE     INTERNAL   ****   ****  ORACLE     INTERNAL   ****
         Copyright (c) 2003-2004 Oracle. All rights reserved.
  
Create an ASM instance using DBCA                     Last Update: 15JUN04
Demo ASM re-balancing                       Comments:
Saar.Maoz@oracle.com
                                                      Lance.Larsh@oracle.com

We simulate 4 disks by partitioning them into 4 partitions, for simplicity.

1. Use fdisk to partition /dev/sde into 4 partitions:
   As root run:
  
      # fdisk /dev/sde
 
     i. Command: Type "n" and press ENTER. 
    ii. Command action: Type "p" and press ENTER.
   iii. Partition number: Type "1" and press ENTER.
    iv. First cylinder: Press ENTER.
     v. Last cylinder: +2000M.
    
     Repeat these steps 3 more times increasing partition# by 1 each time.
    
    vi. To write partition table and exit; Type "write"
    
     In a real RAC, all other nodes will have to re-read the partition table
     change.  Easiest way is to reboot these nodes, refer to OS/vendor to
     inquire if there's a less intrusive way.    

2. Configure raw devices (since not using ASMLib)

   i. Add entries to /etc/sysconfig/rawdevices on all nodes, for example:
/dev/raw/raw11  /dev/sde1
/dev/raw/raw12  /dev/sde2
/dev/raw/raw13  /dev/sde3
/dev/raw/raw14  /dev/sde4

  ii. As root restart the raw devices on all nodes:
 
      # /etc/init.d/rawdevices restart
     
      If CRS is already up with 2 raw devices, the "rawdevices restart" will
      give errors for those two, but that's OK.  It just means CRS already
      has those raw devices open so they can't be changed.
     
 iii. Fix permissions as root, on all nodes:
 
      # chown oracle:dba /dev/raw/raw1[1-4]
 
3. Run dbca to create the ASM instance:

   i. Select RAC, Create Database, on raclinux1, bogus DB name,
      click next until step 7 of 16.
  ii. Select Automatic Storage Management (ASM)
 iii. Let DBCA create the ASM instance
  iv. Create a new diskgroup Name: MY_DG
   v. Select devices /dev/raw/raw11 & 12 to be added
      to MY_DG with normal redundancy.
  vi. Cancel out of DBCA!

4. Notice the ASM instance has been shutdown, startup issue:

   $ srvctl start  asm -n raclinux1
   $ srvctl status asm -n raclinux1

5. (Optional) To fully simulate RAC (in a box) we can create and startup
   another ASM instance on this node.  Normally the second ASM instance
   would run on the second node along with the second instance O10G2.
   To create a second ASM instance (not supported running on 1 node) do:

   a. Edit /opt/oracle/DB10g/dbs/init+ASM1.ora and add these two lines:

+ASM2.instance_number=2
+ASM2.local_listener=LISTENER_+ASM2

   b. Create a symlink to this file for the second ASM instance:

      $ ln -s init+ASM1.ora init+ASM2.ora
 
   c. Create a password file for second ASM instance:

      $ orapwd file=init+ASM2 password=oracle

   d. Fix  /opt/oracle/DB10g/network/admin/tnsnames.ora:

      i. Include only one listener (port 1521) in LISTENER_+ASM1
     ii. Create new LISTENER_+ASM2; include the second listener (1522)

   e. Add the second ASM instance to CRS and start instance up:

     $ srvctl add   asm -n raclinux1 -i +ASM2 -o /opt/oracle/DB10g/
     $ srvctl start asm -n raclinux1 -i +ASM2  


6. Modify the existing instances to be dependent on the newly created ASM
   instances

   $ srvctl modify instance -d O10G -i O10G1 -s +ASM1
   $ srvctl modify instance -d O10G -i O10G2 -s +ASM2

   NOTE: If you only created one ASM instance, set both DB instances
         to depend on the +ASM1.

7. Make the database aware of the diskgroup(s) available on the ASM
   storage:

   $ ORACLE_SID=O10G1 sqlplus "/ as sysdba"

   SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST='+MY_DG' scope=both;

   If not using spfile just drop the scope and also add this parameter
   to your initO10G1.ora file (initO10G2.ora should symlink to it).


8. To use space inside ASM managed storage:

   You can simply issue CREATE TABLESPACE ASM_TBS datafile size 10M;
  
   OR continue with this ASM demo by:

   Using oewizard from swingbench to create a new schema using ASM
   file spec, supply +MY_DG in the filename location and
   "SOE_ASM" as user, password and tablespace.


9. The ASM re-balancing demo:

    i. Start swingbench and run 15 users on SOE_ASM schema.
       This will load/update data in MY_DG diskgroup (SOE_ASM tablespace)
       Monitor swingbench's transaction/min throughout this process.

   ii. Monitor the ASM instance and manipulate the diskgroup:

       $ ORACLE_SID=+ASM1 sqlplus "/ as sysdba"

       Initial condition:

       SQL> select state,header_status,substr(name,1,12) Name,free_mb,
                   substr(path,1,16) PATH from v$asm_disk;

STATE    HEADER_STATU NAME            FREE_MB PATH
-------- ------------ ------------ ---------- ----------------
NORMAL   CANDIDATE                          0 /dev/raw/raw14
NORMAL   CANDIDATE                          0 /dev/raw/raw13
NORMAL   MEMBER       MY_DG_0001         1812 /dev/raw/raw12
NORMAL   MEMBER       MY_DG_0000         1812 /dev/raw/raw11


       SQL> select * from v$asm_operation;   (no rows)


  iii. Add two new disks to the existing diskgroup:

       SQL> alter diskgroup MY_DG add disk '/dev/raw/raw13'
       SQL> alter diskgroup MY_DG add disk '/dev/raw/raw14'

       SQL> select state,header_status,substr(name,1,12) Name,free_mb,
                   substr(path,1,16) PATH from v$asm_disk;
 
STATE    HEADER_STATU NAME            FREE_MB PATH
-------- ------------ ------------ ---------- ----------------
NORMAL   MEMBER       MY_DG_0003         2445 /dev/raw/raw14
NORMAL   MEMBER       MY_DG_0002         1911 /dev/raw/raw13
NORMAL   MEMBER       MY_DG_0001         1812 /dev/raw/raw12
NORMAL   MEMBER       MY_DG_0000         1812 /dev/raw/raw11

       SQL> select operation,state,power,actual,sofar,est_work,
                   est_minutes from v$asm_operation;

OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK EST_MINUTES
----- ---- ---------- ---------- ---------- ---------- -----------
REBAL RUN           1          1          3         62           1

       ASM is rebuilding the diskgroup by adding the new disks.
   
    iv. Now DROP the initial disks that hold all the user data watch
        ASM transfer all the data to the new disks thus allowing you
        to remove the unwanted disks.  Drop completes right away,
        operation of transfering data is taking place in background.

        SQL> alter diskgroup MY_DG drop disk my_dg_0000;
        SQL> alter diskgroup MY_DG drop disk my_dg_0001;

        SQL> select state,header_status,substr(name,1,12) Name,free_mb,
                    substr(path,1,16) PATH from v$asm_disk;

STATE    HEADER_STATU NAME            FREE_MB PATH
-------- ------------ ------------ ---------- ----------------
NORMAL   MEMBER       MY_DG_0003         2335 /dev/raw/raw14
NORMAL   MEMBER       MY_DG_0002         1827 /dev/raw/raw13
DROPPING MEMBER       MY_DG_0001         1860 /dev/raw/raw12
DROPPING MEMBER       MY_DG_0000         1867 /dev/raw/raw11

        SQL> select operation,state,power,actual,sofar,est_work,
                    est_minutes from v$asm_operation;
OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK EST_MINUTES
----- ---- ---------- ---------- ---------- ---------- -----------
REBAL RUN           1          1          7        233           0


        When operation is complete, the disks are marked as FORMER
        members meaning they can be removed or reused for space.

        SQL> select state,header_status,substr(name,1,12) Name,free_mb,
                    substr(path,1,16) PATH from v$asm_disk;

STATE    HEADER_STATU NAME            FREE_MB PATH
-------- ------------ ------------ ---------- ----------------
NORMAL   FORMER                             0 /dev/raw/raw11
NORMAL   FORMER                             0 /dev/raw/raw12
NORMAL   MEMBER       MY_DG_0003         2303 /dev/raw/raw14
NORMAL   MEMBER       MY_DG_0002         1769 /dev/raw/raw13

        Throughout this demo performance didn't suffer at all,
        transactions per minute was constant.


10. (Optional) Inside the ASM Instance:


   a. To connect to it, use bash to set ORACLE_SID just for this shell:

      $ ORACLE_SID=+ASM1 sqlplus "/ as sysdba"

Interesting views inside ASM:

select * from v$asm_diskgroup;
select * from v$asm_client;
select * from v$asm_file;
select header_status,path,name from v$asm_disk;
select name from v$asm_alias;

   b. Puzzle: How do you view/edit a file that starts with
      a + (plus) sign??

     $ more  +asm_diag_18649.trc
usage: more [-dflpcsu] [+linenum | +/pattern] name1 name2 ...

     $ vi +asm_diag_18649.trc
Error detected while processing command line:
E492: Not an editor command: asm_diag_18649.trc
Hit ENTER or type command to continue
 
      Solution: use fully qualified name as:
 
     $ vi ./+asm_diag_18649.trc


  ****  ORACLE     INTERNAL   ****   ****  ORACLE     INTERNAL   ****
         Copyright (c) 2003-2004 Oracle. All rights reserved.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/51862/viewspace-180528/,如需轉載,請註明出處,否則將追究法律責任。

相關文章