Oracle Instant ClientのSQL*PlusをMacで使う

Instantとかいうくらいだからアーカイブ展開したら即使えるとかなのかと思ったら、異常に面倒くさかった。

まずはOTNから適当に以下をダウンロードしてくる。SDKとかはいらない。

  • instantclient-basic-macos.x64-11.2.0.3.0.zip
  • instantclient-sqlplus-macos.x64-11.2.0.3.0.zip

これらを適当なディレクトリに展開する。自分は~/oracleとかつくってそこにばらまいた。

[~/oracle] ls -al
total 382920
drwxr-xr-x@ 20 gm7add9  staff        680 11 26 11:40 .
drwxr-xr-x+ 56 gm7add9  staff       1904 11 26 11:13 ..
-rw-r--r--@  1 gm7add9  staff       6148 11 26 11:40 .DS_Store
-rw-rw-rw-@  1 gm7add9  staff        484  2 15  2013 BASIC_README
-rw-rw-rw-@  1 gm7add9  staff        488  2 15  2013 SQLPLUS_README
-rwxrwxrwx@  1 gm7add9  staff      10252  2 15  2013 adrci
-rwxrwxrwx@  1 gm7add9  staff      40768  2 15  2013 genezi
-r--r--r--@  1 gm7add9  staff        368  4 10  2011 glogin.sql
-rwxrwxrwx@  1 gm7add9  staff   64771444 12 19  2012 libclntsh.dylib.11.1
-rwxrwxrwx@  1 gm7add9  staff    2808528  2 15  2013 libnnz11.dylib
-rwxrwxrwx@  1 gm7add9  staff    1897664 12 19  2012 libocci.dylib.11.1
-rwxrwxrwx@  1 gm7add9  staff  118379468  2 15  2013 libociei.dylib
-rwxrwxrwx@  1 gm7add9  staff     158924 12 19  2012 libocijdbc11.dylib
-rwxrwxrwx@  1 gm7add9  staff    1385860  2 12  2013 libsqlplus.dylib
-rwxrwxrwx@  1 gm7add9  staff    1504252  2 12  2013 libsqlplusic.dylib
-rw-rw-rw-@  1 gm7add9  staff    2095661  5 29  2012 ojdbc5.jar
-rw-rw-rw-@  1 gm7add9  staff    2714016  5 29  2012 ojdbc6.jar
-rwxr-xr-x@  1 gm7add9  staff       8744 12 19  2012 sqlplus
-rwxrwxrwx@  1 gm7add9  staff     162324  2 15  2013 uidrvci
-rw-rw-rw-@  1 gm7add9  staff      66779 12 19  2012 xstreams.jar

いざ、実行。

[~/oracle] sqlplus
dyld: Library not loaded: /ade/b/2649109290/oracle/sqlplus/lib/libsqlplus.dylib
Referenced from: /Users/gm7add9/oracle/sqlplus
Reason: image not found
zsh: trace trap sqlplus

はい、エラー。
/ade/b…とか変なパスでリンクしてんじゃねー。

全部install_name_toolで書き換え。

install_name_tool -change /ade/b/2649109290/oracle/sqlplus/lib/libsqlplus.dylib @executable_path/libsqlplus.dylib sqlplus
install_name_tool -change /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 @executable_path/libclntsh.dylib.11.1 sqlplus
install_name_tool -change /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib @executable_path/libnnz11.dylib sqlplus
install_name_tool -change /ade/b/1891624078/oracle/sqlplus/lib/libsqlplus.dylib @executable_path/libsqlplus.dylib sqlplus
install_name_tool -change /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 @loader_path/libclntsh.dylib.11.1 libsqlplus.dylib
install_name_tool -change /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib @loader_path/libnnz11.dylib libsqlplus.dylib
install_name_tool -change /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib @loader_path/libnnz11.dylib libclntsh.dylib.11.1
install_name_tool -change /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 @loader_path/libclntsh.dylib.11.1 libsqlplusic.dylib
install_name_tool -change /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib @loader_path/libnnz11.dylib libsqlplusic.dylib
install_name_tool -change /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 @loader_path/libclntsh.dylib.11.1 libociei.dylib

再実行。

[~/oracle] sqlplus                                                                                     [gm7add9@vivace]

SQL*Plus: Release 11.2.0.3.0 Production on 火 11月 26 11:49:30 2013

Copyright (c) 1982, 2012, Oracle.  All rights reserved.

ユーザー名を入力してください:

やっとうごいた。みんなこんな面倒くさいことしてんのだろうか…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s