Oracle 19c with Docker and Apple Silicon

目前工作環境少量需求要用到oracle 11g,先前在Intel Mac下,用 gvenzl/oracle-xe 沒什麼問題,但換了 M3 後就變成一個問題,雖然用 Colima 可以執行,但同時其他的 Container 也需要調整,不然 Docker 下的 default builder 跟 colima 相互間是看不到的。

所以花了不少時間在查,最後找到個方式

Oracle Cloud Native

Oraclesean/Oracle Cloud Native 看到這篇後可以知道,Oracle在arm64的架構上是有提供19c的安裝檔,可以自 Oracle19c-linux-arm64 這裡找到安裝檔,並可以在 container-registry.oracle.com 這下載到已 Build 完成的 image。

簡單來說,我們可以自選一個 Oracle 提供的 arm64 linux base image,加上 oracle 19c for arm64 的安裝檔,自己建出可用的 image。

但運氣還不錯,已經有人做了….,所以可以省不少工。

Oracle 19c for arm64

例如在 docker hub – rollernaut 中,我們就可以看到完整的 Dockerfile,用了 LINUX.ARM64_1919000_db_home.zip 來做為執行內容。

再來要找到可用的設定,這裡可以參考 Github – steveswinsburg,可以找到 Configuration 的說明。

 --name:        The name of the container (default: auto generated)
   -p:            The port mapping of the host port to the container port.
                  Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
   -e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
   -e ORACLE_PDB: The Oracle Database Service Name that should be used (default: ORCLPDB1)
   -e ORACLE_PWD: The Oracle Database SYS password (default: auto generated)
   -e INIT_SGA_SIZE: The amount of SGA to allocate to Oracle. This should be 75% of the total memory you want Oracle to use. 
   -e INIT_PGA_SIZE: The amount of PGA to alloxate to oracle. This should be the remaining 25% of the total memory you want Oracle to use.  
   -e ORACLE_CHARACTERSET: The character set to use when creating the database (default: AL32UTF8)
   -v /opt/oracle/oradata
                  The data volume to use for the database.
                  Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
                  If omitted the database will not be persisted over container recreation.
   -v /Users/<your-username>/path/to/store/db/files/:/opt/oracle/oradata
                  Mount the data volume into one of your local folders.
                  If omitted you might run into a "No disk space" issue at some point as your database keeps growing and docker does not resize its volume.
   -d:            Run in detached mode. You want this otherwise `Ctrl-C` will kill the container. 

Docker Compose Example

簡單用成 docker-compose.yaml

services:
  oracle:
    platform: linux/arm64/v8
    container_name: oraclexe
    image: rollernaut/oracle19c:latest
    environment:
      - "ORACLE_PWD=system"
    ports:
      - "1521:1521"
    volumes:
      - ./data/oracle/v8data:/opt/oracle/oradata 

這樣就能透過下列的 client 設定連上 oracle

Hostname: localhost
Port: 1521
Service Name: ORCLPDB1
Username: sys
Password: system
Role: AS SYSDBA 

|500

经验

之前在 intel mac 上安装过 oracle Docker 安装 Oracle
参照同样的方式去在 m 系列芯片上安装,发现失败,核心逻辑就是 Docker 是否可以跨平台运行?
虽然 m 系统芯片上可以通过 rosetta 进行转译。但是依然转译失败。