Oracle19c in Apple Silicon

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。

Screenshot 2024-07-26 at 08.24.09

簡單來說,我們可以自選一個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
Screenshot 2024-07-26 at 08.42.56

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料