0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

オフライン環境(一部のみ)でのora2pgセットアップ(CPANミラー)

0
Last updated at Posted at 2026-07-06

オフライン環境でora2pgのセットアップを行ったので、備忘として残しておく。
OS側のモジュールは、isoマウントで設定済みのため、残すはCPANからモジュールの取得&ビルドのみ。
※ ora2pgを使うには、Perlの実行環境が必要

ただし、オフライン環境下ではCPAN(Comprehensive Perl Archive Network:Perlのライブラリ・モジュール等のリポジトリ)にアクセスできないので、特殊な対応が必要である。

今回はCPANミラーを作成することで、対応した。
まず、インターネット接続可能なサーバでCPANミラーを作成する。

--- インターネット接続可能なサーバでの作業 ---

- ① cpanmのインストール -

CPANミラーを作成するために、capnmを使えるようにする。

① cpanmインストール
dnf -y install perl-App-cpanminus
メタデータの期限切れの最終確認: 0:21:56 前の 2026年07月02日 20時22分31秒 に実施しました。
依存関係が解決しました。
==============================================================================================================================
 パッケージ                               アーキテクチャー   バージョン                           リポジトリー          サイズ
==============================================================================================================================
インストール:
 perl-App-cpanminus                       noarch             1.7044-15.el9                        appstream              86 k
アップグレード:
 bpftool                                  x86_64             7.5.0-804.el9.0.1                    appstream             317 k
 cpp                                      x86_64             11.5.0-14.el9                        appstream              11 M
 glibc                                    x86_64             2.34-270.el9_8                       baseos                2.0 M

 ~~ 中略 ~~

rust-srpm-macros-17-4.el9.noarch                              sombok-2.4.0-16.el9.x86_64
systemtap-sdt-devel-5.4-4.el9.x86_64                          systemtap-sdt-dtrace-5.4-4.el9.x86_64

完了しました!

- ② cpanmの確認 -
インストールが完了したので、cpanmコマンドの確認を行う。

② cpanmコマンドの確認
cpanm
Usage: cpanm [options] Module [...]

Try `cpanm --help` or `man cpanm` for more options.

- ③ CPAN::Miniのインストール -
CPAN::Miniは、最小限のCPANローカルミラーを構築するためのPerlモジュール。
これを用いてミラーを作成するため、コマンドを実行できるようにモジュールのインストールを行う。

③ CPAN::Miniのインストール
cpanm CPAN::Mini
--> Working on CPAN::Mini
Fetching https://www.cpan.org/authors/id/R/RJ/RJBS/CPAN-Mini-1.111017.tar.gz ... OK
Configuring CPAN-Mini-1.111017 ... OK
==> Found dependencies: LWP::UserAgent

 ~~ 中略 ~~

Building and testing HTTP-Negotiate-6.01 ... OK
Successfully installed HTTP-Negotiate-6.01
Building and testing libwww-perl-6.83 ... OK
Successfully installed libwww-perl-6.83
Building and testing CPAN-Mini-1.111017 ... OK
Successfully installed CPAN-Mini-1.111017
28 distributions installed

- ④ ミラーの作成 -
minicpanコマンドを使って、最新モジュールをダウンロードする。

 minicpan -r ダウンロード元のURL -l ダウンロード先のディレクトリ

④ ミラーの作成
minicpan -r http://cpan.metacpan.org/ -l /work/minicpan/
Updating /work/minicpan
Mirroring from http://cpan.metacpan.org/
===============================================================
authors/01mailrc.txt.gz ... updated
modules/02packages.details.txt.gz ... updated
modules/03modlist.data.gz ... updated

 ~~ 中略 ~~


authors/id/Z/ZZ/ZZZ/Here-Template-0.2.tar.gz ... updated
authors/id/Z/ZZ/ZZZ/Nginx-HTTP-0.04.tar.gz ... updated
authors/id/Z/ZZ/ZZZ/Nginx-Perl-1.8.1.10.tar.gz ... updated
authors/id/Z/ZZ/ZZZ/Nginx-Redis-1.1.12.4.tar.gz ... updated
authors/id/Z/ZZ/ZZZ/Redis-Parser-XS-0.02.tar.gz ... updated
authors/id/Z/ZZ/ZZZ/Tie-Hash-LRU-0.05.tar.gz ... updated

作成したミラーを持ち込むため、ZIP圧縮する。
圧縮後は、ora2pgをセットアップする予定のサーバへアップロードし、解凍する。

ミラーの圧縮
zip -r ./minicpan.zip ./minicpan

--- クローズドなサーバでの作業 ---

- ⑤ 圧縮したミラーの解凍 -
ここからはインストールに接続できないクローズドなサーバでの作業となる。

