헤르메스 LIFE

[Docker] Docker 에 Oracle XE 11g설치하기 본문

Database

[Docker] Docker 에 Oracle XE 11g설치하기

헤르메스의날개 2023. 5. 30. 23:23
728x90

 Docker에 Oracle XE 를 설치할 예정입니다.

? oracle-xe 를 찾습니다.
C:\>docker search oracle-xe
NAME                              DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
gvenzl/oracle-xe                  Oracle Database XE (21c, 18c, 11g) for every…   211
oracleinanutshell/oracle-xe-11g                                                    273
wnameless/oracle-xe-11g-r2        Oracle Express Edition 11g Release 2 on Ubun…   96
christophesurmont/oracle-xe-11g   Clone of the wnameless/oracle-xe-11g.            7
pvargacl/oracle-xe-18.4.0         Oracle Express Edition 18.4.0 on Oracle Linu…   10
owncloudci/oracle-xe                                                               0
thebookpeople/oracle-xe-11g                                                        5
webdizz/oracle-xe-11g-sa          This is a simple image based on sath89/oracl…   1                    [OK]
acktsw/oracle-xe-11g              fork from https://hub.docker.com/r/sath89/or…   3                    [OK]
jaspeen/oracle-xe-11g             Fork from sath89/docker-oracle-xe-11g - smal…   6                    [OK]
gerohoff/oracle-xe                test with oracle-xe anonymous user               0
orangehrm/oracle-xe-11g            docker container with Oracle Express Editio…   17                   [OK]
loads/oracle-xe-11g-r2                                                             0
imnotjames/oracle-xe                                                               0
andyrbell/oracle-xe-11g-centos    Oracle Express Edition 11g Release 2 on Cent…   0
justinwyer/oracle-xe                                                               0
larmic/oracle-xe                  A oracle xe image with user integrationtest …   0
larmic/oracle-xe-11g              Using wnameless/oracle-xe-11g with created u…   0
abstractdog/oracle-xe                                                              0
jycr/oracle-xe2                                                                    0
galam/oracle-xe-12c                                                                1
philipharries/oracle-xe           Oracle XE Container with transparent build m…   4
vitorfec/oracle-xe-18c            Oracle Database Express Edition (XE) Release…   1
limingyi/oracle-xe-18c-prebuilt                                                    1
jark/oracle-xe-11g-r2-cdc                                                          0

jaspeen/oracle-xe-11g 가 [OK] 로 확인됩니다.

많이 사용하는 Image 라고 합니다. 이 Image로 결정!!!

? oracle-xe-11g 를 다운로드
C:\>docker pull jaspeen/oracle-xe-11g
Using default tag: latest
latest: Pulling from jaspeen/oracle-xe-11g
Image docker.io/jaspeen/oracle-xe-11g:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
863735b9fd15: Pull complete
4fbaa2f403df: Pull complete
44be94a95984: Pull complete
a3ed95caeb02: Pull complete
05b9ddeb40d9: Pull complete
b44894d2d2af: Pull complete
1492d1fc5b9f: Pull complete
c0f3c6ec8986: Pull complete
fbfc89a21b1b: Pull complete
740047056d21: Pull complete
Digest: sha256:0a4b0456cd5be4982ab28ca9426672acee6d90734873d15124698c5c07055aa9
Status: Downloaded newer image for jaspeen/oracle-xe-11g:latest
docker.io/jaspeen/oracle-xe-11g:latest

? 다운로드된 이미지 확인
C:\>docker images
REPOSITORY              TAG       IMAGE ID       CREATED         SIZE
postgres-ko             14.1      5c2063862126   6 weeks ago     375MB
ubuntu                  latest    08d22c0ceb15   2 months ago    77.8MB
redis                   latest    3358aea34e8c   6 months ago    117MB
mysql                   latest    d1dc36cf8d9e   16 months ago   519MB
postgres                <none>    e94a3bb61224   18 months ago   374MB
jaspeen/oracle-xe-11g   latest    52fbd1fe2d7a   7 years ago     792MB

? Docker oracle11g 컨테이너 생성
? -d : 백그라운드 실행
? -p 포트 포딩 1521번 포트로 들어온 내용은 1521번 포트로 포딩을 해주겟다는 내용
? --name Container 이름을 설정해줍니다. 
? docker exec -> run a command on an existing/running container
? docker run -> create a new container from an image, and run the command there
C:\>docker run --name  oracle11g_boot -d -p 8080:8080 -p 1521:1521 jaspeen/oracle-xe-11g
3cb22993ee2d53f0b2da5f54ba737d41b19bdb7b2575ee2c3f98dd80f3437ac1

