-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOracle RAC Basics.txt
More file actions
137 lines (94 loc) · 5.12 KB
/
Oracle RAC Basics.txt
File metadata and controls
137 lines (94 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Oracle RAC Basics
Login
sqlplus / as sysdba
sqlplus user/password@database-name (ex. sqlplus na_admin/Password1@hpna)
-----------------------------------------------------------
Initialization Parameters File
Location = $ORALCE_HOME/dBS
Sample File = init.ora
-----------------------------------------------------------
Handy Commands
tnsping Checks availablity of an Oracle instance/service
lsnrctl status Checks status of the oracle listner
crsctl check crs Check the Cluster Ready Services status
crs_stat -t (table format) -v (verbosely) Check the Cluster Ready Services status in detail (table format)
crsctl query css votedisk Checks voting disk
srvctl status asm -a Checks status of ASM instance on all nodes in the cluster
crsctl status resource -t Clusterware Resource Status Check
srvctl status database -d ORCL STATUS OF DATABASE
srvctl stop listener -l LISTENER_NAME STOP A LISTENER
srvctl start listener -l LISTENER_NAME START A LISTENER
crsctl stop has stop all the clusterware services/ resources on specific node (including DB and listener) (run as root)
crsctl start has start all the clusterware services/ resources on specific node (including DB and listener) (run as root)
crsctl stop cluster -all to stop csr services on all nodes of clusterware (run as root)
crsctl start cluster -all to start crs services on all nodes of clusterware (run as root)
crsctl check has to check if ohasd is running/ stopped (run as root)
crsctl enable has enable Oracle High Availability Services autostart (run as root)
crsctl disable has disable Oracle High Availability Services autostart (run as root)
crsctl config has check if Oracle High Availability Services autostart is enabled/ disabled (run as root)
srvctl status nodeapps to check the status of services on all nodes
crsctl stop crs stop all the clusterware services/ resources ON THAT NODE! (run as root)
crsctl start crs start all the clusterware services/ resources ON THAT NODE! (run as root)
cluvfy comp scan -verbose Verifying scan status scan_listener
srvctl config scan_listener Verifying scan port
srvctl relocate scan -i 1 -n NODE1 Relocate scan listener 1 to the mentioned node
-----------------------------------------------------------
SQL Statements
select name from v$database outputs how many databases exist
desc <table_name> describes the columns in a particular table
select tablespace_name, table_name from all_tables; list all tables accessable to the current user
select tablespace_name, table_name from user_tables; list all tables owned by the current user
select tablespace_name, table_name from dba_tables; list all tables in the database
-----------------------------------------------------------
How to Query Output to *.csv or *.txt format
>!pwd check current directory
>spool [filename] set the name of output file; it will be saved in the directory from previous step
>select column1 || "," || column2 from table; run query and set "," as the delimeter
test,test
test1,test1
test2,test2
>spool off turn spooling off
>exit exit SQL plus
check directory for output file
-----------------------------------------------------------
Setting Up the Environment
1) Set alias in .bashrc:
export PATH
alias genv='./home/oracle/.bash_profile_grid;envo' // for grid commands
alias denv='. /home/oracle/.bash_profile_database;envo; // for database commands
. /home/oracle/.bash_profile_database
envo
2) Create bash profiles and save them in /home/oracle
touch .bash_profile_database
touch .bash_profile_grid
3) Fill each bash profile with the following contents
Database
export TMP=/tmp
export ORACLE_HOSTNAME=
export ORACLE_UNQNAME=
export ORACLE_BASE=
export ORACLE_HOME=
export ORACLE_SID=
PATH=/usr/sbin/:$PATH:$ORACLE_HOME/bin:/opt/ora01/app/oracle/product/12.1.0/db_1/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME;
alias tns='cd $ORACLE_HOME/network/admin'
alias envo='env | grep ORACLE'
umask 022
Grid
export TMP=/tmp
export ORACLE_HOSTNAME=
export ORACLE_UNQNAME=+ASM
export ORACLE_BASE=/opt/ora01/app/oracle
export GRID_HOME=/opt/ora01/app/grid/product/12.1.0/grid
export GRID_SID=+ASM2
PATH=/usr/sbin/:$PATH:$GRID_HOME/bin:/opt/ora01/app/grid/product/12.1.0/grid/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME;
alias tns='cd $ORACLE_HOME/network/admin'
alias envo='env | grep ORACLE'
umask 022