22
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-04-16

環境

  • 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')
22
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?