About Me

The best place to start learning Oracle, Linux/Unix scripting, and Oracle administration skills. Currently, as Oracle DBA with 11g/10g/9i OCP certified, I want to help you with my background and knowledge. Hopefully, this info would help you as a job aid.
Showing posts with label Oracle DB Administration Job Aid. Show all posts
Showing posts with label Oracle DB Administration Job Aid. Show all posts

Friday, January 27, 2012

some RAC environment command job aid I

It's a simple note for this article to provide few command aid in the cluster environment:

here is the command and example:
cluvfy comp crs --> check CRS integrity
cluvfy comp nodecon -n all  --> check node connectivity in cluster environment
<CRS_HOME>/bin/crs_stat -t  --> check CRS stats


hostname:/opt/oracle> cluvfy comp crs

Verifying CRS integrity

Checking CRS integrity...

Checking daemon liveness...
Liveness check passed for "CRS daemon".

Checking daemon liveness...
Liveness check passed for "CSS daemon".

Checking daemon liveness...
Liveness check passed for "EVM daemon".

Checking CRS health...
CRS health check passed.

CRS integrity check passed.

Verification of CRS integrity was successful.


hostname:/opt/oracle> cluvfy comp nodecon -n all

Verifying node connectivity

Checking node connectivity...

Node connectivity check passed for subnet "10.10.10.0" with node(s) host1, host2, host3.
Node connectivity check passed for subnet "146.18.118.128" with node(s) racstress6,racstress5,racstress4.

Suitable interfaces for VIP on subnet "146.18.118.128":
host3 eth0:146.18.118.153 eth0:146.18.118.206
host2 eth0:146.18.118.154 eth0:146.18.118.205
host1 eth0:146.18.118.155 eth0:146.18.118.204

Suitable interfaces for the private interconnect on subnet "10.10.10.0":
host3 bond0:10.10.10.3
host2 bond0:10.10.10.2
host1 bond0:10.10.10.1

Node connectivity check passed.

Verification of node connectivity was successful.
hostname:/opt/oracle/product/crs/10.2.0.3/bin> ./crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....22.inst application ONLINE UNKNOWN host2
ora....23.inst application ONLINE UNKNOWN host3
ora....R21.srv application ONLINE UNKNOWN host2
ora....r21.srv application ONLINE UNKNOWN host2
ora....ss4.gsd application ONLINE ONLINE host1
ora....ss4.ons application ONLINE OFFLINE
ora....ss4.vip application ONLINE ONLINE host1
ora....ss5.gsd application ONLINE ONLINE host2
ora....ss5.ons application ONLINE OFFLINE
ora....ss5.vip application ONLINE ONLINE host2
ora....ss6.gsd application ONLINE ONLINE host3
ora....ss6.ons application ONLINE OFFLINE
ora....ss6.vip application ONLINE ONLINE host3

Thursday, December 22, 2011

srvctl command job aid - I

In this article, it records some command prompts under 'srvctl' to manipulate the instances/databases under the GRID infrastructure environment. The example provided is based on a Oracle 11g Virtual Database environment. In this machine, we install the Oracle binary of 11.2.0.3, and CRS binary of 11.2.0.3.
(Note: The Grid Infrastrcture will be discussed in more detail in the lessons of Grid Infracsture of Oracle 11g.)

In this case, we are going to use srvctl to shutdown and restart the instance. In the VDB environment we have, we have only one instance for this database. So, it's pretty similar as the normal standalone database. But we treat it as the cluster database environment, so we utilize the srvctl to conduct the task instead of sqlplus.

Ex: Shutdown the database instance and reopen it to the archivelog mode.
1. Check the dbconsole is up or not. if it's up, then shutdown the dbconsole first.

> emctl status dbconsoleOracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
Copyright (c) 1996, 2011 Oracle Corporation.  All rights reserved.
https://Hostname:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running.
------------------------------------------------------------------
Logs are generated in directory /opt/oracle/product/11.2.0.3/hostname_dbname/sysman/log
> emctl stop dbconsoleOracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
Copyright (c) 1996, 2011 Oracle Corporation.  All rights reserved.
https://hostname:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
 ...  Stopped.

 2. Now you can either shutdown the listener before shutdown the database or you can simply issue the shutdown database via srvctl. srvctl will shutdown the listener if it's up before shutting the database. In this exmaple, we choose to shutdown the listener separately.

 > srvctl status listener   --> Check the listener status
Listener LISTENER_NAME is enabled
Listener LISTENER_NAME is running on node(s): nodename
> srvctl stop listner   --> shutdown the listener
> srvctl status listener
Listener LISTENER_NAME is enabled
Listener LISTENER_NAME is not running
>

3. Nowwe stop the instance/database
> srvctl stop database -d database_name  
--> we need to specify the option -d with the database name to shutdown
> srvctl status database -d database_nameDatabase is not running.
So, we are sure the database has been shutdown successfully now.

4. Bring back up the instance/database in archivelog mode.
    (note: in our example the database was in 'noarchivelog' mode before we shut it down)
> srvctl start database -d database_name -o mount 
--> we startup the database in 'mout' mode. Notice that the option of '-o' is where you can specify what mode your want to bring your instance to.
5. Open another session and login to the instance through sqlplus. And issue the 'alter database archivelog' command to turn the archivelog mode on.
> sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 22 21:26:25 2011
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning and Automatic Storage Management options
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> exit

