mingming

Database - Oracle 본문

새싹 하이브리드 클라우드/Database

Database - Oracle

mingming_96 2023. 10. 4. 18:23

Oracle Database Client 설치

로컬 혹은 Oracle SQL Developer를 통해 쉽게 Oracle DB 에 접속할 수 있도록 도와주는 프로그램 입니다.

일반적으로 Oracle Server 설치 시 같이 설치되지만, 클라이언트 모듈만 따로 다운받아 설치했습니다.

 

Oracle SQL Developer 설치

오라클 데이터베이스와 상호작용하기 위한 통합 개발환경으로, SQL 쿼리 및 스크립트 작성, 테이터 베이스 객체 관리 등의 기능을 지원합니다. 아래의 버전을 설치해줍니다.

tnsnames.ora

'.ora 파일' : ora 파일은 Oracle 데이터 베이스 설정 및 구성 정보를 저장하는 텍스트 파일입니다. 

tnsnames.ora 파일은 데이터베이스 서버 및 클라이언트 간의 연결 정보를 정의합니다. Oracle Database로 원격 접속 할 때 이 파일을 통해 연결에 필요한 정보를 찾습니다.

Oracle Database Client 설치한 위치에 network/admin 경로에 위치합니다.

ORA19C =
 (DESCRIPTION =
	(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))  ## localhost portfowarding
	(CONNECT_DATA =
		(SERVER = DEDICATED)
		(SID = ora19c)
		(SERVICE_NAME = ORCL)
	)
 )

 

Oracle Database Start

1. 관리자 계정으로 DB 접속(최상위 계정) 

Database start 와 shutdown은 최상위 계정에서만 가능합니다.

sqlplus / as sysdba

2. DB Startup

SQL> startup
ORACLE instance started.

Total System Global Area  591395496 bytes
Fixed Size                  8899240 bytes
Variable Size             239075328 bytes
Database Buffers          335544320 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.

SQL> quit

3. 리스너 설정

lsnrctl 명령어를 통해 리스너를 동작시킵니다.

ORA19C@/home/oracle> lsnrctl start

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 04-OCT-2023 18:09:04

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Starting /oracle/product/19.0.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /oracle/product/19.0.0/network/admin/listener.ora
Log messages written to /oracle/diag/tnslsnr/edu/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edu)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edu)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                04-OCT-2023 18:09:04
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/19.0.0/network/admin/listener.ora
Listener Log File         /oracle/diag/tnslsnr/edu/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edu)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

 

4. 작동중 확인

ps -ef | grep pmon && ps -ef |grep tns

ORA19C@/home/oracle> ps -ef | grep pmon && ps -ef |grep tns
oracle    6422     1  0 18:07 ?        00:00:00 ora_pmon_ORA19C
oracle    6873 17510  0 18:10 pts/2    00:00:00 grep --color=auto pmon
root        19     2  0 12:41 ?        00:00:00 [netns]
oracle    6798     1  0 18:09 ?        00:00:00 /oracle/product/19.0.0/bin/tnslsnr LISTENER -inherit
oracle    6875 17510  0 18:10 pts/2    00:00:00 grep --color=auto tns

Oracle DB 와 리스너가 정상적으로 실행되면 6422, 6798 두 개의 프로세스가 실행됩니다.

 

 

Oracle Database 로컬 접속

위에서 처럼 해당 OS 에서 접속해서 사용해도 되지만, 로컬에서 접속해 더 편한 환경에서 작업할 수 있습니다.

 

1. 로컬 터미널

위에서 작성한 tnsnames.ora 파일에 정의되어 있는 설정으로 접속가능합니다.

sqlplus username/password@servicename

sqlplus system/oracle@ora19c

 

2. Oracle SQL Develover

사용자 이름 : Oracle Database username

비밀번호 : Oracle Database user password

호스트 이름 : Oracle Databse 

SID (System Identifier): tnsnames.ora 파일에 정의한 SID 를 적어주시면 됩니다. 

 

Oracle Database 종료

Oracle Database 시작의 역순으로 종료할 수 있습니다.

1. 리스너 동작 중지

ORA19C@/home/oracle> lsnrctl stop

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 04-OCT-2023 18:18:48

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=edu)(PORT=1521)))
The command completed successfully

 

2. 관리자계정 ( 최상위 계정 ) 접속 및 가동 중지

ORA19C@/home/oracle> sqlplus / as sysdba

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

 

3. 프로세스 확인

ps -ef | grep pmon && ps -ef |grep tns

ORA19C@/home/oracle> ps -ef | grep pmon && ps -ef |grep tns
oracle    7512 17510  0 18:20 pts/2    00:00:00 grep --color=auto pmon
root        19     2  0 12:41 ?        00:00:00 [netns]
oracle    7514 17510  0 18:20 pts/2    00:00:00 grep --color=auto tns

 

Oracle Listener 명령어

lsnrctl help

lsnrctl status

lsnrctl start

lsnrctl stop

lsnrctl reload

lsnrctl -> 관리 모드 실행

 

'새싹 하이브리드 클라우드 > Database' 카테고리의 다른 글

Oracle - SQL (DDL)  (3) 2023.10.07
Oracle - SQL (DML)  (0) 2023.10.07
Oracle - SQL Query (2)  (0) 2023.10.06
데이터 베이스 언어 SQL  (0) 2023.10.06
Oracle - SQL Query  (0) 2023.10.05