2016/12/31

macOS SierraにOracle Instant Client(12.1.0.2.0)をインストール

macOS 環境をセットアップする際に Oracle Instant Client を入れ直しましたのでその時のメモです。

インストール

以前はブラウザでアクセスしたときの認証クッキーを wget コマンドに渡してダウンロードしていましたが、面倒なので今回は手動でダウンロードしたものを解凍するだけです。

% for f in ~/Downloads/instantclient-*-macos.x64-12.1.0.2.0.zip; do unzip -o $f -d ~/local; done
12.1 のクライアントはとくに DYLD_LIBRARY_PATH 環境変数を設定しなくても接続できるようです。
% ~/local/instantclient_12_1/sqlplus scott/tiger@ol64.vbox/pdb

SQL*Plus: Release 12.1.0.2.0 Production on Fri Dec 30 22:19:00 2016

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

Last Successful login time: Fri Dec 30 2016 22:18:16 +09:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options

SQL>
詳しい仕組みは理解していませんが、インストール手順の Noteに -rpath について言及があるように、実行ファイルからの相対パス上にライブラリファイルがあることを想定しているようですので、同じ場所に解凍すればそれだけで大丈夫そうです。
% otool -L ~/local/instantclient_12_1/sqlplus
/Users/yoshikaw/local/instantclient_12_1/sqlplus:
        @rpath/libsqlplus.dylib (compatibility version 0.0.0, current version 0.0.0)
        @rpath/libclntsh.dylib.12.1 (compatibility version 0.0.0, current version 0.0.0)
        @rpath/libclntshcore.dylib.12.1 (compatibility version 0.0.0, current version 0.0.0)
        @rpath/libnnz12.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

アーカイブ内のファイル一覧

