728x90
반응형

이전에  Docker 를 활용해 Oracle19c 를 설치 하는 방법에 알아 보았습니다. 

이번에는 docker-compose 를 활용해서 Oracle19c 를 설치 해보겠습니다. 

 

설치를 위한 파일 구조 생성 

이전에 소개했던 오라클19c 설치 글 (https://growupcoding.tistory.com/18 ) 내용과 거의 동일 하며 

Docker 오라클 실행 부분만 docker-compose를 활용해 설치해보겠습니다. 

compose 디렉토리 생성 및 공유 디렉토리 권한 변경

  • compose : 파일 및 Oracle19c 가 설치될 파일 디렉토리를 만듭니다. 
  • docker-compose.ora19c.yml : 이미지 빌드를 하기 위한 compose 파일 
  • or19env :  오라클 환경파일(ORACLE_HOME, ORACLE_SID)
  • oradata/ora19_data :오라클 데이터 파일이 생성될 공유 디렉토리

 

oracle-docker@ubuntu2004:~$ tree compose/
compose/
|-- docker-compose.ora19c.yml
|-- or19env
`-- oradata
    `-- ora19_data
        |-- ORCLCDB [error opening dir]
        `-- dbconfig
            `-- ORCLCDB
                |-- listener.ora
                |-- orapwORCLCDB
                |-- oratab
                |-- spfileORCLCDB.ora
                |-- sqlnet.ora
                `-- tnsnames.ora

 

compose 디렉토리 생성

mkdir -p compose/oradata/ora19_data

chmod -Rf 777 compose/oradata/ora19_data

사전 확인 및 준비 사항 (image,환경파일) 

oracle-docker@ubuntu2004:~/compose$ docker image ls
REPOSITORY        TAG         IMAGE ID       CREATED        SIZE
oracle/database   19.3.0-ee   c711d39c5597   2 hours ago    6.53GB
oraclelinux       7-slim      8dd98256c841   10 hours ago   133MB


oracle-docker@ubuntu2004:~/compose$ vi ora19env 
ORACLE_PWD=oracle
ORACLE_SID=orclcdb

docker-compose.yml 작성 

  • env_file : 오라클에서 container 사용하게될 환경 변수 입니다. 
  • image : 빌드를 하게될 오라클 19c 이미지입니다. 
  • ports : 오라클 컨테이너와 통신에 사용하게될 통신 포트 입니다. 설정은 host port: container port 로 작성 합니다. 
  • volumes : 컨테이너와 공유하게될 호스트 볼륨 정보입니다. 
version: '3.8'

 services:
     ora19c:
         container_name: ora19c
 
         env_file:
             - ora19env
 
         image: oracle/database:19.3.0-ee
 
         ports:
             - 1521:1521
             - 5500:5500
 
         volumes:
             - ./oradata/ora19_data:/opt/oracle/oradata
 
         privileged: true

Docker 명령어와 비교해 보겠습니다.

빌드시 항항 명령어를 기억해야 하지만 docker-compose 파일로 관리 하면 이미지별 컨테이너 관리도 쉽습니다. 

또 서비스에 여러개의 컨테이너를 등록 할수도 있습니다. 

  • 오라클 Docker 명령
docker run  \
--name oracle19c \
-p 1519:1521 \
-p 5519:5500 \
-e ORACLE_PWD=oracle \
-e ORACLE_SID=orclcdb \
-v ./data:/opt/oracle/oradata \
oracle/database:19.3.0-ee

 

docker-compose 빌드 

[oracle-docker@ubuntu2004:/home/oracle-docker/compose]$ docker-compose -f docker-compose.ora19c.yml up
Creating network "compose_default" with the default driver
Creating ora19c ... done
Attaching to ora19c
ora19c    | ORACLE EDITION: ENTERPRISE
ora19c    | 
ora19c    | LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 19-MAR-2022 08:09:28
ora19c    | 
ora19c    | Copyright (c) 1991, 2019, Oracle.  All rights reserved.
ora19c    | 
ora19c    | Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...
ora19c    | 
ora19c    | TNSLSNR for Linux: Version 19.0.0.0.0 - Production
ora19c    | System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
ora19c    | Log messages written to /opt/oracle/diag/tnslsnr/bc698e003576/listener/alert/log.xml
ora19c    | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
ora19c    | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
ora19c    | 
ora19c    | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
ora19c    | STATUS of the LISTENER
ora19c    | ------------------------
ora19c    | Alias                     LISTENER
ora19c    | Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
ora19c    | Start Date                19-MAR-2022 08:09:32
ora19c    | Uptime                    0 days 0 hr. 0 min. 3 sec
ora19c    | Trace Level               off
ora19c    | Security                  ON: Local OS Authentication
ora19c    | SNMP                      OFF
ora19c    | Listener Parameter File   /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
ora19c    | Listener Log File         /opt/oracle/diag/tnslsnr/bc698e003576/listener/alert/log.xml
ora19c    | Listening Endpoints Summary...
ora19c    |   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
ora19c    |   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
ora19c    | The listener supports no services
ora19c    | The command completed successfully
ora19c    | Prepare for db operation
ora19c    | 8% complete
ora19c    | Copying database files
ora19c    | 31% complete
ora19c    | Creating and starting Oracle instance
ora19c    | 32% complete
ora19c    | 36% complete
ora19c    | 40% complete
ora19c    | 43% complete
ora19c    | 46% complete
ora19c    | Completing Database Creation
ora19c    | 51% complete
ora19c    | 54% complete
ora19c    | Creating Pluggable Databases
ora19c    | 58% complete
ora19c    | 77% complete
ora19c    | Executing Post Configuration Actions
ora19c    | 100% complete
ora19c    | Database creation complete. For details check the logfiles at:
ora19c    |  /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
ora19c    | Database Information:
ora19c    | Global Database Name:ORCLCDB
ora19c    | System Identifier(SID):ORCLCDB
ora19c    | Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.
ora19c    | 
ora19c    | SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 19 08:41:27 2022
ora19c    | Version 19.3.0.0.0
ora19c    | 
ora19c    | Copyright (c) 1982, 2019, Oracle.  All rights reserved.
ora19c    | 
ora19c    | 
ora19c    | Connected to:
ora19c    | Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ora19c    | Version 19.3.0.0.0
ora19c    | 
ora19c    | SQL> 
ora19c    | System altered.
ora19c    | 
ora19c    | SQL> 
ora19c    | System altered.
ora19c    | 
ora19c    | SQL> 
ora19c    | Pluggable database altered.
ora19c    | 
ora19c    | SQL> 
ora19c    | PL/SQL procedure successfully completed.
ora19c    | 
ora19c    | SQL> SQL> 
ora19c    | Session altered.
ora19c    | 
ora19c    | SQL> 
ora19c    | User created.
ora19c    | 
ora19c    | SQL> 
ora19c    | Grant succeeded.
ora19c    | 
ora19c    | SQL> 
ora19c    | Grant succeeded.
ora19c    | 
ora19c    | SQL> 
ora19c    | Grant succeeded.
ora19c    | 
ora19c    | SQL> 
ora19c    | User altered.
ora19c    | 
ora19c    | SQL> SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ora19c    | Version 19.3.0.0.0
ora19c    | The Oracle base remains unchanged with value /opt/oracle
ora19c    | The Oracle base remains unchanged with value /opt/oracle
ora19c    | #########################
ora19c    | DATABASE IS READY TO USE!
ora19c    | #########################
ora19c    | The following output is now a tail of the alert.log:
ora19c    | ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ora19c    | ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
ora19c    | 2022-03-19T08:41:28.125385+00:00
ora19c    | ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
ora19c    | 2022-03-19T08:41:28.318093+00:00
ora19c    | ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
ora19c    |    ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
ora19c    | Completed:    ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
ora19c    | 
ora19c    | XDB initialized.
ora19c    | 2022-03-19T08:50:54.083033+00:00
ora19c    | ORCLPDB1(3):Resize operation completed for file# 10, old size 327680K, new size 337920K
ora19c    | 2022-03-19T09:00:56.067953+00:00
ora19c    | Resize operation completed for file# 3, old size 522240K, new size 532480K

Docker 프로세스 확인

  • docker-compose -f docker-compose.ora19c.yml ps -a
  • docker ps -a 

oracle-docker@ubuntu2004:~/compose$ docker-compose -f docker-compose.ora19c.yml ps -a
 Name               Command                  State                                             Ports                                       
-------------------------------------------------------------------------------------------------------------------------------------------
ora19c   /bin/sh -c exec $ORACLE_BA ...   Up (healthy)   0.0.0.0:1521->1521/tcp,:::1521->1521/tcp, 0.0.0.0:5500->5500/tcp,:::5500->5500/tcp
oracle-docker@ubuntu2004:~/compose$ docker-compose -f docker-compose.ora19c.yml ps 
 Name               Command                  State                                             Ports                                       
-------------------------------------------------------------------------------------------------------------------------------------------
ora19c   /bin/sh -c exec $ORACLE_BA ...   Up (healthy)   0.0.0.0:1521->1521/tcp,:::1521->1521/tcp, 0.0.0.0:5500->5500/tcp,:::5500->5500/tcp
oracle-docker@ubuntu2004:~/compose$ docker ps -a
CONTAINER ID   IMAGE                       COMMAND                  CREATED             STATUS                   PORTS                                                                                  NAMES
bc698e003576   oracle/database:19.3.0-ee   "/bin/sh -c 'exec $O   About an hour ago   Up 5 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   ora19c

 

Docker Container 실행 및 컨테이너 접속

 

실행결과

oracle-docker@ubuntu2004:~/compose$ docker-compose -f docker-compose.ora19c.yml up -d
Starting ora19c ... done
oracle-docker@ubuntu2004:~/compose$ docker-compose -f docker-compose.ora19c.yml exec ora19c /bin/bash
[oracle@01a4f713764f ~]$ sqlplus sys/oracle as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 19 23:13:42 2022
Version 19.3.0.0.0

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


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

SQL> select * from dual;

D
-
X

SQL> 

Docker-compose 기본 명령 

docker-compose -f [docker compose 파일] [명령어]
docker-compose -f docker-compose.ora19c.yml up
docker-compose -f docker-compose.ora19c.yml up -d // 백그라운드 모드 실행 

docker-compose -f docker-compose.ora19c.yml start // 정지한 컨테이너를 시작
docker-compose -f docker-compose.ora19c.yml start ora19c // 컨테이너가 여러개일경우 ora19c 

docker-compose -f docker-compose.ora19c.yml restart // 이미 실행 중인 컨테이너 다시 시작





docker-compose -f docker-compose.ora19c.yml stop // 컨테이너 중지

docker-compose -f docker-compose.ora19c.yml down // 컨테이너 중지및 삭제

docker-compose -f docker-compose.ora19c.yml  logs // 컨테이너로그 확인

docker-compose -f docker-compose.ora19c.yml ps // 컨테이너 목록 

//Docker 접속 
docker-compose exec [컨테이너] [명령어]
docker-compose -f docker-compose.ora19c.yml exec ora19c /bin/bash​
728x90
반응형

+ Recent posts