본문 바로가기

Devops/Docker

[Docker] Oracle DB 설치하기 (Oracle 12c)

Docker를 사용해 Oracle 12c 버전 설치하는 방법을 살펴보기로 한다.

설치는 Synology Nas 718+에서 진행하였다.

 

1. Docker Login

Oracle 이미지를 다운로드 받기 위해서는 Docker hub에 로그인이 되어있어야 한다. 본인이 사용하고 있는 Docker Hub 계정으로 로그인을 진행한다.

 

root@MyFriends-svc:~# docker --version
Docker version 20.10.3, build b455053
root@MyFriends-svc:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: kindlove
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

 

2. Oracle 이미지 다운로드

Docker pull 명령으로 이미지를 다운로드 받는다. (store/oracle/database-enterprise:12.2.0.1-slim)

 

root@MyFriends-svc:~# docker pull wvbirder/database-enterprise:12.2.0.1-slim
12.2.0.1-slim: Pulling from store/oracle/database-enterprise
4ce27fe12c04: Pull complete
9d3556e8e792: Pull complete
fc60a1a28025: Pull complete
0c32e4ed872e: Pull complete
be0a1f1e8dfd: Pull complete
Digest: sha256:dbd87ae4cc3425dea7ba3d3f34e062cbd0afa89aed2c3f3d47ceb5213cc0359a
Status: Downloaded newer image for wvbirder/database-enterprise:12.2.0.1-slim
docker.io/store/oracle/database-enterprise:12.2.0.1-slim
root@MyFriends-svc:~# docker images
REPOSITORY                         TAG             IMAGE ID       CREATED       SIZE
wvbirder/database-enterprise   12.2.0.1-slim   27c9559d36ec   4 years ago   2.08GB

 

3. Oracle Container를 띄운다.

root@MyFriends-svc:~# docker run -dit --name local_db -p 1521:1521 wvbirder/database-enterprise:12.2.0.1-slim
aaa579e9547adc9112901e4dd3775a8b1734616baff176940d2a9195ccf6aaf3
root@MyFriends-svc:~#
root@MyFriends-svc:~#
root@MyFriends-svc:~#
root@MyFriends-svc:~# docker ps -a (정상적으로 프로세스가 떳는지 확인)
CONTAINER ID   IMAGE                                            COMMAND                  CREATED         STATUS                            PORTS                              NAMES
aaa579e9547a   store/oracle/database-enterprise:12.2.0.1-slim   "/bin/sh -c '/bin/ba…"   8 seconds ago   Up 5 seconds (health: starting)   0.0.0.0:1521->1521/tcp, 5500/tcp   local_db

 

4. Docker 실행 로그를 확인하면서 완료될때 까지 기다린다.

root@MyFriends-svc:~# docker logs -f local_db
Setup Oracle Database
Oracle Database 12.2.0.1 Setup
Wed Dec 29 14:11:26 UTC 2021

Check parameters ......
log file is : /home/oracle/setup/log/paramChk.log
paramChk.sh is done at 0 sec

untar DB bits ......
log file is : /home/oracle/setup/log/untarDB.log
untarDB.sh is done at 30 sec

config DB ......
log file is : /home/oracle/setup/log/configDB.log
Wed Dec 29 14:11:57 UTC 2021
Start Docker DB configuration
Call configDBora.sh to configure database
Wed Dec 29 14:11:57 UTC 2021
Configure DB as oracle user
Setup Database directories ...

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 29 14:11:58 2021
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Connected to an idle instance.

SQL>
File created.

SQL> ORACLE instance started.

Total System Global Area 1342177280 bytes
Fixed Size                  8792536 bytes
Variable Size             352323112 bytes
Database Buffers          973078528 bytes
Redo Buffers                7983104 bytes
Database mounted.
Database opened.
SQL>
Database altered.

SQL>
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
update password

Enter password for SYS:
create pdb : ORCLPDB1

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 29 14:13:30 2021

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

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>   2    3    4    5
Pluggable database created.

SQL>
Pluggable database altered.
SQL>
Pluggable database altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Reset Database parameters

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 29 14:14:29 2021
Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
System altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 29-DEC-2021 14:14:29
Copyright (c) 1991, 2016, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/aaa579e9547a/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Start Date                29-DEC-2021 14:14:39
Uptime                    0 days 0 hr. 0 min. 9 sec
Trace Level               off
Security                  ON: Local OS Authentication
# ===========================================================================
# == Add below entries to your tnsnames.ora to access this database server ==
# ====================== from external host =================================
ORCLCDB=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
    (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLCDB.localdomain)))
ORCLPDB1=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
    (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLPDB1.localdomain)))
#
    alter pluggable database all save state
2021-12-29T14:14:29.351180+00:00
Completed:     alter pluggable database all save state
2021-12-29T14:14:29.650099+00:00
ALTER SYSTEM SET encrypt_new_tablespaces='DDL' SCOPE=BOTH; => 여기까지 나오면 완료된 것임.

 

5. User 생성

Application에서 사용할 사용자를 생성한다.

 

root@MyFriends-svc:~# docker exec -it local_db bash -c "source /home/oracle/.bashrc; sqlplus sys/Oradoc_db1@ORCLCDB as sysdba"

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 29 14:22:05 2021
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>  alter session set "_ORACLE_SCRIPT"=true;
Session altered.

SQL> create user test identified by test;
User created.


SQL> grant connect, resource, dba to test;
Grant succeeded.

SQL> commit;

 

6. 한국 시간대와 한글 설정을 위해 문자 코드셋을 설정한다.

SQL> update sys.props$ set value$='KOREAN_KOREA.UTF8' where name='NLS_LANGUAGE';
1 row updated.

SQL> update sys.props$ set value$='UTF8' where name='NLS_CHARACTERSET';
1 row updated.

SQL> update sys.props$ set value$='UTF8' where name='NLS_NCHAR_CHARACTERSET';
1 row updated.

SQL> update sys.props$ set value$='KO16MSWIN949' where name='NLS_CHARACTERSET';
update sys.props$ set value$='KO16MSWIN949' where name='NLS_NCHAR_CHARACTERSET';
update sys.props$ set value$='AMERICAN_AMERICA.KO16MSWIN949' where name='NLS_LANGUAGE';

1 row updated.

SQL>
1 row updated.

SQL>
1 row updated.

SQL> commit;

Commit complete.

SQL> shutdown immediate; (위 코드셋 설정 후 데이터 베이스를 재기동 한다.)
Database closed.
Database dismounted.
ORACLE instance shut down.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

Warning: You are no longer connected to ORACLE.
SQL> startup;
SP2-0640: Not connected
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup;
ORACLE instance started.

Total System Global Area 1342177280 bytes
Fixed Size                  8792536 bytes
Variable Size             385877544 bytes
Database Buffers          939524096 bytes
Redo Buffers                7983104 bytes
Database mounted.
Database opened.

 

7. Oracle developer 툴 등을 활용해 DB 접속을 확인한다.

기본적으로 설치되는 Oracle 정보는 다음과 같다.

USER = sys / Oradoc_db1
DB_SID=ORCLCDB
DB_PDB=ORCLPDB1
DB_MEMORY=2GB
DB_DOMAIN=localdomain

 

위 정보를 기반으로 본인의 네트워크 상황에 맞게 접속 정보를 설정한다.

-- The End --