среда, 12 ноября 2014 г.

Oracle DB в Linux

Весь день мучаюсь с Oracle DB, а главное уже второй раз в этом месяце.

Пару комманд себе на пямять



# sqlplus / as sysdba запустить sqlplus от sysdba

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Nov 13 00:57:40 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>


# lsnrctl status текущий статус запущенных инстансов database

[oracle@localhost ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 13-NOV-2014 01:00:36
Copyright (c) 1991, 2014, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 12-NOV-2014 22:50:45
Uptime 0 days 2 hr. 9 min. 51 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=5500))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/mtsua/xdb_wallet))(Presentation=HTTP)(Session=RAW))

Services Summary...
Service "mtsua" has 1 instance(s).
Instance "mtsua", status READY, has 1 handler(s) for this service...
Service "mtsuaXDB" has 1 instance(s).
Instance "mtsua", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...

The command completed successfully
[oracle@localhost ~]$

# dbca графический интерфейс работы с инстансами database

# tnsping резолвинг database instancr [oracle@localhost ~]$ tnsping ORCL

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 13-NOV-2014 00:16:54
Copyright (c) 1997, 2014, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@localhost ~]$ tnsping ORCL2
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 13-NOV-2014 00:16:57
Copyright (c) 1997, 2014, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
TNS-03505: Failed to resolve name
[oracle@localhost ~]$ 
#импорт дампа в базу
$ ORACLE_SID = mydbsid
$ cd /u01/app/oracle/admin/orcl/dpdump/
$ imp file=forisrd.dmp log=forisrd.imp.log full=y grants=y indexes=y constraints=y ignore=y 
 $ exp userid=rd/rd OWNER=rd DIRECT=Y FILE=forisrd.dmp grants=y indexes=y
$ cat forisrd.imp.log| grep error -A 3|grep "IMP-" -A 3 
Немного SQL запроссов
#порт EM Database Express
SQL> select dbms_xdb_config.gethttpport() from dual;
DBMS_XDB_CONFIG.GETHTTPPORT()
-----------------------------
5500
# запустить инстанс
SQL> STARTUP
#выключить инстанс
 SQL> SHUTDOWN NORMAL

Немного переменных
[oracle@localhost ~]$ echo $ORACLE_SID
orcl
[oracle@localhost ~]$
[oracle@localhost ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0/dbhome_1
[oracle@localhost ~]$ 
Ф-лы конфигурации
network/admin/listener.ora
network/admin/tnsnames.ora
dbs/init.ora
/u01/app/oracle/admin/orcl/dpdump/ для дампов DataPump 
/etc/oratab настройкизапуска инстансов БД
/usr/local/bin/oraenv  переменные для запуска БД

Ссылки


  • https://docs.oracle.com/cd/B28359_01/server.111/b32009/strt_stp.htm#UNXAR173 
Stopping and Starting Oracle Software