Monday, September 16, 2013

Stop and Start HAS

[oracle@rac1 bin]$ crs_stat -t
Name           Type           Target    State     Host      
------------------------------------------------------------
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1      
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac1      
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1      
ora.cssd       ora.cssd.type  ONLINE    ONLINE    rac1      
ora.diskmon    ora....on.type ONLINE    ONLINE    rac1      
[oracle@rac1 bin]$ crsctl check crs
Parse error:
  'crs' is an invalid argument

Brief usage:
  crsctl check has
     Check status of OHAS

  crsctl check resource {<resName> [...]|-w <filter>} [-n <server>] [-k <cid>] [-d <did>]
     Check status of resource(s)

  crsctl check css
     Check status of Cluster Synchronization Services

For complete usage, use:
    crsctl [-h | --help]
For detailed help on each command and object and its options use:
    crsctl <command> <object> -h  For example, crsctl relocate resource -h
[oracle@rac1 bin]$ crs_stat -l
NAME=ora.LISTENER.lsnr
TYPE=ora.listener.type
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.OCR.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.asm
TYPE=ora.asm.type
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.diskmon
TYPE=ora.diskmon.type
TARGET=ONLINE
STATE=ONLINE on rac1

[oracle@rac1 bin]$


[oracle@rac1 bin]$ ps -ef |grep -i asm
oracle   23945     1  0 19:53 ?        00:00:00 asm_pmon_+ASM
oracle   23947     1  0 19:53 ?        00:00:00 asm_vktm_+ASM
oracle   23951     1  0 19:53 ?        00:00:00 asm_gen0_+ASM
oracle   23953     1  0 19:53 ?        00:00:00 asm_diag_+ASM
oracle   23955     1  0 19:53 ?        00:00:00 asm_psp0_+ASM
oracle   23957     1  0 19:53 ?        00:00:00 asm_dia0_+ASM
oracle   23959     1  0 19:53 ?        00:00:00 asm_mman_+ASM
oracle   23961     1  0 19:53 ?        00:00:00 asm_dbw0_+ASM
oracle   23963     1  0 19:53 ?        00:00:00 asm_lgwr_+ASM
oracle   23965     1  0 19:53 ?        00:00:00 asm_ckpt_+ASM
oracle   23967     1  0 19:53 ?        00:00:00 asm_smon_+ASM
oracle   23969     1  0 19:53 ?        00:00:00 asm_rbal_+ASM
oracle   23971     1  0 19:53 ?        00:00:00 asm_gmon_+ASM
oracle   23973     1  0 19:53 ?        00:00:00 asm_mmon_+ASM
oracle   23975     1  0 19:53 ?        00:00:00 asm_mmnl_+ASM
oracle   25112  5702  0 20:24 pts/1    00:00:00 grep -i asm

[oracle@rac1 bin]$ oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
DISK5
[oracle@rac1 bin]$
[oracle@rac1 bin]$ ls /dev/oracleasm/disks/
DISK1  DISK2  DISK3  DISK4  DISK5
[oracle@rac1 bin]$

[oracle@rac1 bin]$ oracleasm status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes
[oracle@rac1 bin]$

[oracle@rac1 admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0/Grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.localdomain)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
[oracle@rac1 admin]$

[oracle@rac1 admin]$ sqlplus "/ as sysasm"

SQL*Plus: Release 11.2.0.1.0 Production on Sat Mar 23 20:26:50 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Automatic Storage Management option

SQL> shutdown immediate
ASM diskgroups volume disabled
ASM diskgroups dismounted
ASM instance shutdown
SQL>

[oracle@rac1 bin]$ crsctl enable has
CRS-4622: Oracle High Availability Services autostart is enabled.
[oracle@rac1 bin]$ crsctl start has
CRS-4640: Oracle High Availability Services is already active
CRS-4000: Command Start failed, or completed with errors.

