Docker

[Docker] oracle 19c 를 docker 이미지로 만들어서 구축하자 - Linux 용

IT-PAPA 2023. 7. 15. 17:32
728x90
반응형

1. oracle git clone

git clone https://github.com/oracle/docker-images.git
root@dev-oracle:~# git clone https://github.com/oracle/docker-images.git
Cloning into 'docker-images'...
remote: Enumerating objects: 17038, done.
remote: Counting objects: 100% (1730/1730), done.
remote: Compressing objects: 100% (370/370), done.
remote: Total 17038 (delta 1443), reused 1520 (delta 1337), pack-reused 15308
Receiving objects: 100% (17038/17038), 10.77 MiB | 21.83 MiB/s, done.
Resolving deltas: 100% (10029/10029), done.

 

2. oracle 19c 바이너리 다운로드 - LINUX.X64_193000_db_home.zip

Database Software Downloads | Oracle

 

Database Software Downloads | Oracle

Run the Oracle Database Enterprise Edition Container Image with Docker Contains Oracle Database Enterprise Edition 21c running on Oracle Linux 7. Ideal for macOS, Linux, and other platforms. Use the following pull command for the latest: docker pull contai

www.oracle.com

 

Platform 에 맞는 오라클 19c 다운로드

Platform 에 맞는 오라클 19c 다운로드
Platform 에 맞는 오라클 19c 다운로드

 

라이선스 동의 체크 후 다운로드

라이선스 동의 체크 후 다운로드
라이선스 동의 체크 후 다운로드

 

오라클 계정 로그인 후 로그인

오라클 계정 로그인
오라클 계정 로그인

 

3. zip을 Oracle Database/SingleInstance/dockerfiles/19.3.0 디렉토리에 놓습니다. 압축을 풀지 마십시오.

Docker Desktop에서 충분한 양의 메모리가 할당되어 있는지 확인합니다. 이 지침은 총 메모리를 4000MB로 설정하므로 Docker의 값이 이보다 높은지 확인합니다.

LINUX.X64_193000_db_home.zip 업로드 위치
LINUX.X64_193000_db_home.zip 업로드 위치

 

4. oracle 19c 빌드 작업

cd OracleDatabase/SingleInstance/dockerfiles
./buildContainerImage.sh -v 19.3.0 -e
root@dev-oracle:~/docker-images/OracleDatabase/SingleInstance/dockerfiles# ./buildContainerImage.sh -v 19.3.0 -e
Checking Docker version.
Dockerfile
Checking if required packages are present and valid...
LINUX.X64_193000_db_home.zip: OK
==========================
Container runtime info:
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: true
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.2.16-3-pve
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 10
 Total Memory: 15.62GiB
 Name: dev-oracle
 ID: TKGX:PKDO:AULW:RMSE:TCRY:3JP7:CXFR:3RUR:UIOX:BSGO:ATJE:2D6I
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

==========================
Building image 'oracle/database:19.3.0-ee' ...
Sending build context to Docker daemon   3.06GB
Step 1/25 : ARG BASE_IMAGE=oraclelinux:7-slim
Step 2/25 : FROM ${BASE_IMAGE} as base
7-slim: Pulling from library/oraclelinux
70e9ff4420fb: Pull complete 
Digest: sha256:5e138ed4b8bc1daea6e7d102731fb07057092ab49477c40fb68330939ad58949
Status: Downloaded newer image for oraclelinux:7-slim
 ---> 2ff218ecbf1b
Step 3/25 : LABEL "provider"="Oracle"                                                     "issues"="https://github.com/oracle/docker-images/issues"               "volume.data"="/opt/oracle/oradata"                                     "volume.setup.location1"="/opt/oracle/scripts/setup"                    "volume.setup.location2"="/docker-entrypoint-initdb.d/setup"            "volume.startup.location1"="/opt/oracle/scripts/startup"                "volume.startup.location2"="/docker-entrypoint-initdb.d/startup"        "port.listener"="1521"                                                  "port.oemexpress"="5500"
 ---> Running in d6be3d5634fa
Removing intermediate container d6be3d5634fa
 ---> acea8ddeb2d2