(5b. Turn on the database through srvctl, if no need to alter database archivelog)
> srvctl start database -d database_name -o open
--> the '-s' option is to specify the start option. In this case, we want to turn the database to be open, and which is the default, other options includes 'mount', 'nomoun'.
One thing to notice is that, once you use srvctl to start the database in 'nomount', 'mount' mode, you cannnot alter that database through srvctl directly to the 'open' mode. You need to shutdown the database first and then use 'srvctl start database -d database_name -o open' to bring it back on.

6. Check the database status and make sure listner is running.
> srvctl status database -d database_name
Database is running.
> srvctl status listener
Listener LISTENER_NAME is enabled
Listener LISTENER_NAME is running on node(s): node_name
8. Turn on the dbconsole
> emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.3.0
Copyright (c) 1996, 2011 Oracle Corporation.  All rights reserved.
https://hostname:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control .... started.
------------------------------------------------------------------
Logs are generated in directory /opt/oracle/product/11.2.0.3/hostname_dbname/sysman/log
The srvctl also has the -h option to help you find out the option available to use, which is a pretty handy tool to help you utilizing the srvctl.

ex:
> srvctl status listener -h
Displays the current state of the listener.
Usage: srvctl status listener [-l <lsnr_name>] [-v]
    -l <lsnr_name>           Listener name
    -v                       Verbose output
    -h                       Print usage

Saturday, November 5, 2011

Setup services under RAC environment on Oracle 11g/10g

Since Oracle 10g, Oracle begins with Grid infrastructure and introducing RAC environment; while RAC stands for Real Application Clusters.

In this post, it focus on the simple notes of how to setup the service on the RAC environment.
If you are interested with the RAC infrastructure concept, please refer to the Oracle Grid Infrastructure.
(Still under construction)

Basic service setup procedure on a RAC environment is like below:

1. Add database, usually only one database to be added.
2. Add instances, usually the number of instances as same number of nodes.
    ex: three instances and three nodes. 
3. Add services. 

command prompt demo:
Login to one of the node in the cluster, and use srvctl to accomplish this: 
1. add database:
$ srvctl add database -d $DBNAME -o $ORACLE_HOME
-- adding the database, -d following the DBNAME, -o following the ORACLE_HOME
-- the environment parameter can be replaced with hard-coded name. 

2. add instances:
$ srvctl add instance -d $DBNAME -i instance_name -n node_name (without domain name)
-- adding the instances, -d following the DBNAME, -n following the hostname, usually without
-- the domain name. This is repeated for each node in the cluster.

3. add services:
$ srvctl add service -d $DBNAME -s service_name -r primary_instance -a secondary_instance, secondary_instance
-- adding the services, -s following the service_name you want to specify, -r following the list of
-- primary nodes the service wants to direct the connection request to, and -a following the list of
-- secondary node when primary nodes are all not available.
-- This step may be repeated for each service you want to setup for the cluster.
-- A cluster may have multiple services.

4. Start the service:
$ srvctl start service -d $DBNAME -s service_name
-- this command will start the service. And usually it's' repeated for each service you setup on each
-- node if you have multiple services setup for the cluster. 

5. Check the status of service:
$ srvctl status service -d $DBNAME

6. Obtain the config status of service
$ srvctl config service -d $DBNAME -s service_name -a

Example:
$ srvctl add dagtabase -d DB1 -o $ORACLE_HOME
$ srvctl add instance -d DB1 -i INST1 -n host1
$ srvctl add instance -d DB1 -i INST2 -n host2
$ srvctl add instance -d DB1 -i INST3 -n host3
$ srvctl add service -d DB1 -s SVC1 -r host1 -a host2, host3
$ srvctl start service -d DB1 -s SVC1
$ srvctl status service -d DB1 -s SVC1
$ srvctl status service -d DB1 --> list all services under database DB1
$ srvctl cnofig service -d DB1 -s SVC1 -a

To Configure & Start dbcontrol in 10g/11g

To Configure & Start dbcontrol in 10g/11g:
Since Oracle 10g, the GUI tool innovated by Oracle to administrate Oracle database/instances are called "Database Control" or "DB console". To help you setting up with easy tips, I condensed the steps to the most simple summary:
1.       Procedure to setup dbconsole:
a.       $ export ORACLE_HOST_NAME = logical hostname
n  This is required since Oracle 10g to setup dbcontrol.

b.      $ emca –config dbcontrol db –repos create
n  This command would generate emca logs located at:
/opt/oracle/pathpod/product/10.x.x.x/cfgtoollogs/emca

c.       $ emca start dbconsole
n  This command will startup the dbconsole


2.       The emca –config dbcontrol db –repos create creats the following objects, which may cause problems if any of those objects already exist in the database. If it hits to an error message saying any of the objects below already exists, then clean up all the objects below and rerun the emca –config –dbcontrol db –repose create command
n  User sysman
n  User mgmt_view
n  Role mgmt_user
n  Public synonym mgmt_target_blackouts
n  Public synonym setemviewusercontext

3.       And I recommend to write a drop scripts to clean out those objects
EX: em_object_clean.sql

Spool em_object_clean.out
Set echo on
Drop user sysman cascade;
Drop user mgmt_view;
Drop role_mgmt_user;
Drop public synonym mgmt_target_blackouts;
Drop public synonym setemviewusercontext;
Spool off

** Note: Be aware of that, clean out the old EM console objects will wide out all the old history of your EM objects, including snapshots, SWR reports, etc; because those objects are owned by sysman user. Therefore, dropping the sysman cascade command actually wipes out those objects. Be considerable before taking this action.