Oracle

From Smithnet Wiki
Jump to navigation Jump to search

Installation

Database Configuration

Example configuration:

ORACLE_BASE=/opt/oracle/app/oracle
ORACLE_HOME=/opt/oracle/app/oracle/product/12.2.0/dbhome_1
PATH=$PATH:$ORACLE_HOME/bin

Define which databases should be started with dbstart:

/etc/oratab

Listener config $ORACLE_HOME/network/admin/listener.ora:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME=ORCL)
      (ORACLE_HOME=/opt/oracle/app/oracle/product/12.2.0/dbhome_1)
      (SID_NAME=ORCL)
    )
  )
LISTENER =
(DESCRIPTION_LIST =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dbhostname)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

TNS Names config $ORACLE_HOME/network/admin/tnsnames.ora:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

Start/Stop databases:

dbstart
dbshut 

Start/Stop TNS lisenter:

lsnrctl start
lsnrctl stop

SQL Plus

Login:

sqplus username/password@servicename

Common Operations

Change the system password, and make it unlimited time:

alter user system identified by manager;
alter profile default limit password_life_time unlimited;

Useful Queries