Help us understand the problem. What is going on with this article?

OS X Mavericks に Oracle Client と ruby-oci8 をインストール

More than 3 years have passed since last update.

環境
- OS X 10.9.2
- Oracle client 11.2.0.3.0
- ruby-oci8 (2.1.6)

(参考)Setup Oracle instant client and ruby oci8 gem on Mac

-
オラクルから64bit版のファイルを入手する(要OTNアカウント)
http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

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

ファイルを解凍する

unzip -qq instantclient-basic-macos.x64-11.2.0.3.0.zip
unzip -qq instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
unzip -qq instantclient-sdk-macos.x64-11.2.0.3.0.zip

ファイルを移動する

mkdir -p /usr/local/oracle/product/instantclient_64/11.2.0.3.0/bin
mkdir -p /usr/local/oracle/product/instantclient_64/11.2.0.3.0/lib
mkdir -p /usr/local/oracle/product/instantclient_64/11.2.0.3.0/jdbc/lib
mkdir -p /usr/local/oracle/product/instantclient_64/11.2.0.3.0/rdbms/jlib
mkdir -p /usr/local/oracle/product/instantclient_64/11.2.0.3.0/sqlplus/admin

cd instantclient_11_2/

mv ojdbc* /usr/local/oracle/product/instantclient_64/11.2.0.3.0/jdbc/lib/
mv x*.jar /usr/local/oracle/product/instantclient_64/11.2.0.3.0/rdbms/jlib/

glogin.sql から login.sql にファイル名を変更する

mv glogin.sql /usr/local/oracle/product/instantclient_64/11.2.0.3.0/sqlplus/admin/login.sql

lib と sdk を移動する

mv *dylib* /usr/local/oracle/product/instantclient_64/11.2.0.3.0/lib/
mv sdk /usr/local/oracle/product/instantclient_64/11.2.0.3.0/lib/sdk

mv *README /usr/local/oracle/product/instantclient_64/11.2.0.3.0/
mv * /usr/local/oracle/product/instantclient_64/11.2.0.3.0/bin/

-
TNSを設定する

mkdir -p /usr/local/oracle/admin/network
vi /usr/local/oracle/admin/network/tnsnames.ora
xe=
 (description=
   (address_list=
     (address = (protocol = TCP)(host = 127.0.0.1)(port = 1521))
   )
 (connect_data =
   (service_name=xe)
 )
)

-
環境変数を設定する

vi ~/.oracle_client
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/instantclient_64/11.2.0.3.0
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib:$DYLD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_BASE/admin/network
export SQLPATH=$ORACLE_HOME/sqlplus/admin

export NLS_LANG=Japanese_Japan.AL32UTF8
alias sqlplus='rlwrap sqlplus'

rlwrap をインストールすると sqlplus で履歴を使えて便利

brew install rlwrap
echo "source ~/.oracle_client" >> ~/.bash_profile
source ~/.bash_profile

-
sqlplusで接続を確認する

ユーザ名 system、パスワード oracle だとして・・・

sqlplus system/oracle@127.0.0.1/xe

-
ruby-oci8 gem をインストールする

cd /usr/local/oracle/product/instantclient_64/11.2.0.3.0/lib
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib

gem install ruby-oci8

irbで動作を確認する

irb
> require 'oci8'
> o = OCI8.new('system','oracle','127.0.0.1/xe')
usutani
好物は Ruby on Rails や iOS アプリの開発です。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした