3.1 Practice 03 Oracle RAC Administration Topics
3.1 Practice 03 Oracle RAC Administration Topics
Practice 3
Practice Overview
In this practice you will perform some common Oracle RAC Administration tasks. Specifically, you will
perform the following:
• Use multiple connection methods to Oracle RAC database
Practice Assumptions
The practice assumes that you have the Oracle RAC database up and running in the virtual machines
srv1 and srv2.
Practice Procedures
2. Using SQL*Plus utility, connect to rac database as sysdba without providing the password. Check
out to which instance the session has been connected.
sqlplus / as sysdba
This type of connection is called "operating system authenticated" connection. Consider the
following about this connection type:
• It does not require a password.
• It always connects to the local instance.
• An operating system account is needed for the user.
• For an Oracle RAC database, it requires the ORACLE_SID variable to set to the local instance
name.
3. Set the ORACLE_SID variable to "rac" and try connecting to the database using the operating
system authentication.
# display the current value of ORACLE_SID:
echo $ORACLE_SID
4. Try connecting to the local instance as sysdba using the password of sys.
The password of sys is saved in the password file. That is why this method of connection is called
"password file authenticated" connection.
sqlplus sys/oracle as sysdba
6. Connect as system user. Once using a correct password and another time using an incorrect
password.
conn system/oracle
conn system/wrong
This method of authentication is called database authenticated connection. In this method, the
password is saved in the database and the password must be correct to log in.
7. Connect as system user with a wrong password but use the as sysdba option.
conn system/wrong as sysdba
show user
When you use the as sysdba, Oracle logs on as sys user, regardless of the username you used in
your connection attempt. The previous command succeeds because Oracle used the operating
system authentication.
8. Connect as sysdba using sys as a username and an incorrect password but use the tns naming
method this time.
conn sys/wrong@rac as sysdba
Tns naming method supersedes any other connection method. This connection goes through the
listener and Oracle considers this connection as a client connection, not a local connection.
Note: For further information, refer to the section "Configuring Authentication" in the documentation
"Database Administration".
10. Using SQL*Plus utility, connect to rac database using Easy Connect method.
# repeat the following commands multiple times:
conn system/oracle@//srv-scan/rac.localdomain
SELECT INSTANCE_NAME FROM V$INSTANCE;
Note: Oracle recommends against using the easy connect method with SCAN host name because
the easy connect method does not have the ability to specify timeouts and retries for connection
establishment. Instead, applications should use an Oracle Net connect descriptor.
11. Use the easy connect method to connect to the instance rac1
# repeat the following commands multiple times:
conn system/oracle@//srv-scan/rac.localdomain:srv1/rac1
SELECT INSTANCE_NAME FROM V$INSTANCE;
You can configure the tnsnames.ora to connect to specific instances. In the following steps, you will
configure the tnsnames.ora file to store connections to rac1 and rac2. The connections that you will
configure does not use the load balancing feature. Each connection connects to specific instance and it
fails if that instance is down and even if the other instance is up. That is the reason you do not use the
SCAN name nor the VIP address to define the host name in such configuration.
12. In srv1 and srv2, add the following connect descriptors to the tnsnames.ora file.
Do not copy from the PDF file. Copy the code from the downloadable tnsnames.ora file.
vi $TNS_ADMIN/tnsnames.ora
RAC1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv1.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = rac1)
)
)
RAC2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv2.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = rac2)
)
)
13. Test the connection configurations that you made in the previous step. Verify that you are
connected to the required instance.
sqlplus /nolog
conn system/oracle@rac1
SELECT INSTANCE_NAME FROM V$INSTANCE;
conn system/oracle@rac2
SELECT INSTANCE_NAME FROM V$INSTANCE;
exit
B. Use the Various Methods to Start and Stop Oracle RAC Instances
In this section of the practice, you will examine the methods to stop and startup an Oracle RAC
instance and an Oracle RAC database.
14. In a Putty session, make sure you are connected to srv1 as oracle user.
15. Using the srvctl utility, check the status of the database.
srvctl status database -d rac
# connect to the database and verify to which instance the session is connected
sqlplus system/oracle@rac
SELECT INSTANCE_NAME FROM V$INSTANCE;
18. Stop the instances rac1 and rac2 in a single srvctl utility command.
srvctl stop instance -d rac -i rac1,rac2 -o immediate
The command reports that rac1 was already down but it still shuts down rac2.
At this stage the database is down and no user can connect to it.
19. Using SQL*Plus, connect to the local Oracle database instance as sysdba using the operating
system authentication. Then, issue the startup command.
Note: in Oracle RAC database, this is not the recommended method to startup an instance.
Always stick to using the srvctl utility command.
sqlplus / as sysdba
startup
20. Exit from SQL*Plus and check the status of the database using the srvctl utility.
srvctl status database -db rac
Observe that the startup command started the local instance (rac1) but not the entire
database.
23. Display the syntax usage help for srvctl status home command.
srvctl status home -help
24. Use the "srvctl status home" command to check the state of all the resources that are running
from Oracle home. Save the status of the resources in a file in the oracle home directory for node
rac1.
srvctl status home -oraclehome $ORACLE_HOME -statefile ~/rac1_state.dmp -node
srv1
25. Display the syntax usage help for the command "srvctl stop home".
srvctl stop home -help
In this section of the practice, you will examine how to manage the initialization parameters in Oracle
RAC database. The section concentrates on managing the parameters in spfile, not in pfile. This is
because spfile is the format of the initialization parameters file that is highly recommended to use in
production databases and it is the default.
31. In a Putty session, make sure you are connected to srv1 as oracle user.
32. Login as sys to rac1 instance and check out the location of the spfile.
sqlplus sys/oracle@rac1 as sysdba
show parameter spfile
33. Login as system to rac2 instance and check out the location of the spfile.
conn sys/oracle@rac2 as sysdba
show parameter spfile
34. Login back again to rac1 instance and create pfile from spfile. View the contents of the generated
pfile.
conn sys/oracle@rac1 as sysdba
host mkdir /home/oracle/scripts
CREATE PFILE='/home/oracle/scripts/racpfile.ora' FROM SPFILE;
host cat /home/oracle/scripts/racpfile.ora
Observe that the following parameters have different values for each instance.
o INSTANCE_NUMBER
o THREAD
o UNDO_TABLESPACE
Observe that all the instances have the same value for the parameter DB_NAME
In the following steps you will examine the different ways to change a parameter in the memory of an
instance and in the spfile in a RAC database. The parameter ddl_lock_timeout is used as an
example.
35. Create a script file and add the code in it as shown in the following code.
The script simply prints out the parameter memory value in the current instance and the
parameter value in the SPFILE.
# create the following script file:
host vi myfile.sql
39. Set the value of the parameter to 120 only in the instance rac1. Do not specify the SCOPE.
ALTER SYSTEM SET DDL_LOCK_TIMEOUT =120 SID='rac1';
41. Delete the parameter setting from the spfile that applies on all the instances.
The command ALTER SYSTEM RESET is used to delete a parameter setting from spfile.
ALTER SYSTEM RESET DDL_LOCK_TIMEOUT;
45. Set the parameter value in the memory to its default setting.
ALTER SYSTEM SET DDL_LOCK_TIMEOUT=0 SCOPE=MEMORY;
Summary
• srvctl utility is the preferred method to start and stop an Oracle RAC database or a RAC
instance.
• You have the option to shut down the entire Oracle Home resources using the srvctl utility.
• Some initialization parameters can be modified in the memory and/or in the SPFILE. Some of
them accept modification in the instance level and the rest can be modified only in the
database level.