M1 맥북 오라클 설치 - M1 maegbug olakeul seolchi

As Apple has released the M1 chip with a different architecture than the previous generation, it resulted in various apps including Oracle Instant Client not being able to work normally on Apple silicon. However, there’s Rosetta 2 — “A translation process that allows users to run apps that contain x86–64 instructions on Apple silicon” says by Apple. So, In this article I’m going to share my sample steps for setting up Oracle Database Instant Client in Apple Silicon M1.

If you are facing an issue related to installation of Oracle Database Instant Client on M1 something like “DPI-1047: Cannot locate a 64-bit Oracle Client library: mach-o, but wrong architecture”, you may consider the following solution as an alternative way to install Oracle Instant Client.

Steps to Install Oracle Instant Client on Apple SiliconStep 1: install rosetta2

Use below command to install rosetta2:

/usr/sbin/softwareupdate — install-rosetta

Note: The above command will launch the Rosetta installer. Then, you just need to agree to its license agreement. However, you can skip the license agreement by providing this additional flag as below:

/usr/sbin/softwareupdate –install-rosetta –agree-to-license

Then, I duplicate the terminal and set default to “open using rosetta” and will use this terminal to install other items in the next steps.

Step 2: install brew

Use below command to install brew:

arch -x86_64 /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Note: ensure that the library should located at (/usr/local/Homebrew/bin/brew)

Step 3: install python

Use below command to install python:

arch -x86_64 brew install python

Step 4: install pip and dependencies library

Use below command to install pip:

Note: make sure that the libraries are installed with -x86_64.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

Step 5: download instant client

Link: https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

> Move ${instantclient_folder_name} folder (group Basic Package, SQL*Plus Package, SDK Package as 1 folder) after unzip to /Users/[your user path]

> Create a folder ~/lib

> Create a symbolic link

- ln -s /Users/[your user path]/${instantclient_folder_name}/libclntsh.dylib ~/lib/

step 6: setup export path in .zshrc file

> sudo vi .zshrc

> Enter your mac password

> To insert text to file press -> i

Insert below paths to the file:

export PATH=/Users/[your user path]/instantclient:$PATH

export ORACLE_HOME=/Users/[your user path]/instantclient

export DYLD_LIBRARY_PATH=/Users/[your user path]/instantclient

export OCI_LIB_DIR=/Users/[your user path]/instantclient

export OCI_INC_DIR=/Users/[your user path]/instantclient/sdk/include

> Save and quit by command -> :wq

> source .zshrc

Step 7: Install cx_Oracle from PyPi

> python -m pip install cx_Oracle — upgrade — user

Note: The — user is optional and may be useful, if you don’t have permission to write to system directories

Step 8: try running SQLPlus

References:

https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr

참고) m1맥북은 오라클 지원을 안한다고 한다..

맥에 Oracle을 설치하려면 가상 머신과 비슷한 Docker 컨테이너를 통해야 한다.
Docker 사이트를 통해 회원가입을 하고 맥용 desktop 앱을 다운받는다.
맥용 Docker 다운로드 페이지 바로가기

설치 후 Docker 앱에서 로그인하기

내가 저장할 오라클의 이미지와 오라클 컨테이너의 정보의 저장을 위해 로그인한다.
Docker 설치가 다 되었다면 cmd 창을 연다.

docker pull deepdiver/docker-oracle-xe-11g

oracle xe 11g 이미지를 다운받는다.

docker pull jaspeen/oracle-xe-11g

사용할 oracle 버전을 다운받는다.

docker run --name myoracle -d -p 8080:8080 -p 1521:1521 jaspeen/oracle-xe-11g

로컬과 컨테이너의 포트를 연결시켜주는 작업이다.
1521 기본 포트를 사용하였다.
--name뒤에 이름은 컨테이너 이름으로 설정된다.

docker ps -a

현재 실행되고 있는 컨테이너 아이디와 정보를 보여준다.

docker rename <현재 컨테이너 이름> <새 컨테이너 이름>

컨테이너를 알아보기 쉽게 하기 위해 현재 컨테이너 이름을 새 컨테이너 이름으로 바꾸어 준다.
예시: clever_nclean에서 myoracle

docker exec -it myoracle sqlplus

cmd에서 sqlplus를 실행한다.
기본 아이디는 system 비밀번호는 oracle이다.

오라클 사이트에서 SQL developer를 설치한다.

맥에서 SQL developer 실행 시 유의사항

  1. 알수 없는 앱으로 뜨기 때문에 ctrl + 열기로 실행한다.

  2. 실행이 되지 않는 경우 자바 버전을 확인해야 한다.
    CMD에서 자바 버전과 경로 확인하는 방법
    1. /usr/libexec/java_home -V
    2. ls /Library/Java/JavaVirtualMachines jdk1.8.0_281.jdk
    3. echo $(/usr/libexec/java_home -F -v 1.8.0_281)

  3. 버전 확인 후 SQLDeveloper.app 우클릭 > 패키지 내용 보기

  4. Connects > MacOS > sqldeveloper.sh 파일 열기

  5. 2번째 라인 TMP_PATH에서 자바 버전 변경하기(1.8.0_281)

  6. 데이터베이스 접속 또는 생성시 오류를 막기 위해 language와 contry를 kr로 변경해준다.
    SQLDeveloper.app 우클릭 > 패키지 내용 보기
    Contents > Resources > sqldeveloper > sqldeveloper > bin > sqldeveloper.conf 파일 열기

sqldeveloper.conf 파일에 추가해야 할 내용

1. AddVMOption -Duser.language=ko
2. AddVMOption -Duser.country=KR

번외1. 맥에서 터미널로 .sql파일 실행하기

윈도우에서는 @이후 파일 경로와 파일 이름을 적어주면 되지만 맥에서는 docker를 이용하여 실행하여야 한다.

docker exec -i myoracle sqlplus system/oracle < 파일 경로/파일 이름.sql

번외2. SQL developer 한글로 인코딩 바꾸기

도구>환경설정>환경>인코딩에서 UTF-8로 변경한다.

주의) SQLDeveloper는 Java8과 Java11에서만 실행됩니다.


참고한 블로그
https://velog.io/@jcrs0907/oracle-mac-sql-developer
SQLDeveloper 실행 안될때 : https://devmoony.tistory.com/111