まず圧縮したミラーは、任意の場所に解凍する。

ここでは /work 配下に解凍している。どのユーザーでもアクセスできるように 777 に変更する。

⑤ 圧縮したミラーの解凍
[root@kktbt100g work]# unzip -q ./minicpanc.zip
[root@kktbt100g work]# ls -ltr ./
合計 5748316
drwxr-xr-x. 4 root   root             50  7月  3 00:21 minicpan
-rw-r--r--. 1 root   root     5886264718  7月  3 18:04 minicpanc.zip
[root@kktbt100g work]#
[root@kktbt100g work]# chmod -R 777 ./minicpan
[root@kktbt100g work]#
[root@kktbt100g work]# ls -ltr ./
合計 5748316
drwxrwxrwx. 4 root   root             50  7月  3 00:21 minicpan
-rw-r--r--. 1 root   root     5886264718  7月  3 18:04 minicpanc.zip

- ⑥ ora2pgユーザーの作成 -
ora2pgを使用するためのOSユーザー、ora2pg(任意のユーザー)を作成する。

⑥ ora2pgユーザーの作成
[root@kktbt100g ~]# useradd ora2pg
[root@kktbt100g ~]# id ora2pg
uid=10002(ora2pg) gid=10002(ora2pg) groups=10002(ora2pg)
[root@kktbt100g ~]#
[root@kktbt100g ~]# passwd ora2pg
ユーザー ora2pg のパスワードを変更。
新しい パスワード:
正しくないパスワード: このパスワードは 8 文字未満の文字列です
新しい パスワードを再入力してください:
passwd: すべての認証トークンが正しく更新できました。
[root@kktbt100g ~]#
[root@kktbt100g ~]# su - ora2pg
[ora2pg@kktbt100g ~]$ id
uid=10002(ora2pg) gid=10002(ora2pg) groups=10002(ora2pg) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[ora2pg@kktbt100g ~]$

- ⑦ 環境変数の設定 -
Perlモジュールのインストールおよび、ora2pgの実行にあたり、OracleClient向けの環境変数を設定する必要がある。
(DBD::Oracle モジュールも、OracleClientの環境変数を参照する)

下記のとおり設定する。

⑦ 環境変数の設定
[ora2pg@kktbt100g ~]$ cp .bash_profile .bash_profile_`date +%Y%m%d`
[ora2pg@kktbt100g ~]$ ls -ltr .bash_profile*
-rw-r--r--. 1 ora2pg ora2pg 141  4月 30  2024 .bash_profile
-rw-r--r--. 1 ora2pg ora2pg 141  7月  6 16:33 .bash_profile_20260706
[ora2pg@kktbt100g ~]$ vi .bash_profile
[ora2pg@kktbt100g ~]$
[ora2pg@kktbt100g ~]$
[ora2pg@kktbt100g ~]$ diff .bash_profile .bash_profile_`date +%Y%m%d`
9,13d8
<
< export ORACLE_BASE=/opt/app/oracle
< export ORACLE_HOME=${ORACLE_BASE}/product/19.0.0/client_1
< export PATH=${PATH}:${ORACLE_HOME}/bin
< export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
[ora2pg@kktbt100g ~]$

- ⑧ Perlモジュールのインストール -
OSユーザー作成、CPANミラーを持ち込みが完了したので、Perlモジュールのインストールを行う。

インストールは下記のコマンドで行う。

cpanm --mirror [CPANミラーの展開先パス] [モジュール名]