% for f in ~/Downloads/instantclient-*-macos.x64-12.1.0.2.0.zip; do unzip -l $f; done | grep instantclient_12_1 | perl -pe 's/( *\d+) +(\d+-\d+)-(\d+) (.{5}) +/$3-$2 $4 $1 /' | sort -u
2001-04-25 02:04        60 instantclient_12_1/sdk/demo/occiobj.typ
2002-10-15 18:19      2115 instantclient_12_1/sdk/include/occi.h
2005-07-07 19:38      4048 instantclient_12_1/sdk/include/ocidem.h
2005-07-07 19:38      8953 instantclient_12_1/sdk/include/ociextp.h
2005-07-07 19:39     10361 instantclient_12_1/sdk/include/oci8dp.h
2005-09-26 03:58      6204 instantclient_12_1/sdk/include/ociapr.h
2005-09-26 03:58      6494 instantclient_12_1/sdk/include/ocikpr.h
2005-09-26 03:58     43001 instantclient_12_1/sdk/include/ocidef.h
2005-09-26 03:59      7203 instantclient_12_1/sdk/include/oci1.h
2006-08-02 13:13     15083 instantclient_12_1/sdk/include/orid.h
2006-08-02 13:13    102775 instantclient_12_1/sdk/include/ori.h
2006-09-06 12:59      9892 instantclient_12_1/sdk/include/xa.h
2007-10-30 12:29     24778 instantclient_12_1/sdk/include/occiObjects.h
2010-02-16 17:50     39934 instantclient_12_1/sdk/include/occiData.h
2015-04-24 01:29      6506 instantclient_12_1/sdk/include/oratypes.h
2015-04-25 04:49       342 instantclient_12_1/glogin.sql
2015-04-30 00:08     36543 instantclient_12_1/sdk/include/nzerror.h
2015-04-30 00:08     75006 instantclient_12_1/sdk/include/nzt.h
2015-04-30 00:20     44851 instantclient_12_1/sdk/include/ldap.h
2015-05-06 21:01     18742 instantclient_12_1/ODBC_IC_Readme_Unix.html
2015-05-06 21:42      9141 instantclient_12_1/sdk/admin/oraaccess.xsd
2015-05-06 21:42     14783 instantclient_12_1/sdk/demo/cdemo81.c
2015-05-06 21:43      1227 instantclient_12_1/sdk/demo/oraaccess.xml
2015-05-06 21:43      1966 instantclient_12_1/sdk/demo/occidemod.sql
2015-05-06 21:43      4902 instantclient_12_1/sdk/demo/occiobj.cpp
2015-05-06 21:43      7649 instantclient_12_1/sdk/demo/occidml.cpp
2015-05-06 21:43      8358 instantclient_12_1/sdk/demo/occidemo.sql
2015-05-06 21:46      7848 instantclient_12_1/sdk/include/ocixmldb.h
2015-05-06 21:46     11649 instantclient_12_1/sdk/include/occiAQ.h
2015-05-06 21:46     11782 instantclient_12_1/sdk/include/ocidfn.h
2015-05-06 21:46     30429 instantclient_12_1/sdk/include/odci.h
2015-05-06 21:46     35604 instantclient_12_1/sdk/include/occiCommon.h
2015-05-06 21:46     42866 instantclient_12_1/sdk/include/oro.h
2015-05-06 21:46     72561 instantclient_12_1/sdk/include/occiControl.h
2015-05-06 21:46    105155 instantclient_12_1/sdk/include/ocixstream.h
2015-05-06 21:46    123766 instantclient_12_1/sdk/include/ort.h
2015-05-06 21:46    158261 instantclient_12_1/sdk/include/orl.h
2015-05-06 21:46    189648 instantclient_12_1/sdk/include/oci.h
2015-05-06 21:46    434446 instantclient_12_1/sdk/include/ociap.h
2015-05-06 21:53      6798 instantclient_12_1/sdk/demo/setuporamysql.sh
2016-01-14 20:43      4445 instantclient_12_1/odbc_update_ini.sh
2016-01-22 01:14       892 instantclient_12_1/sdk/ott
2016-06-08 00:08   3692096 instantclient_12_1/ojdbc6.jar
2016-06-08 00:08   3698857 instantclient_12_1/ojdbc7.jar
2016-06-08 05:20    309287 instantclient_12_1/sdk/ottclasses.zip
2016-06-08 18:38    238764 instantclient_12_1/libons.dylib
2016-06-08 18:40   9173288 instantclient_12_1/libnnz12.dylib
2016-06-08 18:44     54507 instantclient_12_1/orai18n-mapping.jar
2016-06-08 18:45    101327 instantclient_12_1/orai18n.jar
2016-06-08 19:25         0 instantclient_12_1/help/ja/
2016-06-08 19:25         0 instantclient_12_1/help/ja/META-INF/
2016-06-08 19:25         0 instantclient_12_1/help/ja/img/
2016-06-08 19:25         0 instantclient_12_1/help/ja/img_text/
2016-06-08 19:25         0 instantclient_12_1/help/us/
2016-06-08 19:25         0 instantclient_12_1/help/us/META-INF/
2016-06-08 19:25         0 instantclient_12_1/help/us/img/
2016-06-08 19:25         0 instantclient_12_1/help/us/img_text/
2016-06-08 19:25        71 instantclient_12_1/help/ja/META-INF/MANIFEST.MF
2016-06-08 19:25        71 instantclient_12_1/help/us/META-INF/MANIFEST.MF
2016-06-08 19:25      1035 instantclient_12_1/help/us/img_text/setup_ora.htm
2016-06-08 19:25      1040 instantclient_12_1/help/us/img_text/setup_app.htm
2016-06-08 19:25      1043 instantclient_12_1/help/ja/img_text/setup_ora.htm
2016-06-08 19:25      1044 instantclient_12_1/help/us/img_text/setup_work.htm
2016-06-08 19:25      1049 instantclient_12_1/help/ja/img_text/setup_ssmig.htm
2016-06-08 19:25      1051 instantclient_12_1/help/us/img_text/setup_ssmig.htm
2016-06-08 19:25      1057 instantclient_12_1/help/ja/img_text/setup_work.htm
2016-06-08 19:25      1061 instantclient_12_1/help/ja/img_text/setup_app.htm
2016-06-08 19:25      1311 instantclient_12_1/help/us/img_text/odbcmodel.htm
2016-06-08 19:25      1451 instantclient_12_1/help/ja/img_text/odbcmodel.htm
2016-06-08 19:25      2122 instantclient_12_1/help/ja/oracle.gif
2016-06-08 19:25      2122 instantclient_12_1/help/us/oracle.gif
2016-06-08 19:25      2746 instantclient_12_1/help/us/img_text/odbcdrvarch.htm
2016-06-08 19:25      3315 instantclient_12_1/help/ja/img_text/odbcdrvarch.htm
2016-06-08 19:25      4649 instantclient_12_1/help/us/cpyr.htm
2016-06-08 19:25      5620 instantclient_12_1/help/ja/cpyr.htm
2016-06-08 19:25      6126 instantclient_12_1/help/ja/blafdoc.css
2016-06-08 19:25      6181 instantclient_12_1/help/us/blafdoc.css
2016-06-08 19:25      7389 instantclient_12_1/help/ja/map.xml
2016-06-08 19:25      7468 instantclient_12_1/help/us/map.xml
2016-06-08 19:25      9431 instantclient_12_1/help/us/toc.htm
2016-06-08 19:25      9520 instantclient_12_1/help/ja/toc.htm
2016-06-08 19:25     13107 instantclient_12_1/help/ja/img/odbcmodel.gif
2016-06-08 19:25     13107 instantclient_12_1/help/us/img/odbcmodel.gif
2016-06-08 19:25     13174 instantclient_12_1/help/ja/img/setup_ora.gif
2016-06-08 19:25     13174 instantclient_12_1/help/us/img/setup_ora.gif
2016-06-08 19:25     14486 instantclient_12_1/help/ja/img/setup_work.gif
2016-06-08 19:25     14486 instantclient_12_1/help/us/img/setup_work.gif
2016-06-08 19:25     16950 instantclient_12_1/help/ja/img/odbcdrvarch.gif
2016-06-08 19:25     16950 instantclient_12_1/help/us/img/odbcdrvarch.gif
2016-06-08 19:25     19937 instantclient_12_1/help/ja/img/setup_ssmig.gif
2016-06-08 19:25     19937 instantclient_12_1/help/us/img/setup_ssmig.gif
2016-06-08 19:25     26457 instantclient_12_1/help/ja/img/setup_app.gif
2016-06-08 19:25     26457 instantclient_12_1/help/us/img/setup_app.gif
2016-06-08 19:25    180974 instantclient_12_1/help/us/sqora.htm
2016-06-08 19:25    203275 instantclient_12_1/help/ja/sqora.htm
2016-06-08 19:36     13980 instantclient_12_1/libheteroxa12.dylib
2016-06-08 19:36    159884 instantclient_12_1/libocijdbc12.dylib
2016-06-08 20:04   1272840 instantclient_12_1/libsqlplus.dylib
2016-06-08 20:04   5415256 instantclient_12_1/libsqora.dylib.12.1
2016-06-08 20:05   4532196 instantclient_12_1/libclntshcore.dylib.12.1
2016-06-08 20:05  67437336 instantclient_12_1/libclntsh.dylib.12.1
2016-06-08 22:10      8552 instantclient_12_1/sqlplus
2016-06-08 22:10     71202 instantclient_12_1/xstreams.jar
2016-06-08 22:11   1565732 instantclient_12_1/libsqlplusic.dylib
2016-06-08 22:12     40352 instantclient_12_1/genezi
2016-06-08 22:12     79524 instantclient_12_1/liboramysql12.dylib
2016-06-08 22:12   1483956 instantclient_12_1/libocci.dylib.12.1
2016-06-08 22:13         0 instantclient_12_1/
2016-06-08 22:13         0 instantclient_12_1/help/
2016-06-08 22:13         0 instantclient_12_1/sdk/
2016-06-08 22:13         0 instantclient_12_1/sdk/admin/
2016-06-08 22:13         0 instantclient_12_1/sdk/demo/
2016-06-08 22:13         0 instantclient_12_1/sdk/include/
2016-06-08 22:13       481 instantclient_12_1/sdk/SDK_README
2016-06-08 22:13       483 instantclient_12_1/JDBC_README
2016-06-08 22:13       485 instantclient_12_1/BASIC_README
2016-06-08 22:13       485 instantclient_12_1/TOOLS_README
2016-06-08 22:13       489 instantclient_12_1/SQLPLUS_README
2016-06-08 22:13       495 instantclient_12_1/BASIC_LITE_README
2016-06-08 22:13      4446 instantclient_12_1/sdk/demo/demo.mk
2016-06-08 22:13     10100 instantclient_12_1/adrci
2016-06-08 22:13    150228 instantclient_12_1/uidrvci
2016-06-08 22:13    799008 instantclient_12_1/wrc
2016-06-08 22:13   6001668 instantclient_12_1/libociicus.dylib
2016-06-08 22:13 109548524 instantclient_12_1/libociei.dylib
BASIC の README。
% cat BASIC_README
Basic Package Information
=========================

