[Docker] Oracle12c 설치 가이드.(이미지 다운로드, 컨테이너 생성/실행, 원격에서 Oracle12c 서버로 접속 ...)

2021. 11. 3. 19:27Tool/docker

728x90
728x90

도커 서버 설치 참고.

docker hub에서 oracle12c 공식 이미지 다운로드 권한 획득.

1.링크(도커 허브) 접속 후 로그인.

 

2."Proceed to Checkout" 클릭.

3.개인 정보 입력.

4.제약 조건 동의 후 "Get Content" 클릭.


도커 서버에서 로그인 수행.

$docker login

oracle12c 이미지 다운로드

$docker pull store/oracle/database-enterprise:12.2.0.1
Trying to pull repository docker.io/store/oracle/database-enterprise ... 
12.2.0.1: Pulling from docker.io/store/oracle/database-enterprise
4ce27fe12c04: Pull complete 
9d3556e8e792: Pull complete 
fc60a1a28025: Pull complete 
0c32e4ed872e: Pull complete 
b465d9b6e399: Pull complete 
Digest: sha256:40760ac70dba2c4c70d0c542e42e082e8b04d9040d91688d63f728af764a2f5d
Status: Downloaded newer image for docker.io/store/oracle/database-enterprise:12.2.0.

다운로드한 oracle12c 이미지 확인.

$docker images | grep store/oracle/database-enterprise
docker.io/store/oracle/database-enterprise   12.2.0.1            12a359cd0528        4 years ago         3.44 GB

도커 서버(로컬/호스트)에 oracle12c 볼륨 생성.

$docker volume create oracle12c

오라클12c 컨테이너 생성 & 실행.

  • 볼륨 처리 옵션 : -v
  • 포트바인딩 처리 옵션 : -p
$docker run -idt --name oracle12c -p 1512:1521 -p 5500:5500  -v oracle12c:/ORCL/:z store/oracle/database-enterprise:12.2.0.1

$docker logs 명령을 통해서 오라클12c 서버가 기동되었는지 확인.

$docker logs -f oracle12c
Setup Oracle Database
Oracle Database 12.2.0.1 Setup
Wed Nov 3 07:44:35 UTC 2021

Check parameters ......
log file is : /home/oracle/setup/log/paramChk.log
paramChk.sh is done at 0 sec

untar DB bits ......
log file is : /home/oracle/setup/log/untarDB.log
untarDB.sh is done at 155 sec

config DB ......
log file is : /home/oracle/setup/log/configDB.log
Wed Nov 3 07:47:10 UTC 2021
Start Docker DB configuration
Call configDBora.sh to configure database
Wed Nov 3 07:47:11 UTC 2021
Configure DB as oracle user
Setup Database directories ...

SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 3 07:47:11 2021

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

Connected to an idle instance.

SQL> 
File created.

SQL> ORACLE instance started.

Total System Global Area 1342177280 bytes
Fixed Size		    8792536 bytes
Variable Size		  352323112 bytes
Database Buffers	  973078528 bytes
Redo Buffers		    7983104 bytes
Database mounted.
Database opened.
SQL> 
Database altered.

SQL> 
NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
spfile				     string	 /u01/app/oracle/product/12.2.0
						 /dbhome_1/dbs/spfileORCLCDB.or
						 a
SQL> 
NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
encrypt_new_tablespaces 	     string	 CLOUD_ONLY
SQL> 
User altered.

SQL> 
User altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
update password

Enter password for SYS: 
create pdb : ORCLPDB1

SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 3 07:48:08 2021

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>   2    3    4    5  
Pluggable database created.

SQL> 
Pluggable database altered.

SQL> 
Pluggable database altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Reset Database parameters

SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 3 07:49:06 2021

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 
System altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 03-NOV-2021 07:49:07

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

Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/08505c8bf892/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                03-NOV-2021 07:49:10
Uptime                    0 days 0 hr. 0 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/08505c8bf892/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

DONE!
Remove password info
Docker DB configuration is complete !
configDB.sh is done at 275 sec

Done ! The database is ready for use .
# ===========================================================================  
# == Add below entries to your tnsnames.ora to access this database server ==  
# ====================== from external host =================================  
ORCLCDB=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
    (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLCDB.localdomain)))     
ORCLPDB1=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
    (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLPDB1.localdomain)))     
#                                                                              
#ip-address : IP address of the host where the container is running.           
#port       : Host Port that is mapped to the port 1521 of the container.      
#                                                                              
# The mapped port can be obtained from running "docker port <container-id>"  
# ===========================================================================  
Thread 1 advanced to log sequence 5 (LGWR switch)
  Current log# 2 seq# 5 mem# 0: /u04/app/oracle/redo/redo002.log
