Skip to content

Dev setup on Apple silicon

Bei Chu edited this page Feb 21, 2024 · 11 revisions

Docker

In Docker Desktop, go to Settings -> Resources, set all resource allocation to max.

Oracle

Server

Download Oracle Database 19c for LINUX ARM (aarch64) from https://www.oracle.com/database/technologies/oracle-database-software-downloads.html. Say the downloaded file is at ~/Downloads/LINUX.ARM64_1919000_db_home.zip.

git clone https://github.com/oracle/docker-images.git oracle-docker-images
cd oracle-docker-images/OracleDatabase/SingleInstance/dockerfiles/
mv ~/Downloads/LINUX.ARM64_1919000_db_home.zip 19.3.0/
./buildContainerImage.sh -v 19.3.0 -e

The built image name should be oracle/database:19.3.0-ee.

Now you can run Oracle database using Docker:

docker run --name oracle -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=123 -e ENABLE_ARCHIVELOG=true -v ./data:/opt/oracle/oradata oracle/database:19.3.0-ee

Client

Download Basic Package (DMG), SQL*Plus Package (DMG) and Tools Package (DMG) from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html and run using Rosetta.

User

The user used for replication must have certain permissions. The user name must start with C##. Following command uses C##DOZER.

Log in to CDB using sqlplus. 123 is the ORACLE_PWD env var set in docker run.

sqlplus sys/123@//localhost:1521/ORCLCDB as sysdba

Create user and grant some permissions.

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
CREATE USER C##DOZER IDENTIFIED BY 123;
ALTER USER C##DOZER SET CONTAINER_DATA=ALL CONTAINER=CURRENT;
GRANT CREATE SESSION TO C##DOZER;
GRANT SELECT ON SYS.V_$LOG TO C##DOZER;
GRANT SELECT ON SYS.V_$LOGFILE TO C##DOZER;
GRANT SELECT ON SYS.V_$ARCHIVED_LOG TO C##DOZER;
GRANT SELECT ON SYS.V_$LOGMNR_CONTENTS TO C##DOZER;
GRANT LOGMINING TO C##DOZER;
GRANT EXECUTE ON DBMS_LOGMNR TO C##DOZER;

Log in to PDB.

sqlplus sys/123@//localhost:1521/ORCLPDB1 as sysdba

Grant more permissions.

GRANT CREATE TYPE TO C##DOZER;
GRANT SELECT ON SYS.ALL_TABLES to C##DOZER;
GRANT SELECT ON SYS.ALL_TAB_COLUMNS TO C##DOZER;
GRANT SELECT ON SYS.ALL_CONSTRAINTS TO C##DOZER;
GRANT SELECT ON SYS.ALL_CONS_COLUMNS TO C##DOZER;
GRANT EXECUTE ON SYS.DBMS_FLASHBACK TO C##DOZER;

Dozer

Install Dev Containers extension in VSCode. In Command Palette, select Dev Containers: Open Folder in Container, and open the dozer repository. The container is set to use 32GB memory and 10 CPUs. If that's more than your available resources, adjust accordingly.

Install dependencies.

sudo apt update
sudo apt install -y cmake protobuf-compiler clang libaio1

Install Oracle client library

wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linux-arm64.zip
unzip instantclient-basic-linux-arm64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/instantclient_19_22
sudo ldconfig

Use mold linker (Optional)

This container's default linker is painfully slow. To use mold linker, first build and install it:

git clone https://github.com/rui314/mold.git
mkdir mold/build
cd mold/build
git checkout v2.4.0
../install-build-deps.sh
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ ..
cmake --build . -j $(nproc)
sudo cmake --build . --target install

Then add following to .cargo/config.toml.

[target.aarch64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]