⑧ Perlモジュールのインストール
[ora2pg@kktbt100g ~]$ cpanm --mirror /work/minicpan DBI
!
! Can't write to /usr/local/share/perl5/5.32 and /usr/local/bin: Installing modules to /home/ora2pg/perl5
! To turn off this warning, you have to do one of the following:
!   - run me as a root or with --sudo option (to install to /usr/local/share/perl5/5.32 and /usr/local/bin)
!   - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
!   - Install local::lib by running the following commands
!
!         cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
! Finding DBI on cpanmetadb failed.
--> Working on DBI
Fetching file:///work/minicpan/authors/id/H/HM/HMBRAND/DBI-1.649.tgz ... OK
Configuring DBI-1.649 ... OK
Building and testing DBI-1.649 ... OK
Successfully installed DBI-1.649 (upgraded from 1.643)
1 distribution installed
[ora2pg@kktbt100g ~]$
[ora2pg@kktbt100g ~]$ cpanm --mirror /work/minicpan DBD::Oracle
!
! Can't write to /usr/local/share/perl5/5.32 and /usr/local/bin: Installing modules to /home/ora2pg/perl5
! To turn off this warning, you have to do one of the following:
!   - run me as a root or with --sudo option (to install to /usr/local/share/perl5/5.32 and /usr/local/bin)
!   - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
!   - Install local::lib by running the following commands
!
!         cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
! Finding DBD::Oracle on cpanmetadb failed.
--> Working on DBD::Oracle
Fetching file:///work/minicpan/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.95.tar.gz ... OK
Configuring DBD-Oracle-1.95 ... OK
==> Found dependencies: Test::NoWarnings
! Finding Test::NoWarnings on cpanmetadb failed.
--> Working on Test::NoWarnings
Fetching file:///work/minicpan/authors/id/H/HA/HAARG/Test-NoWarnings-1.06.tar.gz ... OK
Configuring Test-NoWarnings-1.06 ... OK
Building and testing Test-NoWarnings-1.06 ... OK
Successfully installed Test-NoWarnings-1.06
Building and testing DBD-Oracle-1.95 ... FAIL
! Installing DBD::Oracle failed. See /home/ora2pg/.cpanm/work/1783326087.2841/build.log for details. Retry with --force to force install it.
1 distribution installed
[ora2pg@kktbt100g ~]$ cpanm --mirror /work/minicpan DBD::Pg
!
! Can't write to /usr/local/share/perl5/5.32 and /usr/local/bin: Installing modules to /home/ora2pg/perl5
! To turn off this warning, you have to do one of the following:
!   - run me as a root or with --sudo option (to install to /usr/local/share/perl5/5.32 and /usr/local/bin)
!   - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
!   - Install local::lib by running the following commands
!
!         cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
! Finding DBD::Pg on cpanmetadb failed.
--> Working on DBD::Pg
Fetching file:///work/minicpan/authors/id/T/TU/TURNSTEP/DBD-Pg-3.20.2.tar.gz ... OK
Configuring DBD-Pg-3.20.2 ... OK
Building and testing DBD-Pg-3.20.2 ... OK
Successfully installed DBD-Pg-3.20.2 (upgraded from 3.14.2)
1 distribution installed
[ora2pg@kktbt100g ~]$
[ora2pg@kktbt100g ~]$

よく見てみると、DBD::Oracleでエラーになっている。
root権限で実行しろ、とあるので、ora2pgのグループを修正する。oinstall, wheelに所属させ、再実行する。

Perlモジュールの再インストール
[root@kktbt100g ~]# id oracle
uid=10001(oracle) gid=11000(oinstall) groups=11000(oinstall),11001(apdstgrp),11002(kkgrp)
[root@kktbt100g ~]#
[root@kktbt100g ~]# usermod -g oinstall ora2pg
[root@kktbt100g ~]# usermod -g wheel ora2pg
[root@kktbt100g ~]# id ora2pg
uid=10002(ora2pg) gid=10(wheel) groups=10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@kktbt100g ~]#
[root@kktbt100g ~]# su - ora2pg
[ora2pg@kktbt100g ~]$sudo -E cpanm --mirror /work/minicpan DBD::Oracle
! Finding DBD::Oracle on cpanmetadb failed.
--> Working on DBD::Oracle
Fetching file:///work/minicpan/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.95.tar.gz ... OK
Configuring DBD-Oracle-1.95 ... OK
Building and testing DBD-Oracle-1.95 ... FAIL
! Installing DBD::Oracle failed. See /root/.cpanm/work/1783339977.4788/build.log for details. Retry with --force to force install it.

まだエラーになる。
ここでビルドログを確認してみる。

 /root/.cpanm/build.log

Perlモジュールをcpanmコマンドでインストールする際に記録されるビルドおよびエラーのログファイル。

だが、エラーログを確認するも原因は分からず。
諦めて、オンライン環境でのログインに切り替え。。。。

DBD::Oracle(オンライン インストール)
[root@kktbt100g ~]# cpanm DBD::Oracle
--> Working on DBD::Oracle
Fetching https://www.cpan.org/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.95.tar.gz ... OK
Configuring DBD-Oracle-1.95 ... OK
Building and testing DBD-Oracle-1.95 ... OK
Successfully installed DBD-Oracle-1.95
1 distribution installed
[root@kktbt100g ~]#

オンラインだと問題なくインストールできた。
(途中、racle-instantclient19.31-[devel|sqlplus|basic|jdbc]*.rpmをインストールするもエラーのまま)

ビルドログによると、Oracleの共有ライブラリが正しく参照されていないことが原因のようだったが、何が違うのか。。。。

ひとまず先に進む。

- ⑨ Perlモジュールのバージョン確認 -

ここで、Perlモジュールを確認する。