Wed Jun  8 06:13:14 PDT 2016

Client Shared Library 64-bit - 12.1.0.2.0

System name:    Darwin
Release:        13.4.0
Version:        Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64
Machine:        x86_64

Operating in ORACLE_HOME environment.

Small timezone file = /ade/b/4170853811/oracle/oracore/zoneinfo/timezone_18.dat
Large timezone file = /ade/b/4170853811/oracle/oracore/zoneinfo/timezlrg_18.dat
今回試した macOS のバージョン。
% uname -v
Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64

SDKの動作確認

いつものとおり SDK の動作確認として cpanm で DBD::Oracle をビルドしてみます。

% cpanm DBD::Oracle
--> Working on DBD::Oracle
Fetching http://www.cpan.org/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.74.tar.gz ... OK
Configuring DBD-Oracle-1.74 ... OK
Building and testing DBD-Oracle-1.74 ... FAIL
! Installing DBD::Oracle failed. See /Users/yoshikaw/.cpanm/work/1483108653.36790/build.log for details. Retry with --force to force install it.
ところが @rpath が解決できないエラーが出ました。これは DYLD_LIBRARY_PATH 環境変数で解決できるものではなさそうです。
t/000-report-versions-tiny.t .. ok
Can't load '/Users/yoshikaw/.cpanm/work/1483108653.36790/DBD-Oracle-1.74/blib/arch/auto/DBD/Oracle/Oracle.bundle' for module DBD::Oracle: dlopen(/Users/yoshikaw/.cpanm/work/1483108653.36790/DBD-Oracle-1.74/blib/arch/auto/DBD/Oracle/Oracle.bundle, 2): Library not loaded: @rpath/libclntsh.dylib.12.1
  Referenced from: /Users/yoshikaw/.cpanm/work/1483108653.36790/DBD-Oracle-1.74/blib/arch/auto/DBD/Oracle/Oracle.bundle
  Reason: image not found at /usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/DynaLoader.pm line 197.
