0%

Oracle database on Apple M chips

在Apple M芯片上运行Oracle数据库

当前,Oracle数据库并不支持在Apple M芯片上运行,使用Docker也无法使用,需要使用
colima。

安装colima

1
brew install colima

启动colima

1
2
# 基于x86_64架构,使用内存为4GiB
colima start --arch x86_64 --memory 4

使用docker启动oracle数据库

1
docker run -d -p 1521:1521 -e ORACLE_PASSWORD=<your password> -v oracle-volume:/opt/oracle/oradata gvenzl/oracle-xe

一个简单的启动脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash -e

VERSION=latest
PASSWORD=sys

usage() {
cat << EOF

Run Oracle database on Apple M chip.

Parameters:
-p: oracle database password, default for 'sys'
-v: oracle-e version
EOF
}

while getopts "hp:v:" optname; do
case "${optname}" in
"h")
usgae
exit 0
;;
"p")
PASSWORD="${OPTARG}"
;;
"v")
VERSION="${OPTARG}"
;;
esac
done

CONTAINER_RUNTIME=$(which docker 2>/dev/null) ||
{
echo "There is no docker in your PATH"
exit 1
}

arch=$(uname -m)
if [ $arch = "arm64" ]
then
echo "Run oracle database on Apple M chip."

COLIMA=$(which colima)
if [ -z $COLIMA ]
then
echo "No colima, try to install..."

brew_run=$(which brsew) && { ${brew_run} install colima; } ||
mac_port_run=$(which port) && { ${mac_port_run} install colima; } ||
nix_run=$(which nix-env) && { ${nix_run} -iA nixpkgs.colima; } ||
{
echo "Colima is available on Homebrew, MacPorts, and Nix."
echo "But now, can't found any of them."
exit 1
}
fi

colima start --arch x86_64 --memory 4
fi

if [ -z $PASSWORD ]
then
PASSWORD=sys
fi

PORT=1521
${CONTAINER_RUNTIME} run -d -p ${PORT}:1521 -e ORACLE_PASSWORD=${PASSWORD} gvenzl/oracle-xe:${VERSION}

echo "Oracle-xe start with port ${PORT}"
echo "Oracle password: ${PASSWORD}"

# stop and delete colima instance
# colima stop
# colima delete
# This is not a good idea delete colima instance, delete instance will delete
# all context for colima, of course, include image in this instance.

这个脚本暂时没有编写结束相关,参数相关内容,所以只能用作简单的启动脚本

Appendix

  • Colima - container runtimes on macOS (and Linux) with minimal setup.
  • Oracle-xe - Oracle-xe image