Step 4/25 : ARG SLIMMING=true
 ---> Running in 67e614cdee45
Removing intermediate container 67e614cdee45
 ---> 1fc6efdc53db
Step 5/25 : ARG INSTALL_FILE_1="LINUX.X64_193000_db_home.zip"
 ---> Running in 60752dbb3617
Removing intermediate container 60752dbb3617
 ---> 7531b3146448
Step 6/25 : ENV ORACLE_BASE=/opt/oracle     ORACLE_HOME=/opt/oracle/product/19c/dbhome_1     INSTALL_DIR=/opt/install     INSTALL_FILE_1=$INSTALL_FILE_1     INSTALL_RSP="db_inst.rsp"     CONFIG_RSP="dbca.rsp.tmpl"     PWD_FILE="setPassword.sh"     RUN_FILE="runOracle.sh"     START_FILE="startDB.sh"     CREATE_DB_FILE="createDB.sh"     CREATE_OBSERVER_FILE="createObserver.sh"     SETUP_LINUX_FILE="setupLinuxEnv.sh"     CHECK_SPACE_FILE="checkSpace.sh"     CHECK_DB_FILE="checkDBStatus.sh"     USER_SCRIPTS_FILE="runUserScripts.sh"     INSTALL_DB_BINARIES_FILE="installDBBinaries.sh"     RELINK_BINARY_FILE="relinkOracleBinary.sh"     CONFIG_TCPS_FILE="configTcps.sh"     SLIMMING=$SLIMMING     ENABLE_ARCHIVELOG=false     ARCHIVELOG_DIR_NAME=archive_logs     CLONE_DB=false     STANDBY_DB=false     PRIMARY_DB_CONN_STR=""     DG_OBSERVER_ONLY=false     DG_OBSERVER_NAME=""     CHECKPOINT_FILE_EXTN=".created"     WALLET_DIR=""
 ---> Running in e86f59dbac90
Removing intermediate container e86f59dbac90
 ---> ad0ca811b31d
Step 7/25 : ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH     LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib     CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
 ---> Running in da6de8c8b593
Removing intermediate container da6de8c8b593
 ---> 5ec2fee54e5e
Step 8/25 : COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
 ---> d4ea97adff43
Step 9/25 : COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CREATE_OBSERVER_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $RELINK_BINARY_FILE $CONFIG_TCPS_FILE $ORACLE_BASE/
 ---> b4330c758d34
