[Docker] oracle19c 설치 가이드.(이미지 빌드, 컨테이너 기동, 원격 서버에서 접속 ...)

2021. 11. 17. 10:25Tool/docker

728x90
728x90

도커 서버 설치 참고.


oracle19c 이미지 빌드를 위해서 필요한 작업.

1.oracle19c 이미지를 빌드할 수 있는 스크립트가 존재하는 디렉토리(dockerfiles)를 git에서 클론.

2.오라클19c 바이너리(LINUX.X64_193000_db_home.zip) 다운로드.

3.다운로드한 바이너리를 클론해온 스크립트 디렉토리(dockerfiles/${version})로 이관.

4.이미지를 빌드할 수 있는 스크립트 파일(buildContainerImage.sh) 실행.

oracle19c 이미지 빌드를 위한 스크립트 파일 git에서 클론 작업.

1.repository 전체 다운로드

$git clone https://github.com/oracle/docker-images

2.특정 repository만 다운로드(글쓴이는 "특정 repository 다운로드"로 진행.)

2.1.github-files-fetcher 패키지 다운로드

$sudo npm i -g github-files-fetcher
/usr/bin/fetcher -> /usr/lib/node_modules/github-files-fetcher/index.js
/usr/bin/github-files-fetcher -> /usr/lib/node_modules/github-files-fetcher/index.js
/usr/lib
└── github-files-fetcher@1.6.0

2.2.oracle19c 이미지를 빌드할 수 있는 스크립트 디렉토리를 clone.

$fetcher --url=https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles

2.3클론해온 디렉토리 확인.

$pwd
/root/dockerfiles
$ls
11.2.0.2  12.1.0.2  12.2.0.1  18.3.0  18.4.0  19.3.0  21.3.0  buildContainerImage.sh

 

다운로드한 oracle19c 설치 바이너리를 클론해온 스크립트 파일 경로(dockerfiles/${version})로 이관.

1.링크에서 오라클19c 바이너리 다운로드.

2.다운로드한 oracle19c binary(LINUX.X64_193000_db_home.zip)를 dockerfiles/${version} 경로로 이관.

3.oracle19c 빌드 스크립트에 vi 패키지 설치 명령이 없으므로, dockerfiles/${version}/setupLinuxEnv.sh에 vi 패키지 설치 명령 추가.

#/root/dockerfiles/19.3.0/setupLinuxEnv.sh
yum -y install vi && \

oracle19c 이미지 빌드 실행("Build completed"까지 약 15분 ~ 20분 소요)

[/root/dockerfiles] $ ./buildContainerImage.sh -v 19.3.0 -s

…

  Oracle Database container image for 'se2' version 19.3.0 is ready to be extended:     
    --> oracle/database:19.3.0-se2
  Build completed in 854 seconds.

빌드된 이미지 확인.

$docker images
REPOSITORY        TAG          IMAGE ID       CREATED         SIZE
oracle/database   19.3.0-se2   4d2b089a6a0a   3 minutes ago   6.54GB
oraclelinux       7-slim       078d6e3ae75e   2 weeks ago     132MB

oracle19c 볼륨 생성.

$docker volume create oracle19c

oracle19c 컨테이너 생성 & 실행.

  • 볼륨 처리 "-v", 포트바인딩 처리 "-p", 환경 변수 설정 "-e"
$docker run --name oracle19c -p 1519:1521 -p 5519:5500 -v oracle19c:/opt/oracle/oradata -e ORACLE_SID=ORCLCDB -e ORACLE_PDB=ORCLPDB1 -e ORACLE_PWD=[PASSWD] --restart always oracle/database:19.3.0-se2

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

  • "DATABASE IS READY TO USE!"까지 약 10분 소요.
$docker logs -f oracle19c
ORACLE EDITION: STANDARD

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 16-NOV-2021 09:12:01

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

Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/77e97200d15e/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                16-NOV-2021 09:12:01
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/77e97200d15e/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended 
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, co
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommend
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, co
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recomme
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, co
b.The password entered is a keyword that Oracle does not recommend to be used as password
   ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
Database Information:
Global Database Name:ORCLCDB
System Identifier(SID):ORCLCDB
Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 16 09:26:51 2021
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> 
System altered.

SQL> 
System altered.

SQL> 
Pluggable database altered.

SQL> 
PL/SQL procedure successfully completed.

SQL> SQL> 
Session altered.

SQL> 
User created.

SQL> 
Grant succeeded.

