Xen 3.0.4 上に domU として構築した 2 つの CentOS 4.4 にて、 Oracle 10g R1 RAC (Real Application Clusters) を インストールしてみます。
しかしまだうまくいきません。
Xen についてはこちらをご覧ください。
ディスクを5つ用意しました。
dom0 でのデバイス名/ファイル名 | 用途 | 容量 | domU に見せるデバイス名 |
/dev/Volume00/rac1 | OSをインストール | 15GB | sda1 |
/opt/rac1-swap.img | swap | 1GB | sda2 |
/dev/Volume00/racshare | 共有ディスク | 5GB | sdb1 |
ノード間で共有するものについては、 domU の設定ファイルで書き込み権限を付けるときに w ではなく w! とする必要があります。
rac1 の起動ファイルの /opt/rac1.conf はこのようにしています。
kernel = "/boot/vmlinuz-2.6.16.33-xenU" ramdisk = "/boot/initrd-2.6.16.33-xenU.img" memory = 882 name = "rac1" vif = [ 'mac=XX:YY:ZZ:1F:63:DA, bridge=xenbr0', 'mac=XX:YY:ZZ:1F:63:DB, bridge=xenbr1' ] disk = [ 'phy:Volume00/rac1,sda1,w', 'file:/opt/rac1-swap.img,sda2,w', 'phy:Volume00/racshare,sdb1,w!' ] root = "/dev/sda1 ro" extra = "4"
rac2 も同様に書いて、別々の端末ウィンドウでそれぞれ起動しておきます。
[root@centos4 opt]# xm create -c /opt/rac1.conf
[root@centos4 opt]# xm create -c /opt/rac2.conf
カーネルパラメータやユーザの設定は DB のインストールと同様です。
ネットワークは2つのNICを設定しておきます。
/etc/hosts の設定をします。 rac1 と rac2 は FQDN で書いておかないと、 OS の起動が遅くなります。
127.0.0.1 localhost localhost.localdomain 192.168.1.2 centos4 192.168.1.21 rac1 rac1.localdomain 192.168.1.22 rac2 rac2.localdomain 192.168.1.121 rac1-vip 192.168.1.122 rac2-vip 192.168.10.21 rac1-priv 192.168.10.22 rac2-priv
oracle ユーザでログインして、 SSH でお互いにパスワードなしで入れるように設定しておきます。
まず rac1 で鍵ペアを作ります。パスフレーズは空にします。
[oracle@rac1 ~]$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_dsa): Created directory '/home/oracle/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_dsa. Your public key has been saved in /home/oracle/.ssh/id_dsa.pub. The key fingerprint is: 87:81:8d:03:f9:83:ac:40:27:bc:cf:a9:54:bb:e7:94 oracle@rac1
rac2 でも作ります。
[oracle@rac2 ~]$ ssh-keygen -t dsa
公開鍵をお互いにコピーします。
[oracle@rac1 ~]$ scp .ssh/id_dsa.pub rac2:~/.ssh/authorized_keys2 The authenticity of host 'rac2 (192.168.1.22)' can't be established. RSA key fingerprint is ec:91:64:10:cc:c0:09:b2:b6:8d:6e:3f:03:cf:6b:5c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac2,192.168.1.22' (RSA) to the list of known hosts. oracle@rac2's password: id_dsa.pub 100% 601 0.6KB/s 00:00
[oracle@rac2 ~]$ scp .ssh/id_dsa.pub rac1:~/.ssh/authorized_keys2
自ホストの分も登録しておきます。
[oracle@rac1 ~]$ cd .ssh [oracle@rac1 .ssh]$ cat id_dsa.pub >> authorized_keys2
[oracle@rac2 ~]$ cd .ssh [oracle@rac2 .ssh]$ cat id_dsa.pub >> authorized_keys2
authorized_keys2 の権限を 600 にしておきます。
[oracle@rac1 ~]$ chmod 600 .ssh/authorized_keys2
[oracle@rac2 ~]$ chmod 600 .ssh/authorized_keys2
一度ログインして、すべてパスワードが不要なことを確認します。
[oracle@rac1 ~]$ ssh rac1 [oracle@rac1 ~]$ ssh rac1-priv [oracle@rac1 ~]$ ssh rac2 [oracle@rac1 ~]$ ssh rac2-priv
[oracle@rac2 ~]$ ssh rac2 [oracle@rac2 ~]$ ssh rac2-priv [oracle@rac2 ~]$ ssh rac1 [oracle@rac2 ~]$ ssh rac1-priv
これで rac1 と rac2 の間で透過的にコマンドが通るようになりました。
[oracle@rac1 ~]$ ssh rac2 hostname rac2
また、インターコネクト用の送受信バッファの設定をするため、 /etc/sysctl.conf に追記します。
net.core.rmem_max = 262144 net.core.wmem_max = 262144 net.core.rmem_default = 262144 net.core.wmem_default = 262144
これは sysctl -p で有効にします。
/dev/sdb1 を共有ディスクとして使います。 rac1 と rac2 の両方で作業を行います。
まず、selinux が無効になっていることを 確認してください。/etc/selinux/config です。
必要なツールをダウンロードしてきます。最新版は http://oss.oracle.com/projects/ocfs2-tools/ で確認できます。
[root@rac1 ~]# wget http://oss.oracle.com/projects/ocfs2-tools/dist/files/RedHat/RHEL4/i386/1.2.2-1/ocfs2-tools-1.2.2-1.i386.rpm [root@rac1 ~]# wget http://oss.oracle.com/projects/ocfs2-tools/dist/files/RedHat/RHEL4/i386/1.2.2-1/ocfs2-tools-debuginfo-1.2.2-1.i386.rpm [root@rac1 ~]# wget http://oss.oracle.com/projects/ocfs2-tools/dist/files/RedHat/RHEL4/i386/1.2.2-1/ocfs2-tools-devel-1.2.2-1.i386.rpm [root@rac1 ~]# wget http://oss.oracle.com/projects/ocfs2-tools/dist/files/RedHat/RHEL4/i386/1.2.2-1/ocfs2console-1.2.2-1.i386.rpm
依存するパッケージをインストールします。
[root@rac1 ~]# yum install e2fsprogs-devel glib2-devel vte pygtk2
これらがインストールできたら、OCFS2のツールもすんなり入ります。
[root@rac1 ~]# rpm -Uvh ocfs2* Preparing... ########################################### [100%] 1:ocfs2-tools ########################################### [ 25%] 2:ocfs2-tools-debuginfo ########################################### [ 50%] 3:ocfs2-tools-devel ########################################### [ 75%] 4:ocfs2console ########################################### [100%]
rac2 でも同様にインストールします。
ocfs2console でクラスタの設定を行うのですが、 うまくいきませんでした。 /etc/ocfs2/cluster.conf を自分で書きます。 ネットワークはインターコネクト側(eth1)を指定します。
cluster: node_count = 2 name = ocfs2 node: ip_port = 7777 ip_address = 192.168.10.21 number = 0 name = rac1 cluster = ocfs2 node: ip_port = 7777 ip_address = 192.168.10.22 number = 1 name = rac2 cluster = ocfs2
起動時に有効になるように設定します。
[root@rac1 ~]# /etc/init.d/o2cb configure Configuring the O2CB driver. This will configure the on-boot properties of the O2CB driver. The following questions will determine whether the driver is loaded on boot. The current values will be shown in brackets ('[]'). Hitting <ENTER> without typing an answer will keep that current value. Ctrl-C will abort. Load O2CB driver on boot (y/n) [n]: y Cluster to start on boot (Enter "none" to clear) [ocfs2]: Specify heartbeat dead threshold (>=7) [7]: Writing O2CB configuration: OK Loading module "configfs": OK Mounting configfs filesystem at /sys/kernel/config: OK Loading module "ocfs2_nodemanager": OK Loading module "ocfs2_dlm": OK Loading module "ocfs2_dlmfs": OCFS2 User DLM kernel interface loaded OK Mounting ocfs2_dlmfs filesystem at /dlm: OK Starting O2CB cluster ocfs2: OK
rac2 でも同様に設定して、一度 OS を再起動します。
起動したら、ocfs2console を起動します。
[root@rac1 ~]# export DISPLAY=192.168.1.2:0 [root@rac1 ~]# ocfs2console
にて、/dev/sdb1 をフォーマットします。
フォーマットできたら、mount するために /etc/fstab に1行追加します。 /u02 は空のディレクトリを作っておきます。
/dev/sdb1 /u02 ocfs2 _netdev 0 0
[root@rac1 ~]# mount /u02 (3053,0):ocfs2_initialize_super:1326 max_slots for this device: 4 (3053,0):ocfs2_fill_local_node_info:1019 I am node 0 (3053,0):__dlm_print_nodes:377 Nodes in my domain ("624F813F3D9740B8BD65980A43C3BCC3"): (3053,0):__dlm_print_nodes:381 node 0 (3053,0):ocfs2_find_slot:267 taking node slot 0 ocfs2: Mounting device (8,17) on (node 0, slot 0) with ordered data mode. [root@rac1 ~]# df /u02 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 5120000 268280 4851720 6% /u02
rac2 でも同様に mount して、ファイルが共有できていることを確認します。
[root@rac1 u02]# cd /u02 [root@rac1 u02]# ls lost+found [root@rac1 u02]# dd if=/dev/zero of=sharedfile bs=1M count=1 1+0 records in 1+0 records out
[root@rac2 u02]# cd /u02 [root@rac2 u02]# ls -l
total 1028
drwxr-xr-x 2 root root 4096 Feb 4 15:18 lost+found -rw-r--r-- 1 root root 1048576 Feb 4 15:28 sharedfile
以上で OCFS2 の設定が完了です。
いま /u02 は root でしか書き込めないので、 oracle ユーザで書き込めるディレクトリを作っておきます。
[root@rac1 ~]# mkdir /u02/crs/ [root@rac1 ~]# chown oracle:oinstall /u02/crs/
rac1 にて、CRS (Cluster Ready Service) をインストールします。 まずはソフトウェアを展開します。
[oracle@rac1 ~]$ gunzip ship.crs.lnx32.cpio.gz [oracle@rac1 ~]$ mkdir CRS [oracle@rac1 ~]$ cd CRS [oracle@rac1 CRS]$ cpio -idmv < ../ship.crs.lnx32.cpio
192.168.1.2 の X を使って、そちらに画面を飛ばす設定をします。 192.168.1.2 側では xhost + しておきます。
[oracle@rac1 CRS]$ export DISPLAY=192.168.1.2:0 [oracle@rac1 CRS]$ export LANG=ja_JP.eucJP
runInstaller を起動します。
[oracle@rac1 CRS]$ Disk1/runInstaller
注意点は下記の通りです。
(root.sh でエラーになる)