? docker에 설치된 컨테이너 목록 조회
C:\>docker ps -a
CONTAINER ID   IMAGE                   COMMAND                   CREATED          STATUS                   PORTS                                            NAMES
3cb22993ee2d   jaspeen/oracle-xe-11g   "/entrypoint.sh "         18 seconds ago   Up 18 seconds            0.0.0.0:1521->1521/tcp, 0.0.0.0:8080->8080/tcp   oracle11g_boot
36e399118658   postgres-ko:14.1        "docker-entrypoint.s…"   6 weeks ago      Up 34 minutes            0.0.0.0:5432->5432/tcp                           postgres_boot
52f3c5aa5df1   postgres                "docker-entrypoint.s…"   6 weeks ago      Exited (1) 6 weeks ago
                                   musing_neumann
856611a265bf   redis                   "docker-entrypoint.s…"   6 months ago     Exited (0) 6 weeks ago
                                   redis_boot
1644e02bc589   mysql                   "docker-entrypoint.s…"   15 months ago    Exited (0) 7 days ago
                                   mysql_boot

? 확인
? docker logs -f (컨테이너명)
C:\>docker logs -f oracle11g_boot
ls: cannot access /u01/app/oracle/oradata: No such file or directory
Database not initialized. Initializing database.
Setting up:
processes=500
sessions=555
transactions=610
If you want to use different parameters set processes, sessions, transactions env variables and consider this formula:
processes=x
sessions=x*1.1+5
transactions=sessions*1.1

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:
Specify a port that will be used for the database listener [1521]:
Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:
Starting Oracle Net Listener...Done

Docker 접속

 Oracle  XE의 sysdba 계정의 Default ID / PW 는 system / oracle 입니다.

계정생성 후 connection, resource, dba 권한을 부여합니다.

? Docker 접속
C:\>docker exec -it oracle11g_boot bash
root@3cb22993ee2d:/# grep -n . /etc/*-release
/etc/lsb-release:1:DISTRIB_ID=Ubuntu
/etc/lsb-release:2:DISTRIB_RELEASE=14.04
/etc/lsb-release:3:DISTRIB_CODENAME=trusty
/etc/lsb-release:4:DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
/etc/os-release:1:NAME="Ubuntu"
/etc/os-release:2:VERSION="14.04.3 LTS, Trusty Tahr"
/etc/os-release:3:ID=ubuntu
/etc/os-release:4:ID_LIKE=debian
/etc/os-release:5:PRETTY_NAME="Ubuntu 14.04.3 LTS"
/etc/os-release:6:VERSION_ID="14.04"
/etc/os-release:7:HOME_URL="http://www.ubuntu.com/"
/etc/os-release:8:SUPPORT_URL="http://help.ubuntu.com/"
/etc/os-release:9:BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

? sqlplus 접속
root@3cb22993ee2d:/# sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 30 14:44:03 2023

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

ERROR:
ORA-01031: insufficient privileges


Enter user-name: system
Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

? 계정생성
SQL> create user hermeswing identified by pass;

User created.

? 권한부여
SQL> grant connect,resource,dba to hermeswing;

Grant succeeded.

SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

? 생성된 계정으로 접속
root@3cb22993ee2d:/# sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 30 14:59:04 2023

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

Enter user-name: hermeswing
Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL>

DBeaver 접속

Database : XE

Username : hermeswing

password : pass


Oracle 샘플계정 오픈

생성한 "system" 계정 또는 "hermeswing" 계정으로 접속 후 아래와 같이 실행 하면 됩니다.

ALTER USER hr ACCOUNT UNLOCK;

-- ALTER USER hr IDENTIFIED BY <hr-password>;
ALTER USER hr IDENTIFIED BY pass;

그리고, 다시  hr 계정으로 접속합니다.

테이블 목록을 조회해 봤습니다.


https://docs.oracle.com/cd/E17781_01/admin.112/e18585/toc.htm#XEGSG119

 

Database Express Edition Getting Started Guide - Contents

Select Create User, and specify the necessary information. (Under System Privileges, grant ALTER SESSION, CREATE SESSION, CREATE DATABASE LINK, CREATE MATERIALIZED VIEW, CREATE PROCEDURE, CREATE PUBLIC SYNONYM, CREATE ROLE, CREATE SEQUENCE, CREATE SYNONYM,

docs.oracle.com

 

728x90