やっぱり Oracle8i が動くかどうかが重要でしょう。
Oracleが動かなければOSにあらず、 みたいな奴も多いしね (いるのかそんな奴)。
FreeBSDのハンドブックには 8.0.5 のインストール方法は載っているけど、 最近の主流である Oracle8i ( Oracle 8.1.6 ) では全然インストール方法がかわっているため通用しません。
まぁ、すべての元凶はあのインストーラのせいなんだけど。
Oracle8.1.6 を FreeBSD 4.2-RELEASE で動かすことを目的とします。
もちろん、Oracle社から正式な製品はリリースされていません。 しかし、FreeBSDにはLinuxエミューレーションがあります。 こいつを使って、何とか動かして見ようと試みるわけですね。
ここの内容を見てOracleに問い合わせてもたぶん意味は無いと思います。 がFreeBSD版のOracleをリリースしてくれというのは凄い意味があることです。 行動あるのみです。
ちなみにFreeBSDでLinuxのバイナリを動作させることを Linuxエミュレーションと呼ぶのは正確には正しくないそうです (FreeBSDハンドブックより)。 が、ここではとおりを良くするためにこの用語を使っています。御了承ください。
マシン名 | jetworld |
IPアドレス | 192.168.100.10 |
CPU | Celeron400MHz |
RAM | 128Mbyte |
HDD | 20Gbyte |
OS | FreeBSD 4.2 Release |
Oracleのインストールは長い道のりです。 まずはインストール前にいろいろとやることがあります。 くじけずがんばろう。
インストールするためのファイルを準備します。 Linuxエミュレーションを使うのでLinux環境を整えるためのファイルも必要です。
portsからlinux-baseとlinux_devtoolsをインストールします。 多くの人はlinux_baseをFreeBSDインストール時にインストールしているはずなので、 linux_devtoolsをインストールするだけで済むでしょう。 といっても結構大変かな。
linux_baseがインストールされているかどうかは pkg_infoコマンドで確認できる。
tokuda@jetworld{107}> pkg_info|grep linux linux-jdk-1.2.2 Blackdown Linux Java Developers Kit 1.2.2 linux_base-6.1 The base set of packages needed in Linux mode tokuda@jetworld{108}>
linux_baseが組み込まれているかどうかはkldstatを実行すると確認できる。
tokuda@jetworld{114}> kldstat Id Refs Address Size Name 1 2 0xc0100000 29738c kernel 2 1 0xc0af1000 11000 linux.ko tokuda@jetworld{115}>
linux.koと表示されればOK。/etc/rc.confにlinux_enable="YES" と書いておけばブート時にlinux_baseが組み込まれます。
linux_devtoolsをインストールします。 portsからインストールした様子は次のとおり。
tokuda@jetworld{109}> cd /usr/ports/devel/linux_devtools/ tokuda@jetworld{111}> su Password: <--- rootのパスワードを入力 jetworld# make install
Oracleのインストーラが/etc/mtabをチェックするらしいので、 とりあえず/etc/fstabをコピーしておきましょう。 この作業を行わないとインストーラが落ちます。
jetworld# cp /etc/fstab /compat/linux/etc/mtab jetworld#
Oracleの製品にもJREが含まれていますが、 このJREはFreeBSDではうまく動きません。 ということで、BlackdownのJREをインストールし、 OracleのJREに見せかける作業を行います。
Blackdownのサイトからjre118_v3-glibc-2.1.3.tar.bz2をダウンロードして、 インストールします。インストール先は/compat/linux/usrとします。
tokuda@jetworld{116}> su Password: jetworld# cd /compat/linux/usr/ jetworld# tar --bzip2 -xvf /tmp/jre118_v3-glibc-2.1.3.tar.bz2
Oracleのインストーラで利用されるJREを置き換えるため、 Blackdown版とは構成の違う JREのファイル構成をシンボリックによって解消します。
rootでの作業です jetworld# cd /compat/linux/usr/jre118_v3/ jetworld# ln -s . linux jetworld#
Oracleのインストーラがarchというコマンドを呼び出すのですが、 Linux環境には含まれていません。しかたがないので archといういい加減きわまりないシェルスクリプトを作ります。
rootでの作業です jetworld# echo echo i686 > /compat/linux/bin/arch jetworld# chmod +x /compat/linux/bin/arch
Oracleを実行するためのユーザとグループを作成します。
/etc/groupを編集し、dbaグループを作成します。 /etc/groupのサンプルを次に示します。
# $FreeBSD: src/etc/group,v 1.19 1999/08/27 23:23:41 peter Exp $ # wheel:*:0:root,tokuda daemon:*:1:daemon kmem:*:2:root sys:*:3:root tty:*:4:root operator:*:5:root mail:*:6: bin:*:7: news:*:8: man:*:9: games:*:13: staff:*:20:root guest:*:31:root bind:*:53: uucp:*:66: xten:*:67:xten dialer:*:68: network:*:69: nogroup:*:65533: nobody:*:65534: dba:*:1000:
vipwなどを利用して/etc/passwdにoracleというユーザを作成します。
ホームディレクトリは/usr/oracleとし、 ログインシェルは/compat/linux/bin/bashとします。 /etc/passwdのoracleユーザに関するエントリの例を次に示します。
oracle::2000:1000::0:0:OracleUser:/usr/oracle:/compat/linux/bin/bash
vipwでユーザを作成した場合には/usr/oracleを作成し、 パーミッションを変更します。
rootでの作業です jetworld# mkdir /usr/oracle jetworld# chown oracle:dba /usr/oracle
ここからOracleユーザで作業を行います。 ここからはlocalhostにtelnetして作業している例を示します。
また、とくに断りがない限りoracleユーザで作業を行っています。
/usr/oracleに816ee-trial.tar.gzコピーし、展開する例を次に示します。
[oracle@jetworld oracle]$ cd /usr/oracle [oracle@jetworld oracle]$ tar xvzf 816ee-trial.tar.gz
.profileを編集してログインしなおして環境を反映させます。 envコマンドを実行して環境変数を確認しておきます。
ORACLE_BASE=/usr/oracle; export ORACLE_BASE ORACLE_HOME=/usr/oracle/product/8.1.6; export ORACLE_HOME LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH ORACLE_SID=ORCL; export ORACLE_SID PATH=/compat/linux/bin:/compat/linux/sbin:/compat/linux/usr/bin:/compat/linux/usr/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:$ORACLE_HOME/bin export PATH LANG=ja_JP.EUC export LANG
FreeBSDで動かすためにいくつかのスクリプトを修正する必要があります。
インストーラがJREのnativeスレッドを使う部分を greenスレッドを使うように修正します。
[oracle@jetworld Oracle8iR2]$ cd /usr/oracle/Oracle8iR2 [oracle@jetworld Oracle8iR2]$ cp runInstaller runInstaller.org [oracle@jetworld Oracle8iR2]$ vi runInstaller
34行目のTHREAD_FLAG=nativeをTHREAD_FLAG=greenに変更する。
[oracle@jetworld install]$ cd /usr/oracle/Oracle8iR2/install [oracle@jetworld install]$ cp oraparam.ini oraparam.ini.org [oracle@jetworld install]$ vi oraparam.ini五行目のJRE_LOCATIONをBlackdownのJREのディレクトリに変更する。
BEFORE: JRE_LOCATION=../stage/Components/oracle.swd.jre/1.1.8/1/DataFiles/Expanded AFTER: JRE_LOCATION=/compat/linux/usr/jre118_v3
いよいよインストーラの実行です。./runInstallerで実行しましょう。
[oracle@jetworld install]$ cd /usr/oracle/Oracle8iR2 [oracle@jetworld Oracle8iR2]$ ./runInstaller
各画面での入力は次のとおりです。
----------------------------------- File Locations Source... Path: /usr/local/Oracle8iR2/stage/products.jar Distination... Path: /usr/oracle/product/8.1.6 -----------------------------------
[Next]を押します。
----------------------------------- UNIX Group Name UNIX Group Name: dba -----------------------------------
[Next]を押します。
orainsRoot.shを実行しろというダイアログが出るので、 なにもボタンを押さずに別のウィンドウのshellでrootになり orainsRoot.shを実行します。
rootの作業です jetworld# cd /usr/oracle jetworld# ./orainstRoot.sh Creating Oracle Inventory pointer file (/etc/oraInst.loc) Changing groupname of /usr/oracle/oraInventory to dba. jetworld#
実行を確認後、ダイアログの[Retry]を押します。
次に、インストールする製品を選びます。 当然Oracle8i Enterprise Editionを選びましょう。
----------------------------------- Available Products Select a product to install ● Oracle8i Enterprise Edition 8.1.6.1.0 ○ Oracle8i Client 8.1.6.0.0 -----------------------------------
Oracle8i Enterprise Edition 8.1.6.1.0にチェックをし[Next]を押します。
次にインストールのタイプを選択します。 深く考えずにTypicalを選択します。 初期データベースは結果的に作成されないので気にしなくてかまいません。
----------------------------------- Installation Types Oracle8i Enterprise Edition 8.1.6.1.0 What type of installation do you want for Oracle8i Enterprise Edition 8.1.6.1.0? ●Typical (540MB) ○Minimal (455MB) ○Custom -----------------------------------
データベース名を決める画面になります。SIDとあわせてORCLにします。
----------------------------------- Database Identification Global Database Name: ORCL SID: ORCL -----------------------------------
ORCLデータベース関係のファイルを置く場所を指定します。
----------------------------------- Database File Location Directory for Database File: /usr/oracle/orcl -----------------------------------
これで事前に指定する項目が終了したので、 サマリ画面が表示され、インストールされる内容が表示されます。 いよいよインストール (ファイルの書き込み) が開始されます。
----------------------------------- Summary Oracle8i Enterprise Edition 8.1.6.1.0 -----------------------------------
[Install] を押すとインストール画面になり、 ファイルのコピーが始まります。
----------------------------------- Install -----------------------------------
ファイルコピー中に次のようなダイアログが表示されます。
----------------------------------- Setup Privileges A Configuration script needs to be run as root before installation can proceed. Please leave this window up, go run /usr/oracle/product/8.1.6/root.sh as root from another window, then come back here and cleck OK to continue. -----------------------------------
root で /usr/oracle/root.shを実行させますが、 その前にroot.shを修正する必要があります。
修正行は27行, 33行, 34行, 246行, 248行です。 それぞれFreeBSDに存在するコマンドのパスに変更します。
27 CHOWN=/usr/sbin/chown 33 AWK=/usr/bin/awk 34 SED=/usr/bin/sed 246 CHOWN="/usr/sbin/chown" 248 TEST="/bin/test"
root.shを実行するとoraenv, coraenv コマンドをインストールするディレクトリを指定する質問があります。 /usr/local/binがデフォルト値として表示されているので そのままリターンを押せばOK。
jetworld# ./root.sh Running Oracle8 root.sh script... \nThe following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /usr/oracle/product/8.1.6 ORACLE_SID= ORCL Enter the full pathname of the local bin directory: [/usr/local/bin]: \c Entry will be added to the /etc/oratab file by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. IMPORTANT NOTE: Please delete any log and trace files previously created by the Oracle Enterprise Manager Intelligent Agent. These files may be found in the directories you use for storing other Net8 log and trace files. If such files exist, the OEM IA may not restart. jetworld#
ダイアログに戻り[OK]を押します。
インストール作業が継続され、設定ツールによる自動設定が始まります。
----------------------------------- Configuration Tool The following tools will be automatically started for you: These tools are optinal. It is recommended, although not required, that these tools be run successfully. -----------------------------------
Net8 Configuration Assistantは成功するものの、 Oracle Database Configuration Assistantは失敗してしまいます。 次のようなダイアログが表示されるはずです。
----------------------------------- One or more tools have failed. It is recommended but not required that these tools succeed for this installation. You can now select these tools, read its details to examine why they failed, fix those problems, and retry them. Or, you can click "Next" to continue. -----------------------------------
あとから自分でデータベースをAssistantに頼らず手動で作るのでfail のままで問題ありません。failの原因はJREがSIGSEGVで死んだということらしいので、 Oracleのデータベース機能そのものに影響はないと思われますし。
Errorダイアログに対して [OK] を押し、Configuration Toolsの画面で [Next] を押します。
ついにインストールが完了です。ということで、 インストール終了画面が表示されますね。
----------------------------------- End of Installation The installation of Oracle8i Enterprise Edition was successful, but some optinal configuration tools failed or were cancelled -----------------------------------
これ以上インストールする物がないので、 [Exit] を押し、確認画面が出るので[Yes]を押します。
インストールが無事完了したものの、データベースが動いていません。 ここでは、非常に小さいデータベースを作成し、機能の確認を行います。
まずはカーネルの再構築です。 これを行わないとOracleは起動しません。
jetworld# cd /usr/src/sys/i386/conf/ jetworld# vi JETWORLD
カーネルコンフィギュレーションファイルに次の記述があるか確認し、 なければ追加しておきます。
options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues options SYSVSEM #SYSV-style semaphores
次にシェアードメモリ関係のパラメータを追加します。 今回追加した例は次のとおりです。
options SHMMAXPGS=10000 options SHMMNI=100 options SHMSEG=10 options SEMMNS=200 options SEMMNI=70 options SEMMSL=61
カーネルを再構築し、リブートします。
テストのために小さなデータベースを構築します。
データベース名はORCLでSIDもORCLです。demoというユーザを作成し、 そこにテーブルなどを作ります。
データベースORCL関係のファイルを/usr/oracle/orclに置くことにします。
それにともなって必要なディレクトリを作成します。
[oracle@jetworld oracle]$ cd /usr/oracle [oracle@jetworld oracle]$ mkdir orcl [oracle@jetworld oracle]$ cd orcl [oracle@jetworld orcl]$ mkdir ddl data pfile archive bdump cdump udump [oracle@jetworld orcl]$
スクリプトファイルddl.tar.gzをダウンロードし、 /usr/oracle/orclに置き、展開します。
[oracle@jetworld orcl]$ cd /usr/oracle/orcl [oracle@jetworld orcl]$ tar xvzf ddl.tar.gz
ddlディレクトリに移動し、順にスクリプトを実行します。 ただし、07cr_tbl.sqlはまだ実行しません。
[oracle@jetworld ddl]$ sh ./01crdb.sh Oracle Server Manager Release 3.1.6.0.0 - Production Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved. Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SVRMGR> SVRMGR> Connected. SVRMGR> ORACLE instance started. Total System Global Area 25575408 bytes Fixed Size 69616 bytes Variable Size 24608768 bytes Database Buffers 819200 bytes Redo Buffers 77824 bytes SVRMGR> SVRMGR> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> Statement processed. SVRMGR> SVRMGR> Disconnected. SVRMGR> SVRMGR> Server Manager complete. [oracle@jetworld ddl]$
この調子で02crdb.sh, 03crdb.sh, 05crtblsp.sh, 06cruser.sh を実行しましょう。
[oracle@jetworld ddl]$ sh ./02crdb.sh ... 中略 ... [oracle@jetworld ddl]$ sh ./03crdb.sh ... 中略 ... [oracle@jetworld ddl]$ sh ./05crtblsp.sh ... 中略 ... [oracle@jetworld ddl]$ sh ./06cruser.sh
SQL*Plusでテーブルを作成します。 ここではdemoというユーザで接続してdemoユーザ用に T_GIJIというテーブルを作成しています。
[oracle@jetworld ddl]$ sqlplus SQL*Plus: Release 8.1.6.0.0 - Production on Fri Feb 23 00:42:11 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Enter user-name: demo Enter password: <---- demoと入力する Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SQL> @07cr_tbl.sql DROP TABLE T_GIJI CASCADE CONSTRAINTS * ERROR at line 1: ORA-00942: table or view does not exist Table created. Table altered. SQL>
上の実行結果ではエラーが表示されていますが、 このエラーは気にする必要がありません。 これはテーブルT_GIJIを作成する前に同名の古いテーブルT_GIJI があったら消す処理を書いてあるため起こります。 今回は当然初めて実行するので古いテーブルT_GIJI が存在しないのでエラーになっているというわけです。
[oracle@jetworld admin]$ svrmgrl Oracle Server Manager Release 3.1.6.0.0 - Production Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved. Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SVRMGR> connect internal Connected. SVRMGR> shutdown normal Database closed. Database dismounted. ORACLE instance shut down. SVRMGR> quit Server Manager complete. [oracle@jetworld admin]$
無事に止まったら次に進みますが、 処理が途中で固まった場合には、他のターミナルを開き、 svrmgrlを起動し、internal接続しshutdown abortで強制的に終了させましょう。
さて、initORCL.oraの編集を行います。
[oracle@jetworld admin]$ vi /usr/oracle/orcl/pfile/initORCL.ora
修正箇所は5行目のrollback_segmentsのコメントを外すだけです。
修正前: #rollback_segments = (rbs01, rbs02, rbs03, rbs04) 修正後: rollback_segments = (rbs01, rbs02, rbs03, rbs04)
ロールバックセグメントを修正したらOracleを再起動しましょう。 svrmgrlを起動し、internalで接続し、startupコマンドを実行します。 実行例を次に示します。
[oracle@jetworld admin]$ svrmgrl Oracle Server Manager Release 3.1.6.0.0 - Production Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved. Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SVRMGR> connect internal Connected. SVRMGR> startup pfile=/usr/oracle/orcl/pfile/initORCL.ora ORACLE instance started. Total System Global Area 25575408 bytes Fixed Size 69616 bytes Variable Size 24608768 bytes Database Buffers 819200 bytes Redo Buffers 77824 bytes Database mounted. Database opened. SVRMGR> quit Server Manager complete. [oracle@jetworld admin]$
無事起動したら次に進みましょう。
Net8の設定を行うために
の三つのファイルが必要です。これらのファイルを /usr/oracle/product/8.1.6/network/adminにコピーします。
もし他のマシンで利用する場合には、 Oracleを動かすIPアドレスとドメイン名を修正する必要があるでしょう。
listenerを起動するためにはlsnrctlコマンドを使います。
lsnrctl startで起動、lsnrctl stopで停止です。lsnrctl statusで listenerの状態を表示します。
lsnrctl startを実行した時の例を次に示します。
[oracle@jetworld admin]$ lsnrctl start LSNRCTL for Linux: Version 8.1.6.0.0 - Production on 24-FEB-2001 01:52:48 (c) Copyright 1998, 1999, Oracle Corporation. All rights reserved. Starting /usr/oracle/product/8.1.6/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 8.1.6.0.0 - Production System parameter file is /usr/oracle/product/8.1.6/network/admin/listener.ora Log messages written to /usr/oracle/product/8.1.6/network/log/listener.log Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.10)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.10)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 8.1.6.0.0 - Production Start Date 24-FEB-2001 01:52:49 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security OFF SNMP OFF Listener Parameter File /usr/oracle/product/8.1.6/network/admin/listener.ora Listener Log File /usr/oracle/product/8.1.6/network/log/listener.log Services Summary... ORCL has 1 service handler(s) The command completed successfully [oracle@jetworld admin]$
listenerが起動したので、Net8経由でOracleに接続してみましょう。
demoというユーザ名とdemoというパスワードでTNSNAMEがORCLなので sqlplus demo/demo@ORCLと入力すればNet8経由でOracleに接続します。 実行例を次に示します。
[oracle@jetworld admin]$ sqlplus demo/demo@ORCL SQL*Plus: Release 8.1.6.0.0 - Production on Sat Feb 24 01:54:43 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SQL>
先程作成したT_GIJIというテーブルにデータをINSERTしてみましょう。
SQL> INSERT INTO T_GIJI VALUES ('001','test_t','test_a','test_c'); 1 row created.
うまくINSERTされたか確認してみましょう。
SQL> SELECT * FROM T_GIJI; ID TITLE AUTHOR CONTENTS ----- ------------------------ ------------ -------------------------------- 001 test_t test_a test_c
これでOKですね。
しかし、日本語のデータは化けてしまいます。 これは環境変数NLS_LANGが設定されていないからです。
NLS_LANGを設定するためには一旦SQL*Plusを終了し (quit)、 環境変数を設定します。
この環境変数は.profileに書いておくべきでしたね。
NLS_LANGは次のようにして設定します。
[oracle@jetworld oracle]$ NLS_LANG=Japanese_Japan.JA16SJIS [oracle@jetworld oracle]$ export NLS_LANG
kterm + kinput2 を使った場合、SQL*Plusでは 日本語がうまく入力できなかったので、 次のようなファイルをEUCコードで作成します (jp.sqlとします)。
INSERT INTO T_GIJI VALUES ('12', 'てすと', 'てすと', 'てすと');
ファイルを作成したらSQL*PlusでこのSQL文を実行させます。
[oracle@jetworld oracle]$ sqlplus demo/demo@ORCL SQL*Plus: Release 8.1.6.0.0 - Production on y Feb 24 13:01:56 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SQL> @jp.sql 1 row created. SQL> SELECT * FROM T_GIJI; ID TITLE AUTHOR CONTENTS ----- ------------------------ ------------ -------------------------------- 12 てすと てすと てすと SQL>
これで日本語もうまくいきました。
Oracle8iであるOracle8.1.6をFreeBSD 4.2 RELEASE で動作させることができました。
いくつかのユーティリティが動作しないという点で完全ではないのですが、 Javaの実行環境でのエラーが原因のものばかりなので Oracleのデータベース機能はきちんと動作していると思われます。
ここではOracleの持つさらに細かい機能や性能に付いてはふれていません。 これらの点についてさらに検証が必要となるでしょう。
$Lastupdate: Mon Mar 18 02:30:30 2002 $