2
1

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.

CentOS7からsqlplusでOracleRDSに接続する

Last updated at Posted at 2018-11-20

Oracleのダウンロードサイトにいく。

下記2つをダウンロード。
oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm

ダウンロードページの下にインストール手順も書いてある。

$ sudo yum install -y libaio
$ sudo rpm -ivh oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm

確認
$ ll /usr/lib/oracle/18.3/client64/lib

~/.bashrcなどに書いてもそのログインユーザーのみ使えるだけなので、
/etc/ld.so.conf.d/配下にファイルを作成して、共有ライブラリの検索パスを追記しておく。

# echo "/usr/lib/oracle/18.3/client64/lib" >> /etc/ld.so.conf.d/oracle.conf
# cat !$
cat /etc/ld.so.conf.d/oracle.conf
/usr/lib/oracle/18.3/client64/lib

/etc/ld.so.cacheの内容を更新してあげないと使われないので、ldconfigコマンドでld.so.conf.dの変更をキャッシュに反映する。

# ldconfig
# sqlplus64

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Nov 20 02:12:26 2018
Version 18.3.0.0.0

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

Enter user-name:

sqlplusは使えるようになったので、RDSへの接続確認をする。

$ sqlplus64 'ユーザー名@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=RDSのエンドポイント)(PORT=1521))(CONNECT_DATA=(SID=ORCL)))'

適当なSelect文を発行して確認

SQL> set linesize 160
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME    HOST_NAME                                                        VERSION           STARTUP_T STATUS       PAR    THREAD#
--------------- ---------------- ---------------------------------------------------------------- ----------------- --------- ------------ --- ----------
ARCHIVE LOG_SWITCH_WAIT LOGINS     SHU DATABASE_STATUS   INSTANCE_ROLE      ACTIVE_ST BLO
------- --------------- ---------- --- ----------------- ------------------ --------- ---
              1 ORCL             ip-10-7-2-238                                                    11.2.0.4.0        20-NOV-18 OPEN         NO           1
STARTED                 ALLOWED    NO  ACTIVE            PRIMARY_INSTANCE   NORMAL    NO
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?