OS/Raspberry Pi

Raspberry Pi : Docker - ARM 버전 Oracle 데이터베이스 설치

파란크리스마스 2024. 3. 23. 22:52
728x90

출처

리눅스 버전 확인

pi@raspberrypi:~$ uname -a
Linux raspberrypi 6.6.20+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux

도커 설치

pi@raspberrypi:~$ curl -sSL https://get.docker.com | sh

도커 버전 확인

pi@raspberrypi:~$ sudo docker version
Client: Docker Engine - Community
 Version:           26.0.0
 API version:       1.45

도커 허브에서 Oracle 데이터베이스용 이미지 다운로드

pi@raspberrypi:~$ sudo docker pull bluexmas/aarch64_oracle_db_19
Using default tag: latest
latest: Pulling from bluexmas/aarch64_oracle_db_19
ea4e27ae0b4c: Pull complete 
60e14e4a36dc: Pull complete 
2459d70df083: Pull complete 
43588f5a3c30: Pull complete 
fd59129c6b98: Pull complete 
f4347f997964: Pull complete 
b1a1518d1ad3: Pull complete 
051a9330efaf: Pull complete 
7145497f1832: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:276c6358c179efab39be868b6a8368df57c29210f0370c2e2cec9017f7b54dc2
Status: Downloaded newer image for bluexmas/aarch64_oracle_db_19:latest
docker.io/bluexmas/aarch64_oracle_db_19:latest

이미지 조회

pi@raspberrypi:~$ sudo docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
bluexmas/aarch64_oracle_db_19   latest    73ebf0277483   2 hours ago   5.89GB

환경변수 추가

pi@raspberrypi:~$ vi ~/.profile
CONTAINER_NAME=ORCL
ORADATA=~/oracle-docker/oradata

환경변수 적용

pi@raspberrypi:~$ source ~/.profile