Step 10/25 : RUN chmod ug+x $INSTALL_DIR/*.sh &&     sync &&     $INSTALL_DIR/$CHECK_SPACE_FILE &&     $INSTALL_DIR/$SETUP_LINUX_FILE &&     rm -rf $INSTALL_DIR
 ---> Running in 1f72ab0afc64
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package hostname.x86_64 0:3.13-3.el7_7.1 will be installed
---> Package openssl.x86_64 1:1.0.2k-26.el7_9 will be installed
--> Processing Dependency: make for package: 1:openssl-1.0.2k-26.el7_9.x86_64
.....

Launching Oracle Database Setup Wizard...

[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2023-07-15_08-14-37AM.log
   ACTION: Identify the list of failed prerequisite checks from the log: installActions2023-07-15_08-14-37AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
 /opt/oracle/product/19c/dbhome_1/install/response/db_2023-07-15_08-14-37AM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2023-07-15_08-14-37AM/installActions2023-07-15_08-14-37AM.log

As a root user, execute the following script(s):
        1. /opt/oracle/oraInventory/orainstRoot.sh
        2. /opt/oracle/product/19c/dbhome_1/root.sh

Execute /opt/oracle/oraInventory/orainstRoot.sh on the following nodes: 
[0cb88cfab2f9]
Execute /opt/oracle/product/19c/dbhome_1/root.sh on the following nodes: 
[0cb88cfab2f9]


Successfully Setup Software with warning(s).
Moved the install session logs to:
 /opt/oracle/oraInventory/logs/InstallActions2023-07-15_08-14-37AM
Removing intermediate container 0cb88cfab2f9
 ---> 2fdd22b2e60b
Step 16/25 : FROM base
 ---> ecfd44b58815
Step 17/25 : USER oracle
 ---> Running in c6b26e002b47
Removing intermediate container c6b26e002b47
 ---> 7acbf2cb4df6
Step 18/25 : COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
 ---> 753f66fa6bfa
Step 19/25 : USER root
 ---> Running in 9a469cd9d884
Removing intermediate container 9a469cd9d884
 ---> f34408be2836
Step 20/25 : RUN "$ORACLE_BASE"/oraInventory/orainstRoot.sh &&     "$ORACLE_HOME"/root.sh
 ---> Running in 8563d3850085
Changing permissions of /opt/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/oraInventory to dba.
The execution of the script is complete.
Check /opt/oracle/product/19c/dbhome_1/install/root_8563d3850085_2023-07-15_08-16-09-444982513.log for the output of root script
Removing intermediate container 8563d3850085
 ---> bd0cbbbadc83
Step 21/25 : USER oracle
 ---> Running in d4036c2234f3
Removing intermediate container d4036c2234f3
 ---> 6f5a77b0eea2
Step 22/25 : WORKDIR /home/oracle
 ---> Running in b4db4555f211
Removing intermediate container b4db4555f211
 ---> ff9a043e2fb6
Step 23/25 : RUN echo 'ORACLE_SID=${ORACLE_SID:-ORCLCDB}; export ORACLE_SID=${ORACLE_SID^^}' > .bashrc
 ---> Running in 6e03d3bf9e7f
Removing intermediate container 6e03d3bf9e7f
 ---> 1601c4239aee
Step 24/25 : HEALTHCHECK --interval=1m --start-period=5m --timeout=30s    CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
 ---> Running in 7ef5e02e5f7e
Removing intermediate container 7ef5e02e5f7e
 ---> 38f74197fe11
Step 25/25 : CMD [ "/bin/bash", "-c", "exec $ORACLE_BASE/$RUN_FILE" ]
 ---> Running in fd49d1becf27
Removing intermediate container fd49d1becf27
 ---> 82992e3a033b
Successfully built 82992e3a033b
Successfully tagged oracle/database:19.3.0-ee


  Oracle Database container image for 'ee' version 19.3.0 is ready to be extended: 
    
    --> oracle/database:19.3.0-ee

  Build completed in 211 seconds.

 

공간이 부족하다는 메시지가 표시되면 디스크에 사용 가능한 공간을 확인합니다. 문제가 없으면

yes | docker image prun > /dev/null 을 통해 이전 Docker 이미지를 제거합니다

 

5. docker run 실행하기

docker run \
--name oracle19c \
-p 1521:1521 \
-p 5500:5500 \
-e ORACLE_PDB=orcl \
-e ORACLE_PWD=password \
-e INIT_SGA_SIZE=3000 \
-e INIT_PGA_SIZE=1000 \
-v /opt/oracle/oradata \
-d \
oracle/database:19.3.0-ee

처음 실행할 때 데이터베이스가 작성되고 설정됩니다. 이 작업은 10-15분 정도 소요됩니다. 도커 대시보드를 열고 진행 상황을 확인합니다. 그러면 연결할 수 있습니다.

선택적으로, 데이터베이스에 점점 더 많은 데이터를 삽입할 때 "디스크 공간 없음" 문제가 발생하지 않도록 다음 run 명령을 사용할 수 있습니다.

docker run \
--name oracle19c \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PDB=orcl \
-e ORACLE_PWD=password \
-e INIT_SGA_SIZE=3000 \
-e INIT_PGA_SIZE=1000 \
-v /Users/<your-username>/path/to/store/db/files/:/opt/oracle/oradata \
-d \
oracle/database:19.3.0-ee

 

docker run 실행 후 로그

ORACLE EDITION: ENTERPRISE
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-JUL-2023 08:27:17
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/c198fccddb8a/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                15-JUL-2023 08:27:17
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/c198fccddb8a/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 standards.
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
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 recommended standards.
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
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 recommended standards.
   CAUSE: 
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
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
.....


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 Sat Jul 15 08:38:46 2023
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> 
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> 
Grant succeeded.
SQL> 
User altered.
SQL> SQL> Disconnected from Oracle Database 19c Enterprise Edition 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:
ORCL(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2023-07-15T08:38:46.867053+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
2023-07-15T08:38:46.871346+00:00
ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
   ALTER PLUGGABLE DATABASE ORCL SAVE STATE
Completed:    ALTER PLUGGABLE DATABASE ORCL SAVE STATE
2023-07-15T08:38:46.888991+00:00
XDB initialized.

 

옵션 값 설명

--name: 컨테이너의 이름(기본값: 자동 생성)
-p: 호스트 포트와 컨테이너 포트의 포트 매핑입니다.
노출되는 포트는 1521(Oracle Listener), 5500(OEM Express) 두 개입니다
-e Oracle_SID: 사용해야 하는 오라클 데이터베이스 SID(기본값: ORCLCDB)
-e ORACLE_PDB: 사용할 Oracle 데이터베이스 서비스 이름(기본값: ORCLPDB1)
-e ORACLE_PWD: Oracle Database SYS 암호(기본값: 자동 생성됨)
-e INIT_SGA_SIZE: Oracle에 할당할 SGA의 양입니다. 이 메모리는 Oracle에서 사용할 총 메모리의 75%를 차지해야 합니다.
-e INIT_PGA_SIZE: 오라클에 산화할 PGA의 양입니다. 이 값은 오라클에서 사용할 총 메모리의 나머지 25%여야 합니다.
-e ORACLE_CHARTSET: 데이터베이스를 작성할 때 사용할 문자 집합(기본값: AL32UTF8)
-v /opt/message/oradata
데이터베이스에 사용할 데이터 볼륨.
컨테이너 내에서 Unix "oracle"(uid: 54321) 사용자가 쓰기 가능해야 합니다!
생략할 경우 데이터베이스는 컨테이너 재생 중에 유지되지 않습니다.
-v /Users/<사용자 이름>/경로/저장/db/파일/:/opt/oracle/oradata
데이터 볼륨을 로컬 폴더 중 하나에 마운트합니다.
생략할 경우 데이터베이스가 계속 증가하고 도커의 볼륨 크기가 조정되지 않아 "디스크 공간 없음" 문제가 발생할 수 있습니다.
-d: 분리 모드에서 실행합니다. 그렇지 않으면 Ctrl-C가 컨테이너를 죽일 것입니다.

INIT_SGA_SIZE 및 INIT_PGA_SIZE를 지정하지 않으면 Oracle이 CPU 수, 시스템에서 사용 가능한 메모리 등을 기준으로 할당할 메모리를 결정합니다. 데스크톱 환경의 경우 이 메모리는 약 2000MB에서 5000MB 사이일 수 있습니다. 이를 제어하려면 값을 설정합니다.

 

Oracle 접속 정보

컨테이너가 시작되면 다른 데이터베이스와 마찬가지로 컨테이너에 연결할 수 있습니다. PDB는 서비스 이름을 사용하므로 SID가 아닌 서비스 이름을 사용합니다.

예를 들어 SQL Developer:

Hostname: localhost
Port: 1521
Service Name: <your service name>
Username: sys
Password: <your password>
Role: AS SYSDBA

 

Oracle 비밀번호 변경

참고: ORACLE_PWD 매개 변수를 설정하지 않은 경우 암호에 대한 도커 실행 출력을 확인합니다.

SYS 계정의 암호는 docker exec 명령을 통해 변경할 수 있습니다. 컨테이너가 실행 중이어야 합니다:

먼저 도커를 실행하여 컨테이너 ID를 가져옵니다. 그런 다음 docker exec <docer id> ./setPassword.sh <new password>를 실행합니다

 

Oracle 설치 원본 사이트

steveswinsburg/oracle19c-docker: A docker container for running Oracle 19c (github.com)

 

GitHub - steveswinsburg/oracle19c-docker: A docker container for running Oracle 19c

A docker container for running Oracle 19c. Contribute to steveswinsburg/oracle19c-docker development by creating an account on GitHub.

github.com

 

728x90
반응형
LIST