HAS- High Availability sevice is for all cluster demon...exemple
[oracle@rac1 dbs]$  crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rac1'
CRS-2673: Attempting to stop 'ora.LISTENERASM.lsnr' on 'rac1'
CRS-2673: Attempting to stop 'ora.OCR.dg' on 'rac1'
CRS-2677: Stop of 'ora.OCR.dg' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.LISTENERASM.lsnr' on 'rac1' succeeded
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'rac1'
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded CRS-2673: Attempting to stop 'ora.diskmon' on 'rac1'
CRS-2677: Stop of 'ora.diskmon' on 'rac1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'rac1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[oracle@rac1 dbs]$ crsctl status resource -l
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Status failed, or completed with errors.
[oracle@rac1 dbs]$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.

[oracle@rac1 dbs]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.


[oracle@rac1 bin]$ srvctl remove listener -l LISTENER

[oracle@rac1 admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0/Grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENERASM =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.localdomain)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
[oracle@rac1 admin]$ srvctl add listener -l LISTENERASM -p "TCP:1522" -o $ORACLE_HOME
[oracle@rac1 admin]$
[oracle@rac1 admin]$ srvctl add listener -l LISTENERASM -p "TCP:15" -o $ORACLE_HOME
[oracle@rac1 admin]$ vi listener.ora
[oracle@rac1 admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0/Grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENERASM =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.localdomain)(PORT = 1522))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
[oracle@rac1 admin]$ srvctl config asm
ASM home: /u01/app/11.2.0/Grid
ASM listener was not found
PRCA-1032 : ASM listener LISTENER does not exist
Spfile: +OCR/asm/asmparameterfile/registry.253.810849181
ASM diskgroup discovery string:
[oracle@rac1 admin]$ srvctl remove asm
[oracle@rac1 admin]$ srvctl add asm -l LISTENERASM -p +data/spfile.ora
[oracle@rac1 admin]$
[oracle@rac1 admin]$ srvctl config asm
ASM home: /u01/app/11.2.0/Grid
ASM listener: LISTENERASM
Spfile: +data/spfile.ora
ASM diskgroup discovery string:
[oracle@rac1 admin]$
[oracle@rac1 admin]$
[oracle@rac1 admin]$
[oracle@rac1 admin]$ srvctl start asm
[oracle@rac1 admin]$
[oracle@rac1 admin]$ ps -ef |grep -i asm
oracle    7113     1  0 22:38 ?        00:00:00 /u01/app/11.2.0/Grid/bin/tnslsnr LISTENERASM -inherit
oracle    7280     1  0 22:40 ?        00:00:00 asm_pmon_+ASM
oracle    7282     1  0 22:40 ?        00:00:00 asm_vktm_+ASM
oracle    7286     1  0 22:40 ?        00:00:00 asm_gen0_+ASM
oracle    7288     1  0 22:40 ?        00:00:00 asm_diag_+ASM
oracle    7290     1  0 22:40 ?        00:00:00 asm_psp0_+ASM
oracle    7292     1  0 22:40 ?        00:00:00 asm_dia0_+ASM
oracle    7294     1  0 22:40 ?        00:00:00 asm_mman_+ASM
oracle    7296     1  0 22:40 ?        00:00:00 asm_dbw0_+ASM
oracle    7298     1  0 22:40 ?        00:00:00 asm_lgwr_+ASM
oracle    7300     1  0 22:40 ?        00:00:00 asm_ckpt_+ASM
oracle    7302     1  0 22:40 ?        00:00:00 asm_smon_+ASM
oracle    7304     1  0 22:40 ?        00:00:00 asm_rbal_+ASM
oracle    7306     1  0 22:40 ?        00:00:00 asm_gmon_+ASM
oracle    7308     1  0 22:40 ?        00:00:00 asm_mmon_+ASM
oracle    7310     1  0 22:40 ?        00:00:00 asm_mmnl_+ASM
oracle    7336  5775  0 22:40 pts/1    00:00:00 grep -i asm
[oracle@rac1 admin]$

 CREATE DISKGROUP OCR EXTERNAL REDUNDANCY  DISK 'ORCL:DISK1',
'ORCL:DISK2' ATTRIBUTE 'compatible.asm'='11.2.0.0.0' /* ASMCA */


 large_pool_size          = 12M
  instance_type            = "asm"
  remote_login_passwordfile= "EXCLUSIVE"
  asm_power_limit          = 1
  diagnostic_dest          = "/u01/app/oracle"
   ASM_DISKGROUPs   ='OCR'


