Oracle DB for system administrators, part1

This serie of posts is intended to give kickstart overview on oracle database for system administrators. For more deep knowledge please consult oracle documentation Here I will use only command line utilities (much elegant for automation). If you prefer you can use many other tools like OEM, Toad, SQL Developer, etc.
1. Let start the database I asume you are login as oracle user, or any other user, member of DBA group
1.1 First start listener

[oracle@rh-or ~]$ lsnrctl start 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-MAR-2010 13:05:50  Copyright (c) 1991, 2009, Oracle.  All rights reserved.  Starting /home/oracle/11g2/bin/tnslsnr: please wait...  TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /home/oracle/11g2/network/admin/listener.ora Log messages written to /home/oracle/base/diag/tnslsnr/rh-or/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rh-or)(PORT=1521)))  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias                     LISTENER Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date                07-MAR-2010 13:05:50 Uptime                    0 days 0 hr. 0 min. 2 sec Trace Level               off Security                  ON: Local OS Authentication SNMP                      OFF Listener Parameter File   /home/oracle/11g2/network/admin/listener.ora Listener Log File         /home/oracle/base/diag/tnslsnr/rh-or/listener/alert/log.xml Listening Endpoints Summary...   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rh-or)(PORT=1521))) The listener supports no services The command completed successfully

1.2 Then start the database itself

[oracle@rh-or ~]$ sqlplus / as sysdba  
SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 7 13:06:37 2010  Copyright (c) 1982, 2009, Oracle.  All rights reserved.  Connected to an idle instance. 
SQL> startup 
ORACLE instance started.  Total System Global Area  422670336 bytes Fixed Size                  1336960 bytes Variable Size             318769536 bytes Database Buffers           96468992 bytes Redo Buffers                6094848 bytes Database mounted. Database opened. 
SQL>

2. Check if database and listener are run

[oracle@rh-or ~]$ ps -efl|grep lsnr 
0 S oracle   10324     1  0  75   0 - 10527 stext  13:05 ?        00:00:00 /home/oracle/11g2/bin/tnslsnr LISTENER -inherit 
0 R oracle   10473  3892  0  79   0 -   428 -      13:07 pts/0    00:00:00 grep lsnr
[oracle@rh-or ~]$ ps -efl|grep ora_ 
0 S oracle   10376     1  0  75   0 - 142554 -     13:06 ?        00:00:00 ora_pmon_orcl 
0 S oracle   10378     1  0  58   - - 142388 -     13:06 ?        00:00:00 ora_vktm_orcl 
0 S oracle   10382     1  0  75   0 - 142388 -     13:06 ?        00:00:00 ora_gen0_orcl 
0 S oracle   10384     1  0  78   0 - 142388 -     13:06 ?        00:00:00 ora_diag_orcl 
0 S oracle   10386     1  0  75   0 - 142390 -     13:06 ?        00:00:00 ora_dbrm_orcl 
0 S oracle   10388     1  0  75   0 - 142388 -     13:06 ?        00:00:00 ora_psp0_orcl 
0 S oracle   10390     1  0  78   0 - 142516 -     13:06 ?        00:00:00 ora_dia0_orcl 
0 S oracle   10392     1  0  78   0 - 142388 -     13:06 ?        00:00:00 ora_mman_orcl 
0 S oracle   10394     1  0  75   0 - 143363 -     13:06 ?        00:00:00 ora_dbw0_orcl 
0 S oracle   10396     1  0  75   0 - 146276 -     13:06 ?        00:00:00 ora_lgwr_orcl 
0 S oracle   10398     1  0  76   0 - 142388 -     13:06 ?        00:00:00 ora_ckpt_orcl 
0 S oracle   10400     1  0  75   0 - 142395 -     13:06 ?        00:00:00 ora_smon_orcl 
0 S oracle   10402     1  0  75   0 - 142389 -     13:06 ?        00:00:00 ora_reco_orcl

3. Lets try to login to database

[oracle@rh-or ~]$ sqlplus user/password@SID  

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 7 13:01:43 2010  Copyright (c) 1982, 2009, Oracle.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options  
SQL>

where user is the username you want to login, password is the password for this user and SID is the the SID identifier of this instance of Oracle database. SID can be name of the SID, hostname or IP address. Above we are login on different way which is possible only if you are login on the same host as database and you are user Oracle DB start 4. Lets make our first retrieve of information from database

SQL> select username,user_id from dba_users;  
USERNAME                          USER_ID ------------------------------ ---------- SYSTEM                                  5 SYS                                     0 MGMT_VIEW                              74 DBSNMP                                 30 SYSMAN                                 72 OUTLN                                   9 OLAPSYS                                61 SI_INFORMTN_SCHEMA                     56

Here we select columns username and user_id from table of users, defined in database, named dba_users

No comments:

Post a Comment

Compressed tar archive

There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...