この類のエラーを検索すると install_name_tool(1) で共有ライブラリ中のパスを変える方法が見つかりました。 これらのサイトに記載されている方法は、絶対パスではなく @executable_path や @rpath に変更する方法ですが、これの逆、インストール先の絶対パスに書き換えることで対応できました。
% cd ~/local/instantclient_12_1

% otool -D libclntsh.dylib.12.1
libclntsh.dylib.12.1:
@rpath/libclntsh.dylib.12.1

% install_name_tool -id $PWD/libclntsh.dylib.12.1 libclntsh.dylib.12.1
  
% otool -D libclntsh.dylib.12.1
libclntsh.dylib.12.1:
/Users/yoshikaw/local/instantclient_12_1/libclntsh.dylib.12.1
% cpanm DBD::Oracle
--> Working on DBD::Oracle
Fetching http://www.cpan.org/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.74.tar.gz ... OK
Configuring DBD-Oracle-1.74 ... OK
Building and testing DBD-Oracle-1.74 ... OK
Successfully installed DBD-Oracle-1.74
1 distribution installed
機械的に一律置換するのであれば以下のようになるでしょうか。
% find ~/local/instantclient_12_1 -name '*dylib*' -type f | xargs -n 1 -I{} bash -c 'p={}; install_name_tool -id $p $p'

おわりに

相変わらずインストール手順しか試していないなーという感じですね。。。

0 件のコメント:

コメントを投稿