[oracle@rac1 dbs]$ crsctl status resource -l
NAME=ora.LISTENERASM.lsnr
TYPE=ora.listener.type
CARDINALITY_ID=rac1
DEGREE_ID=1
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.OCR.dg
TYPE=ora.diskgroup.type
CARDINALITY_ID=rac1
DEGREE_ID=1
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.asm
TYPE=ora.asm.type
CARDINALITY_ID=rac1
DEGREE_ID=1
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.cssd
TYPE=ora.cssd.type
CARDINALITY_ID=1
DEGREE_ID=1
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.diskmon
TYPE=ora.diskmon.type
CARDINALITY_ID=1
DEGREE_ID=1
TARGET=ONLINE
STATE=ONLINE on rac1

[oracle@rac1 dbs]$
[oracle@rac1 dbs]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :        120
         Available space (kbytes) :     262000
         ID                       :  999309595
         Device/File Name         : /u01/app/11.2.0/Grid/cdata/localhost/local.ocr
                                    Device/File integrity check succeeded

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

         Cluster registry integrity check succeeded

         Logical corruption check bypassed due to non-privileged user

[PROD]ora14:DUMMY:/u01/app/11.2.0/grid/bin$ ./crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   823eb26c96754f03bf32dd96682fb2f7 (/u02/RAC/voting1/vdsk1) []
 2. ONLINE   1dbda37c86fd4f6fbf01941a75d32a63 (/u02/RAC/voting2/vdsk2) []
 3. ONLINE   655bfee2f4284f60bfca21a001ba51bf (/u02/RAC/voting3/vdsk3) []
Located 3 voting disk(s).

[oracle@rac1 dbs]$
[oracle@rac1 dbs]$  crsctl query has releaseversion
Oracle High Availability Services release version on the local node is [11.2.0.1.0]
[oracle@rac1 dbs]$

ASM log file/var/log/oracleasm

Senerio 1) Create new diskgroup and assing to DB
 SQL> alter tablespace users add datafile '+OCR' size 100m;


 CREATE DISKGROUP Vote EXTERNAL REDUNDANCY  DISK 'ORCL:DISK3' ATTRIBUTE 'compatible.asm'='11.2.0.0.0' /* ASMCA */


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ASM Operations

Instance name select instance_name from v$instance;
Create disk group
create diskgroup diskgrpA high redundancy
  failgroup failgrpA disk ’\\.\f:’ name disk1
  failgroup failgrpB disk ’\\.\g:’ name disk2 force
  failgroup failgrpC disk ’\\.\h:’ name disk3;

create diskgroup diskgrpA external redundancy

Note: force is used if disk has been in a previous diskgroup, external redundancy uses third party mirroring i.e SAN

Add disks to a group alter diskgroup diskgrpA add disk
  '\\.\i:' name disk4;
  '\\.\j:' name disk5;
Remove disks from a group alter diskgroup diskgrpA drop disk disk6;
Remove disk group drop diskgroup diskgrpA including contents
resizing disk group alter diskgroup diskgrpA resize disk 'disk3' size 500M;
Undo remove disk group alter database diskgrpA undrop disks;

Display diskgroup info

select name, group_number, name, type, state, total_mb, free_mb from v$asm_diskgroup;
select group_number, disk_number, name, failgroup, create_date, path, total_mb from v$asm_disk;
select group_number, operation, state, power, actual, sofar, est_work, est_rate, est_minutes from v$asm_operation;

Rebalance a diskgroup (after disk failure and disk has been replaced)
alter diskgroup diskgrpA rebalance power 8;

Note: to speed up rebalancing increase the level upto 11, remember that this will also decrease performance, you can also use the wait parameter this will hold the commandline until it is finished

Dismount or mount a diskgroup
alter diskgroup diskgrpA dismount;
alter diskgroup diskgrpA mount;

Check a diskgroups integrity
alter diskgroup diskgrpA check all;

