오라클 데이터 베이스 도커 이미지는 Oracle Database Server 12.2.0.1 Enterprise Edition 버전 입니다.
이 이미지에는 pdb가 하나 인 다중 테넌트 구성의 기본 데이터베이스가 포함되어 있습니다.
Oracle Database Server 12c R2에 대한 자세한 내용은 http://docs.oracle.com/en/database/ 를 참조 하십시오.
1. Docker Store에 로그인
$ 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: 도커 로그인
Password: 도커 로그인 비밀번호
WARNING! Your password will be stored unencrypted in /home/irexnet/.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 데이터베이스 서버 인스턴스 시작
2.1 이미지 다운로드
$ docker pull store/oracle/database-enterprise:12.2.0.1
12.2.0.1: Pulling from store/oracle/database-enterprise
4ce27fe12c04: Pull complete
9d3556e8e792: Pull complete
fc60a1a28025: Pull complete
0c32e4ed872e: Pull complete
b465d9b6e399: Pull complete
Digest: sha256:40760ac70dba2c4c70d0c542e42e082e8b04d9040d91688d63f728af764a2f5d
Status: Downloaded newer image for store/oracle/database-enterprise:12.2.0.1
docker.io/store/oracle/database-enterprise:12.2.0.1
[참고] Oracle Database Server 12.2.0.1 Enterprise Edition Slim 버전 다운로드
$ docker pull store/oracle/database-enterprise:12.2.0.1-slim
12.2.0.1-slim 이미지는 디스크 공간 (4GB) 요구 사항을 줄이고 컨테이너 시작을 빠르게합니다.
이 이미지는 Analytics, Oracle R, Oracle Label Security, Oracle Text, Oracle Application Express 및
Oracle DataVault 기능을 지원하지 않습니다.
2.2 이미지 다운로드 확인
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
store/oracle/database-enterprise 12.2.0.1 12a359cd0528 2 years ago 3.44GB
2.3 호스트 시스템의 오라클 데이터 디렉터리 생성 및 디렉터리 권한
# 디렉터리 생성
$ mkdir ~/docker/oracle/data
# 디렉터리 권한 부여
$ chmod 777 ~/docker/oracle/data
2.4 이미지 컨테이너 생성 및 실행
$ docker run -d --name oracledb -p 1521:1521 -v ~/docker/oracle/data:/ORCL store/oracle/database-enterprise:12.2.0.1
cc5f322095066d3fb0ba0f4b6f27f41764bf7a8c5d520f8b7c0ca2f9d07e8a5a
[참고] docker run -d -it --name -v OracleDBData:/ORCL store/oracle/database-enterprise:12.2.0.1
: 컨테이너 이름
12.2.0.1 : 도커 이미지 태그
OracleDBData : 호스트 시스템의 오라클 데이터디렉터리
이 Oracle 데이터베이스 서버 이미지는 Docker 데이터 볼륨을 사용하여 데이터 파일, 리두 로그, 감사 로그,
경고 로그 및 추적 파일을 저장합니다.
데이터 볼륨은의 컨테이너 내부에 마운트됩니다 /ORCL. docker run 명령을 사용하여 데이터 볼륨으로 데이터베이스를 시작하려면
OracleDBDataDocker가 작성하고의 컨테이너 내부에 마운트된 데이터 볼륨입니다 /ORCL.
OracleDBData 데이터 볼륨 을 재사용하여 지속 된 데이터 파일을 다른 컨테이너와 함께 재사용 할 수 있습니다 .
2.4 이미지 컨테이너 로그 확인
$ docker logs -f oracledb
Setup Oracle Database
Oracle Database 12.2.0.1 Setup
Tue Mar 10 07:48:20 UTC 2020
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 32 sec
config DB ......
log file is : /home/oracle/setup/log/configDB.log
Tue Mar 10 07:48:52 UTC 2020
Start Docker DB configuration
Call configDBora.sh to configure database
Tue Mar 10 07:48:53 UTC 2020
Configure DB as oracle user
Setup Database directories ...
SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 10 07:48:53 2020
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 939525672 bytes
Database Buffers 369098752 bytes
Redo Buffers 24760320 bytes
Database mounted.
Database opened.
SQL>
Database altered.
SQL>
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/12.2.0
/dbhome_1/dbs/spfileORCLCDB.ora
SQL>
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
encrypt_new_tablespaces string CLOUD_ONLY
SQL>
User altered.
SQL>
User altered.
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
update password
Enter password for SYS:
create pdb : ORCLPDB1
SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 10 07:49:16 2020
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 Tue Mar 10 07:49:36 2020
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 10-MAR-2020 07:49:36
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/cc5f32209506/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 10-MAR-2020 07:49:37
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/cc5f32209506/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
DONE!
Remove password info
Docker DB configuration is complete !
configDB.sh is done at 77 sec
Done ! The database is ready for use .
# ===========================================================================
# == Add below entries to your tnsnames.ora to access this database server ==
# ====================== from external host =================================
ORCLCDB=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLCDB.localdomain)))
ORCLPDB1=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLPDB1.localdomain)))
#
#ip-address : IP address of the host where the container is running.
#port : Host Port that is mapped to the port 1521 of the container.
#
# The mapped port can be obtained from running "docker port "
# ===========================================================================
Thread 1 advanced to log sequence 5 (LGWR switch)
Current log# 2 seq# 5 mem# 0: /u04/app/oracle/redo/redo002.log
2020-03-10T07:49:35.812066+00:00
ORCLPDB1(3):Opening pdb with no Resource Manager plan active
Pluggable database ORCLPDB1 opened read write
Completed: alter pluggable database ORCLPDB1 open
alter pluggable database all save state
Completed: alter pluggable database all save state
2020-03-10T07:49:36.474809+00:00
ALTER SYSTEM SET encrypt_new_tablespaces='DDL' SCOPE=BOTH;
2020-03-10T07:50:06.563066+00:00
TABLE SYS.WRP$_REPORTS: ADDED INTERVAL PARTITION SYS_P287 (3722) VALUES LESS THAN (TO_DATE(' 2020-03-11 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLE SYS.WRP$_REPORTS_DETAILS: ADDED INTERVAL PARTITION SYS_P288 (3722) VALUES LESS THAN (TO_DATE(' 2020-03-11 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLE SYS.WRP$_REPORTS_TIME_BANDS: ADDED INTERVAL PARTITION SYS_P291 (3721) VALUES LESS THAN (TO_DATE(' 2020-03-10 01:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
^C
2.5 컨테이너 프로세스 확인
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc5f32209506 store/oracle/database-enterprise:12.2.0.1 "/bin/sh -c '/bin/ba…" 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:1521->1521/tcp, 5500/tcp oracledb
3. 오라클 환경설정 (시간/캐릭터셋)
3.1 오라클 sys 계정 비밀번호 변경
3.1.1. SQL * Plus 접속
$ docker exec -it oracledb bash -c "source /home/oracle/.bashrc; sqlplus /nolog"
SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 10 07:53:57 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
3.1.2 sysdba 접속
SQL> conn /as sysdba
Connected.
3.1.3 sys 계정 비밀번호 변경
SQL> alter user sys identified by oracle;
User altered.
[참고] alter user sys identified by ;
: sys 계정 비빌번호
3.1.4 sqlplus 접속 종료
SQL> quit
3.2 시간 지역 설정
3.2.1 .bashrc 설정
$ docker exec -it oracledb bash -c "echo \"export TZ='Asia/Seoul'\" >> /home/oracle/.bashrc"
3.2.2 .bashrc 설정 적용 확인
$ docker exec -it oracledb bash -c "cat /home/oracle/.bashrc"
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export OH=/u01/app/oracle/product/12.2.0/dbhome_1
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/u01/app/oracle/product/12.2.0/dbhome_1/bin
export TNS_ADMIN=/u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB
export ORACLE_SID=ORCLCDB;
export TZ='Asia/Seoul'
3.2 계정 생성 & 캐릭터셋 설정
3.2.1 계정 생성
# sqlplus 접속
$ docker exec -it oracledb bash -c "source /home/oracle/.bashrc; sqlplus sys/oracle@ORCLCDB as sysdba"
SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 10 17:01:58 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
# Oracle 12C 에서 사용자 생성 시 이전 번전과 같은 방법으로 만들기 위해 사용 (12c 부터 c## 계정 이름 으로 지정하도록 바뀜)
SQL> alter session set "_ORACLE_SCRIPT"=true;
Session altered.
# 계정 생성
SQL> create user irexnet identified by oracle;
User created.
# 계정 권한 부여
SQL> grant connect, resource, dba to irexnet;
Grant succeeded.
3.2.2 캐릭터셋 설정
# NLS_LANGUAGE
SQL> update sys.props$ set value$='KOREAN_KOREA.UTF8' where name='NLS_LANGUAGE';
1 row updated.
# NLS_CHARACTERSET
SQL> update sys.props$ set value$='UTF8' where name='NLS_CHARACTERSET';
1 row updated.
# NLS_NCHAR_CHARACTERSET
SQL> update sys.props$ set value$='UTF8' where name='NLS_NCHAR_CHARACTERSET';
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> 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 989857320 bytes
Database Buffers 318767104 bytes
Redo Buffers 24760320 bytes
Database mounted.
Database opened.
SQL> alter system enable restricted session;
System altered.
SQL> alter system set job_queue_processes=0;
System altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01531: a database already open by the instance
SQL> select name, value$ from sys.props$ where name=upper('nls_language') or name=upper('nls_territory');
NAME
--------------------------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_TERRITORY
AMERICA
NLS_LANGUAGE
KOREAN_KOREA.UTF8
SQL> col value new_value charset
SQL> select value from nls_database_parameters where parameter=upper('nls_characterset');
VALUE
--------------------------------------------------------------------------------
UTF8
SQL> alter database character set internal_use &charset;
old 1: alter database character set internal_use &charset
new 1: alter database character set internal_use UTF8
Database altered.
SQL> alter database character set internal_use &ncharset;
Enter value for ncharset: UTF8
old 1: alter database character set internal_use &ncharset
new 1: alter database character set internal_use UTF8
Database altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 1342177280 bytes
Fixed Size 8792536 bytes
Variable Size 973080104 bytes
Database Buffers 335544320 bytes
Redo Buffers 24760320 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
문제 해결
문제1] 캐릿터셋 설정 후 ("알 수 없는 문자 집합 이름입니다") 오류 처리 방법
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-553: 알 수 없는 문자 집합 이름입니다
$ docker exec -it oracledb bash -c "source /home/oracle/.bashrc; sqlplus sys/oracle@ORCLCDB as sysdba"
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter system enable restricted session;
SQL> alter system set job_queue_processes=0;
SQL> alter system set aq_tm_processes=0;
SQL> alter database open;
SQL> select name, value$ from sys.props$ where name=upper('nls_language') or name=upper('nls_territory');
SQL> col value new_value charset
SQL> select value from nls_database_parameters where parameter=upper('nls_characterset');
SQL> col value new_value ncharset
SQL> select value from nls_database_parameters where parameter=upper('nls_nchar_characterset');
SQL> alter database character set internal_use &charset;
SQL> alter database character set internal_use &ncharset;
SQL> shutdown immediate;
SQL> startup;
'개발도구 > Docker' 카테고리의 다른 글
Docker Installation of Oracle Database 12c (0) | 2020.04.07 |
---|---|
Miniconda 개발 환경 구축 (0) | 2020.03.26 |
도커 전체 컨테이너 이미지 삭제 (0) | 2020.03.26 |
도커 컨테이너 로그 관리 (0) | 2020.03.11 |