⑨ Perlモジュールのバージョン確認
[ora2pg@kktbt100g ~]$ perl -MDBI -e 'print "DBI Version:$DBI::VERSION\n"'
DBI Version:1.643
[ora2pg@kktbt100g ~]$ perl -MDBD::Oracle -e 'print "$DBD::Oracle::VERSION:\n"'
1.95:
[ora2pg@kktbt100g ~]$ perl -MDBD::Pg -e 'print "$DBD::Pg::VERSION\n"'
3.14.2

無事にインストールできた。

- ⑩ ora2pgのコンパイル・インストール -

最後に予め取得しておいたora2pgをコンパイル・インストールする。

make & make install は root ユーザーで実行しないとエラーとなる。
そのため、make & make install の直前で root ユーザー戻っている。

⑩ ora2pgのコンパイル・インストール
[ora2pg@kktbt100g work]$ tar zxvf ./ora2pg-24.3.tar.gz
ora2pg-24.3/
ora2pg-24.3/LICENSE
ora2pg-24.3/packaging/
ora2pg-24.3/packaging/debian/
ora2pg-24.3/packaging/debian/ora2pg/
ora2pg-24.3/packaging/debian/ora2pg/DEBIAN/
ora2pg-24.3/packaging/debian/ora2pg/DEBIAN/copyright
ora2pg-24.3/packaging/debian/ora2pg/DEBIAN/control
ora2pg-24.3/packaging/debian/create-deb-tree.sh
ora2pg-24.3/packaging/slackbuild/
ora2pg-24.3/packaging/slackbuild/Ora2Pg.SlackBuild
ora2pg-24.3/packaging/slackbuild/Ora2Pg.info
ora2pg-24.3/packaging/slackbuild/README
ora2pg-24.3/packaging/slackbuild/slack-desc
ora2pg-24.3/packaging/slackbuild/doinst.sh
ora2pg-24.3/packaging/README
ora2pg-24.3/packaging/RPM/
ora2pg-24.3/packaging/RPM/ora2pg.spec
ora2pg-24.3/MANIFEST
ora2pg-24.3/changelog
ora2pg-24.3/INSTALL
ora2pg-24.3/Makefile.PL
ora2pg-24.3/README
ora2pg-24.3/scripts/
ora2pg-24.3/scripts/ora2pg
ora2pg-24.3/scripts/ora2pg_scanner
ora2pg-24.3/lib/
ora2pg-24.3/lib/Ora2Pg/
ora2pg-24.3/lib/Ora2Pg/MSSQL.pm
ora2pg-24.3/lib/Ora2Pg/MySQL.pm
ora2pg-24.3/lib/Ora2Pg/Oracle.pm
ora2pg-24.3/lib/Ora2Pg/PLSQL.pm
ora2pg-24.3/lib/Ora2Pg/GEOM.pm
ora2pg-24.3/lib/Ora2Pg.pm
ora2pg-24.3/doc/
ora2pg-24.3/doc/ora2pg.3
ora2pg-24.3/doc/Ora2Pg.pod
[ora2pg@kktbt100g work]$
[ora2pg@kktbt100g work]$ cd ora2pg-24.3/
[ora2pg@kktbt100g ora2pg-24.3]$
[ora2pg@kktbt100g ora2pg-24.3]$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Ora2Pg
Writing MYMETA.yml and MYMETA.json

Done...
------------------------------------------------------------------------------
Please read documentation at http://ora2pg.darold.net/ before asking for help
------------------------------------------------------------------------------
Now type: make && make install
[ora2pg@kktbt100g ora2pg-24.3]$
[root@kktbt100g ~]# cd /work/ora2pg-24.3/
[ora2pg@kktbt100g ora2pg-24.3]$ exit
[root@kktbt100g ora2pg-24.3]# make && make install
Manifying 1 pod document
Manifying 1 pod document
Installing /usr/local/share/perl5/5.32/Ora2Pg.pm
Installing /usr/local/share/perl5/5.32/Ora2Pg/PLSQL.pm
Installing /usr/local/share/perl5/5.32/Ora2Pg/Oracle.pm
Installing /usr/local/share/perl5/5.32/Ora2Pg/MySQL.pm
Installing /usr/local/share/perl5/5.32/Ora2Pg/MSSQL.pm
Installing /usr/local/share/perl5/5.32/Ora2Pg/GEOM.pm
Installing /usr/local/share/man/man3/ora2pg.3
Installing /usr/local/bin/ora2pg
Installing /usr/local/bin/ora2pg_scanner
Installing default configuration file (ora2pg.conf.dist) to /etc/ora2pg
Appending installation info to /usr/lib64/perl5/perllocal.pod
⑪ ora2pgのバージョン確認
[root@kktbt100g ora2pg-24.3]# su - ora2pg
[ora2pg@kktbt100g ~]$ ora2pg -v
Ora2Pg v24.3
[ora2pg@kktbt100g ~]$

- 参考 -

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?