2021-11-03T07:49:06.245887+00:00
ORCLPDB1(3):Opening pdb with no Resource Manager plan active
Pluggable database ORCLPDB1 opened read write
Completed:     alter pluggable database ORCLPDB1 open
    alter pluggable database all save state
Completed:     alter pluggable database all save state

oracle12c 컨테이너 기동 확인.

$docker ps | grep oracle12c
08505c8bf892        store/oracle/database-enterprise:12.2.0.1   "/bin/sh -c '/bin/..."   2 hours ago         Up 2 hours (healthy)   0.0.0.0:1512->1521/tcp, 0.0.0.0:5512->5500/tcp   oracle12c

oracle12c 컨테이너 접속.

$docker exec -it oracle12c bash
[oracle@08505c8bf892 /]$

컨테이너 내부 "/home/oracle" 경로에서 오라클 환경변수 적용.

  • ".bashrc" 참고. 볼륨처리한 "/ORCL/u01 … u04" 경로와 $ORACLE_HOME "/u01 … u04" 경로는 링킹되어 있음.
[oracle@08505c8bf892 /home/oracle]$. ./.bashrc

컨테이너 내부에서 sys 계정으로 sqlplus 접속.

$sqlplus system/Oradoc_db1
SQL*Plus: Release 12.2.0.1.0 Production on Wed Nov 3 07:51:10 2021
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>

테이블 스페이스 생성.

SQL> CREATE TABLESPACE gomu92
DATAFILE '/u02/app/oracle/oradata/ORCL/gomu92.dbf' SIZE 500M
AUTOEXTEND ON NEXT 50M;

계정 생성, 계정 권한 추가.

SQL> alter session set "_ORACLE_SCRIPT"=true;
SQL> CREATE USER gomu92 IDENTIFIED BY gomu92 DEFAULT TABLESPACE gomu92;
SQL> grant connect, resource, dba to gomu92;

 

외부에서 접속이 가능한지 확인.(포트 바인딩 확인)

1.admin tool을 활용한 접속 확인.

  • system 계정의 passwd는 "Oradoc_db1"이며, 글쓴이는 tibero admin을 활용함.

2.oracle client 환경에서 sqlplus를 활용한 접속 확인.

2.1.oracle client 환경의 $TNS_ADMIN/tnsnames.ora 설정.

ORA12C =
  (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1512))
        (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SID = ORCLCDB)
        )
  )

2.2.oracle client 환경에서 sqlplus를 사용하여 접속 확인.

$sqlplus system/Oradoc_db1@ORA12C
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 3 17:13:03 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Last Successful login time: Wed Nov 03 2021 17:09:18 +09:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>

볼륨 처리 확인.

1.컨테이너 내부의 볼륨 경로 확인.

$ pwd
/ORCL
$ ls -al
total 4
drwxr-xr-x. 6 oracle oinstall   46 Nov  3 07:45 .
drwxr-xr-x. 1 root   root     4096 Nov  3 07:44 ..
drwxr-xr-x. 3 oracle oinstall   16 Aug  8  2017 u01
drwxr-xr-x. 3 oracle oinstall   16 Aug  8  2017 u02
drwxr-xr-x. 3 oracle oinstall   16 Aug  8  2017 u03
drwxr-xr-x. 3 oracle oinstall   16 Aug  8  2017 u04

2.도커 서버(로컬/호스트)의 볼륨 경로 확인.

$pwd
/var/lib/docker/volumes/oracle12c/_data
$ ls -al
합계 4
drwxr-xr-x. 6 54321 54321 46 11월  3 16:45 .
drwxr-xr-x. 3 root  root  18 11월  3 16:44 ..
drwxr-xr-x. 3 54321 54321 16  8월  9  2017 u01
drwxr-xr-x. 3 54321 54321 16  8월  9  2017 u02
drwxr-xr-x. 3 54321 54321 16  8월  9  2017 u03
drwxr-xr-x. 3 54321 54321 16  8월  9  2017 u04

3.도커 서버(로컬/호스트)의 볼륨 경로에서 생성한 테이블 스페이스(gomu92.dbf)가 존재하는지 확인.

$pwd
/var/lib/docker/volumes/oracle12c/_data/u02/app/oracle/oradata/ORCL
$ls
cntrlORCLCDB.dbf  orclpdb1  sysaux01.dbf  temp01.dbf     users01.dbf
gomu92.dbf        pdbseed   system01.dbf  undotbs01.dbf
728x90
728x90