데이터 디렉터리 및 Docker 볼륨 만들기

 for dir in audit data diag reco
  do mkdir -p $ORADATA/${CONTAINER_NAME}/${dir}
     rm -fr $ORADATA/${CONTAINER_NAME}/${dir}/*
     sudo docker volume rm ${CONTAINER_NAME}_${dir} 2>/dev/null
     sudo docker volume create --opt type=none --opt o=bind \
            --opt device=$ORADATA/${CONTAINER_NAME}/${dir} \
            ${CONTAINER_NAME}_${dir}
done
pi@raspberrypi:~$  for dir in audit data diag reco
>   do mkdir -p $ORADATA/${CONTAINER_NAME}/${dir}
>      rm -fr $ORADATA/${CONTAINER_NAME}/${dir}/*
>      sudo docker volume rm ${CONTAINER_NAME}_${dir} 2>/dev/null
>      sudo docker volume create --opt type=none --opt o=bind \
>             --opt device=$ORADATA/${CONTAINER_NAME}/${dir} \
>             ${CONTAINER_NAME}_${dir}
> done
ORCL_audit
ORCL_data
ORCL_diag
ORCL_reco

도커 이미지에서 디렉토리 권한이 없으므로 디렉토리 권한 해제

pi@raspberrypi:~$ cd oracle-docker/oradata/
pi@raspberrypi:~/oracle-docker/oradata$ sudo chmod 777 -Rf ORCL
pi@raspberrypi:~/oracle-docker/oradata$ cd ORCL
pi@raspberrypi:~/oracle-docker/oradata/ORCL$ ls -al
합계 24
drwxrwxrwx 6 pi pi 4096  3월 23일  21:58 .
drwxr-xr-x 3 pi pi 4096  3월 23일  21:58 ..
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 audit
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 data
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 diag
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 reco

Oracle Docker 이미지 실행

sudo docker run -d \
    --name ${CONTAINER_NAME} \
    --volume ${CONTAINER_NAME}_data:/u02/app/oracle/oradata \
    --volume ${CONTAINER_NAME}_diag:/u01/app/oracle/diag \
    --volume ${CONTAINER_NAME}_audit:/u01/app/oracle/admin \
    --volume ${CONTAINER_NAME}_reco:/u03/app/oracle \
    --volume $ORADATA/scripts:/scripts \
    -e ORACLE_SID=${CONTAINER_NAME} \
    -e ORACLE_PDB=${CONTAINER_NAME}PDB1 \
    -p 8080:8080 \
    -p 1521:1521 \
    bluexmas/aarch64_oracle_db_19
pi@raspberrypi:~$ sudo docker run -d \
>     --name ${CONTAINER_NAME} \
>     --volume ${CONTAINER_NAME}_data:/u02/app/oracle/oradata \
>     --volume ${CONTAINER_NAME}_diag:/u01/app/oracle/diag \
>     --volume ${CONTAINER_NAME}_audit:/u01/app/oracle/admin \
>     --volume ${CONTAINER_NAME}_reco:/u03/app/oracle \
>     --volume $ORADATA/scripts:/scripts \
>     -e ORACLE_SID=${CONTAINER_NAME} \
>     -e ORACLE_PDB=${CONTAINER_NAME}PDB1 \
>     -p 8080:8080 \
>     -p 1521:1521 \
>     bluexmas/aarch64_oracle_db_19
cb12a2d9068bdb4ccf34ab033bfcc5ea9a9222f6d397a783995a1fb9da9393af

도커 실행 로그 확인

pi@raspberrypi:~$ sudo docker logs -f $CONTAINER_NAME
cat: /sys/fs/cgroup/memory.max: No such file or directory
ERROR: There was a problem getting the cgroups memory limit on the system
Exiting...
 
## ----------------------------------------------------------------------------------------------- #
  Oracle password for SYS, SYSTEM and PDBADMIN: muPGi2X9#b6J_7 
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: Running DBCA for database ORCL at 2024-03-23 12:59:41
## ----------------------------------------------------------------------------------------------- #
 
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 23-MAR-2024 12:59:41
 
Copyright (c) 1991, 2023, Oracle.  All rights reserved.
 
Starting /u01/app/oracle/product/19.19/dbhome_1/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.19/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/cb12a2d9068b/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                23-MAR-2024 12:59:41
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/19.19/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/cb12a2d9068b/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: Creating container database ORCL and 1 pluggable database(s) with name ORCLPDB1 at 2024-03-23 12:59:41
## ----------------------------------------------------------------------------------------------- #
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/ORCL.
Database Information:
Global Database Name:ORCL
System Identifier(SID):ORCL
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ORCL/ORCL.log" for further details.
 
Pluggable database altered.
 
 
Pluggable database altered.
 
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: DBCA complete at 2024-03-23 13:09:10
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  Database ORCL with unique name ORCL is open and available. 
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  Tailing alert_ORCL.log: 
2024-03-23T13:09:09.405148+00:00
ORCLPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  SIZE 5M AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  SIZE 5M AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2024-03-23T13:09:10.226142+00:00
alter pluggable database all open
Completed: alter pluggable database all open
alter pluggable database all save state
Completed: alter pluggable database all save state

컨테이너 ID 확인

pi@raspberrypi:~$ sudo docker ps 
CONTAINER ID   IMAGE                           COMMAND                   CREATED          STATUS                    PORTS                                                                                            NAMES
cb12a2d9068b   bluexmas/aarch64_oracle_db_19   "/bin/sh -c 'exec $D…"   10 minutes ago   Up 10 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 5500/tcp   ORCL

SQLPlus 접속

pi@raspberrypi:~$ sudo docker exec -it cb12a2d9068b sqlplus
 
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 23 13:11:36 2024
Version 19.19.0.0.0
 
Copyright (c) 1982, 2023, Oracle.  All rights reserved.
 
Enter user-name: SYSTEM
Enter password: 
Last Successful login time: Sat Mar 23 2024 13:05:14 +00:00
 
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0
 
SQL> select TABLESPACE_NAME from DBA_TABLESPACES;
 
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
 
SQL>