SQL> 
Grant succeeded.

SQL> 
User altered.

SQL> SQL> Disconnected from Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
The Oracle base remains unchanged with value /opt/oracle
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2021-11-16T09:26:51.863022+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
2021-11-16T09:26:51.870800+00:00
ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
   ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
Completed:    ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2021-11-16T09:26:52.030972+00:00

oracle19c 컨테이너 기동 확인.

$docker ps | grep oracle19c
CONTAINER ID   IMAGE                        COMMAND                  CREATED        STATUS                  PORTS                                                                                  NAMES
77e97200d15e   oracle/database:19.3.0-se2   "/bin/sh -c 'exec $O…"   15 hours ago   Up 15 hours (healthy)   0.0.0.0:1519->1521/tcp, :::1519->1521/tcp, 0.0.0.0:5519->5500/tcp, :::5519->5500/tcp   oracle19c

oracle19c 컨테이너 접속.

$docker exec -it oracle19c bash
[oracle@77e97200d15e ~]$

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

[oracle@77e97200d15e ~]$ sqlplus sys/[$PASSWD]@[$SID Name] as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 17 00:19:48 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>

테이블 스페이스 생성

CREATE TABLESPACE gomu92
DATAFILE '/opt/oracle/oradata/ORCLCDB/gomu92.dbf' SIZE 500M
AUTOEXTEND ON NEXT 50M;

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

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

볼륨 처리 확인.

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

[oracle@77e97200d15e oradata]$ pwd
/opt/oracle/oradata
[oracle@77e97200d15e oradata]$ ls -al
total 20
drwxr-xr-x 4 oracle dba      4096 Nov 16 09:26 .
drwxr-xr-x 1 oracle dba      4096 Nov 16 09:26 ..
-rw-r--r-- 1 oracle oinstall    0 Nov 16 09:26 .ORCLCDB.created
drwxr-x--- 4 oracle oinstall 4096 Nov 17 00:32 ORCLCDB
drwxr-xr-x 3 oracle oinstall 4096 Nov 16 09:26 dbconfig

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

$pwd
/var/lib/docker/volumes/oracle19c/_data
$ls -al
합계 16
drwxr-xr-x 4 54321 54322 4096 11월 16 18:26 .
drwx-----x 3 root  root  4096 11월 16 17:58 ..
-rw-r--r-- 1 54321 54321    0 11월 16 18:26 .ORCLCDB.created
drwxr-x--- 4 54321 54321 4096 11월 17 09:32 ORCLCDB
drwxr-xr-x 3 54321 54321 4096 11월 16 18:26 dbconfig

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

$ pwd
/var/lib/docker/volumes/oracle19c/_data/ORCLCD
$ls -al
합계 3094532
drwxr-x--- 4 54321 54321      4096 11월 17 09:32 .
drwxr-xr-x 4 54321 54322      4096 11월 16 18:26 ..
drwxr-x--- 2 54321 54321      4096 11월 16 18:26 ORCLPDB1
-rw-r----- 1 54321 54321  18726912 11월 17 09:50 control01.ctl
-rw-r----- 1 54321 54321  18726912 11월 17 09:50 control02.ctl
-rw-r----- 1 54321 54321 524296192 11월 17 09:32 gomu92.dbf
drwxr-x--- 2 54321 54321      4096 11월 16 18:16 pdbseed
-rw-r----- 1 54321 54321 209715712 11월 17 09:50 redo01.log
-rw-r----- 1 54321 54321 209715712 11월 16 18:26 redo02.log
-rw-r----- 1 54321 54321 209715712 11월 17 00:26 redo03.log
-rw-r----- 1 54321 54321 555753472 11월 17 09:49 sysaux01.dbf
-rw-r----- 1 54321 54321 943726592 11월 17 09:49 system01.dbf
-rw-r----- 1 54321 54321 125837312 11월 17 07:00 temp01.dbf
-rw-r----- 1 54321 54321 356524032 11월 17 09:48 undotbs01.dbf
-rw-r----- 1 54321 54321   5251072 11월 17 00:57 users01.dbf

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

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

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

$ vi $TNS_ADMIN/tnsnames.ora
ORA19C_docker =
  (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1519))
        (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SID = ORCLCDB)
        )
  )
$sqlplus system/[$PASSWD]@ORA19C_docker
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 17 10:01:39 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Last Successful login time: Wed Nov 17 2021 09:57:11 +09:00
Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
728x90
728x90