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

2021. 10. 26. 17:24Tool/docker

728x90
728x90

도커 서버 설치 참고.

docker hub에서 다운로드할 oracle11g 이미지 확인

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

$docker login

oracle11g 이미지 다운로드

$docker pull jaspeen/oracle-xe-11g
Using default tag: latest
Trying to pull repository docker.io/jaspeen/oracle-xe-11g ... 
latest: Pulling from docker.io/jaspeen/oracle-xe-11g
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 docker.io/jaspeen/oracle-xe-11g:latest

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

$docker images | grep oracle
docker.io/jaspeen/oracle-xe-11g   latest              52fbd1fe2d7a        5 years ago         792 MB

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

$docker volume create oracle11g

오라클11g 컨테이너 생성, 실행.

  • 포트바인딩 설정 "-p ..."
  • 볼륨 설정 "-v ..."
  • 환경변수 설정 "-e ..."
$docker run -idt --name oracle11g -p 1521:1521 -p 8080:8080 -v oracle11g:/u01/app/oracle/:z -e ORACLE_ALLOW_REMOTE=true --restart=always jaspeen/oracle-xe-11g

oracle 11g 컨테이너 기동 확인.

$docker ps | grep oracle11g
db8847f416cc        jaspeen/oracle-xe-11g   "/entrypoint.sh "   15 seconds ago      Up 14 seconds       0.0.0.0:1521->1521/tcp, 8080/tcp   oracle11g

$docker logs 명령을 통해서 컨테이너의 오라클 서버가 기동되었는지 확인.

$docker logs -f oracle11g
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
mv: cannot remove '/u01/app/oracle-product/11.2.0/xe/dbs': Directory not empty

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
Configuring database...Done
rm: cannot remove '/u01/app/oracle/product/11.2.0/xe/config/seeddb': Directory not empty
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
Database initialized. Please visit http://#containeer:8080/apex to proceed with configuration
Oracle Database 11g Express Edition instance is already started

Database ready to use. Enjoy! ;)

컨테이너 접속.

$docker exec -it oracle11g bash
root@275efaba556c:/#

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

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

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

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

ORA11G =
  (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
        (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SID = XE)
        )
  )

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

$sqlplus system/oracle@ORA11G
SQL*Plus: Release 19.0.0.0.0 - Production on 화 10월 26 16:58:58 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
다음에 접속됨:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>

볼륨 처리 확인.

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

$pwd
/u01/app/oracle

$ls -al  
total 12
drwxr-x---. 8 oracle dba  4096 Oct 26 07:50 .
drwxr-xr-x. 1 root   root   27 Nov 26  2015 ..
-rw-------. 1 oracle dba    65 Oct 26 05:54 .bash_history
drwxr-x---. 4 oracle dba    33 Oct 26 07:50 admin
drwxr-xr-x. 2 oracle dba    21 Nov 26  2015 dbs
drwxrwxr-x. 4 oracle dba    32 Oct 26 07:50 diag
drwxr-x---. 3 oracle dba    15 Oct 26 07:50 fast_recovery_area
drwxr-x---. 3 oracle dba    15 Oct 26 07:50 oradata
drwxr-xr-x. 3 oracle dba    17 Oct 26 07:50 oradiag_oracle
lrwxrwxrwx. 1 root   root   23 Oct 26 07:50 product -> /u01/app/oracle-product

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

$pwd
/var/lib/docker/volumes/oracle11g/_data

$ls -al
합계 12
drwxr-x---.  8 infini infini 4096 10월 26 16:50 .
dr-xr-x---. 41 root   root   4096 10월 26 17:06 ..
-rw-------.  1 infini infini   65 10월 26 14:54 .bash_history
drwxr-x---.  4 infini infini   33 10월 26 16:50 admin
drwxr-xr-x.  2 infini infini   21 11월 26  2015 dbs
drwxrwxr-x.  4 infini infini   32 10월 26 16:50 diag
drwxr-x---.  3 infini infini   15 10월 26 16:50 fast_recovery_area
drwxr-x---.  3 infini infini   15 10월 26 16:50 oradata
drwxr-xr-x.  3 infini infini   17 10월 26 16:50 oradiag_oracle
lrwxrwxrwx.  1 root   root     23 10월 26 16:50 product -> /u01/app/oracle-product
728x90
728x90