Diskgroup Directory
alter diskgroup diskgrpA add directory '+diskgrpA/dir1'

Note: this is required if you use aliases when creating databse files i.e '+diskgrpA/dir/control_file1'

adding and drop aliases alter diskgroup diskgrpA add alias '+diskgrpA/dir/second.dbf' for '+diskgrpB/datafile/table.763.1';
alter diskgroup diskgrpA drop alias '+diskgrpA/dir/second.dbf'
Drop files from a diskgroup alter diskgroup diskgrpA drop file '+diskgrpA/payroll/payroll.dbf';
Using ASM Disks

Examples of using ASM disks

create tablespace test datafile ‘+diskgrpA’ size 100m;
alter tablespace test add datafile ‘+diskgrpA’ size 100m;
alter database add logfile group 4 ‘+dg_log1’,’+dg_log2’ size 100m;
alter system set log_archive_dest_1=’location=+dg_arch1’;
alter system set db_recovery_file_dest=’+dg_flash’;

Display performance
select path, reads, writes, read_time, write_time,
       read_time/decode(reads,0,1,reads) "AVGRDTIME",
       write_time/decode(writes,0,1,writes) "AVGWRTIME"
from v$asm_disk_stat;


CREATE DISKGROUP STANDBY EXTERNAL REDUNDANCY  DISK 'ORCL:DISK4' ATTRIBUTE 'compatible.asm'='11.2.0.0.0' /* ASMCA */

alter diskgroup STANDBY mount;
SQL>  alter diskgroup OCR drop disk DISK3;

Diskgroup altered.






Physical standby


SQL> ALTER DATABASE ADD STANDBY LOGFILE '+OCR/orcl/onlinelog/standby_log01.log' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE '+OCR/orcl/onlinelog/standby_log02.log' SIZE 52428800;

ALTER DATABASE ADD STANDBY LOGFILE '+OCR/orcl/onlinelog/standby_log03.log' SIZE 52428800;

ALTER DATABASE ADD STANDBY LOGFILE '+OCR/orcl/onlinelog/standby_log04.log' SIZE 52428800;

Database altered.

SQL>
Database altered.

SQL> SQL>

Database altered.

SQL> SQL>
Database altered.

SQL> SQL>
SQL> ALTER SYSTEM SET log_archive_config = 'dg_config=(orcl,stby)';

System altered.

SQL> ALTER SYSTEM SET log_archive_dest_2 = 'service=stby async valid_for=(online_logfile,primary_role) db_unique_name=stby';

System altered.

Set ORCL in archive log

Go to ASM terminal
[oracle@rac1 Grid]$ asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     16378    14247                0           14247              0             N  OCR/
MOUNTED  EXTERN  N         512   4096  1048576      8189     8137                0            8137              0             N  STANDBY/
ASMCMD> cd OCR
ASMCMD> ls
ASM/
ORCL/
ASMCMD> cd ORCL
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileorcl.ora
ASMCMD> mkdir arch
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
arch/
spfileorcl.ora
ASMCMD>
alter system set log_archive_dest_1='location=+OCR/ORCL/arch' SCOPE=SPFILE;
SQL>  alter system set log_archive_dest_1='location=+OCR/ORCL/arch'
  2  ;

System altered.

SQL> show parameter log_archive_dest_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      location=+OCR/ORCL/arch
log_archive_dest_10                  string
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  722366464 bytes
Fixed Size                  2216864 bytes
Variable Size             503319648 bytes
Database Buffers          209715200 bytes
Redo Buffers                7114752 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive loglist
SP2-0734: unknown command beginning "archive lo..." - rest of line ignored.
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +OCR/orcl/arch
Oldest online log sequence     13
Next log sequence to archive   15
Current log sequence           15

SQL> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      orcl.localdomain
SQL> show parameter uniq

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      orcl


SID_LIST_LISTENER =
 (SID_LIST =
 (SID_DESC =
 (GLOBAL_DBNAME = stdby.localdomain)
 (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
 (SID_NAME = stby)
 )
 (GLOBAL_DBNAME = orcl.localdomain)
 (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
 (SID_NAME = orcl)
)



No comments:

Post a Comment