「Samba 3.2 のクラスタ機能検証手順」の版間の差分

提供:Samba-JP
ナビゲーションに移動検索に移動
680行目: 680行目:
5039 ? SN 0:00 /usr/sbin/smbd -D
5039 ? SN 0:00 /usr/sbin/smbd -D
5200 pts/0 S+ 0:00 grep mbd
5200 pts/0 S+ 0:00 grep mbd
</pre>

<pre>
samba32a:/etc/samba# smbpasswd -a local
New SMB password:
Retype new SMB password:
Added user local.
samba32a:/etc/samba#
</pre>
</pre>



2008年10月6日 (月) 23:54時点における版

Samba 3.2 系列の新機能の一つにクラスタ機能があります。

以下、Debian 開発版(コードネーム lenny)を用いた、クラスタ機能の検証手順を解説します。

なお、lenny を用いた理由は、検証に必要なパッケージがすべてデフォルトで用意されているためです。

検証環境は、メモリ 128MB の VMware 仮想マシンです。

iscsi ターゲットの作成

クラスタ機能を利用するには、共有ディスクが必要です。

Samba のクラスタ機能は、共有ディスクの実装に依存しませんが、比較的手軽にできる共有ディスクとして、ここでは iSCSI のターゲットを動作させることにします。

以下、 base-system のインストールのみを行った lenny を前提として手順を紹介します。

/etc/apt/sources.list は

iscsi1:~# cat /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian lenny main
deb http://security.debian.org/ lenny/updates main

のように設定しています。

  • telnetd のインストール
リモートマシンから設定を行うため、「telnetd」をインストールしました。なお ssh にしなかったのは、インストールするパッケージを最低限にしたかったためです。
iscsi1:~# apt-get install telnetd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  openbsd-inetd
The following NEW packages will be installed:
  openbsd-inetd telnetd
0 upgraded, 2 newly installed, 0 to remove and 101 not upgraded.
Need to get 0B/75.5kB of archives.
After this operation, 238kB of additional disk space will be used.
Do you want to continue [Y/n]?
Selecting previously deselected package openbsd-inetd.
(Reading database ... 11668 files and directories currently installed.)
Unpacking openbsd-inetd (from .../openbsd-inetd_0.20080125-1_i386.deb) ...
Selecting previously deselected package telnetd.
Unpacking telnetd (from .../telnetd_0.17-36_i386.deb) ...
Processing triggers for man-db ...
Setting up openbsd-inetd (0.20080125-1) ...
Stopping internet superserver: inetd.
Not starting internet superserver: no services enabled.
Setting up telnetd (0.17-36) ...
Adding user telnetd to group utmp
  • 作業用ユーザの作成
telnetでログインするために、「local」というユーザーを作成しました。
iscsi1:~# useradd -u 501 -m local
iscsi1:~# passwd local
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
  • ホスト名の設定
ここではホスト名を「iscsi1」に設定しました。
echo iscsi1 > /etc/hostname
  • IP アドレスの設定
検証だけなら DHCP でも動作しますが、ここでは一応 192.168.135.20 というアドレスを付与しました。
 # The loopback network interface
 auto lo
 iface lo inet loopback
 
 # The primary network interface
 auto eth0
 #iface eth0 inet dhcp
 iface eth0 inet static
         address 192.168.135.20
         netmask 255.255.255.0
         network 192.168.135.0
       broadcast 192.168.135.255
         gateway 192.168.135.2
  • 再起動
IP アドレスの設定などを反映させるため、一度再起動します。
実際には、再起動しなくても設定の反映はできますが、気持ち悪いので……
  • パッケージのインストール
iscsitarget-modules-xxx および iscsitarget パッケージをインストールします。
iscsi1:~# apt-get install iscsitarget
(エラーで終了しますが、インストールはできています)
iscsi1:~# apt-get install iscsitarget-modules-2.6.26-1-686
Reading package lists... Done
Building dependency tree
Reading state information... Done
iscsitarget is already the newest version.
The following extra packages will be installed:
  linux-image-2.6.26-1-686
Suggested packages:
  linux-doc-2.6.26
The following NEW packages will be installed:
  iscsitarget-modules-2.6.26-1-686 linux-image-2.6.26-1-686
0 upgraded, 2 newly installed, 0 to remove and 101 not upgraded.
Need to get 20.1MB of archives.
After this operation, 57.4MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.jp.debian.org lenny/main linux-image-2.6.26-1-686 2.6.26-5 [20.
1MB]
Get:2 http://ftp.jp.debian.org lenny/main iscsitarget-modules-2.6.26-1-686 2.6.2
6+0.4.16+svn162-4 [37.5kB]
Fetched 20.1MB in 16s (1250kB/s)
Preconfiguring packages ...
Selecting previously deselected package linux-image-2.6.26-1-686.
(Reading database ... 11705 files and directories currently installed.)
Unpacking linux-image-2.6.26-1-686 (from .../linux-image-2.6.26-1-686_2.6.26-5_i
386.deb) ...
Done.
Selecting previously deselected package iscsitarget-modules-2.6.26-1-686.
Unpacking iscsitarget-modules-2.6.26-1-686 (from .../iscsitarget-modules-2.6.26-
1-686_2.6.26+0.4.16+svn162-4_i386.deb) ...
Setting up linux-image-2.6.26-1-686 (2.6.26-5) ...
Running depmod.
Running mkinitramfs-kpkg.
Running postinst hook script update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.26-1-686
Found kernel: /boot/vmlinuz-2.6.24-1-686
Updating /boot/grub/menu.lst ... done

Setting up iscsitarget-modules-2.6.26-1-686 (2.6.26+0.4.16+svn162-4) ...
iscsi1:~#
  • 再起動の実行
ここで、ホスト名の変更の反映、カーネルモジュールの組み込みなどを行うために、一度再起動を実行します。
  • ループバックデバイスの作成
以下のようにして、イメージファイルを作成の上、ループバックデバイスを作成します。なお、再起動するたびにループバックデバイスの構成を行う必要があります。
※うまく自動化する方法あるんでしょうか?
iscsi1:~# dd if=/dev/zero of=/var/lib/iscsi1.img bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 3.21413 s, 167 MB/s
iscsi1:~# losetup /dev/loop0 /var/lib/iscsi1.img
iscsi1:~# losetup -a
/dev/loop0: [0301]:98270 (/var/lib/iscsi1.img)
/dev/loop/0: [0301]:98270 (/var/lib/iscsi1.img)
これで、/dev/loop0 に 512MB の仮想パーティションが存在することになりました。実際に存在するパーティションを用いる場合、この作業は省略できます。
  • /etc/ietd.conf を編集します
ここでは、必要最低限の設定として、認証なしで、今作成したループバックデバイスを公開する設定を行います。各パラメータの詳細については、ietd.conf(5) などを参照してください。
Target iqn.2008-09.com.monyo:iscsi1
    Lun 0 Path=/dev/loop0,Type=fileio
    MaxConnections 1
  • iscsitarget の再起動
iscsitarget サービスの再起動を行い、設定を反映します。
iscsi1:~# /etc/init.d/iscsitarget stop
Removing iSCSI enterprise target devices: succeeded.
Stopping iSCSI enterprise target service: succeeded.
Removing iSCSI enterprise target modules: succeeded.
iscsi1:~# /etc/init.d/iscsitarget start
Starting iSCSI enterprise target service: succeeded.

Samba サーバ1の構築

引き続き、Samba サーバを構築します。

同じく、base-system のインストールのみを行った lenny から構築する方法を紹介します。

  • telnetd のインストール
  • 作業用ユーザの作成
  • ホスト名の設定
ここではホスト名を「samba32a」に設定しました。
echo samba32a > /etc/hostname
  • IP アドレスの設定
検証だけなら DHCP でも動作しますが、ここでは一応 192.168.135.21 というアドレスを付与しました。
  • 再起動
IP アドレスの設定などを反映させるため、一度再起動します。
実際には、再起動しなくても設定の反映はできますが、気持ち悪いので……
  • iSCSI / gfs / Samba 関連パッケージのインストール
以下、順次パッケージのインストールを行っていきます。
クラスタファイルシステムとしては、gfs を用いました。gfs は依存パッケージが多いので、できれば ocfs2 でやりたかったんですが、ocfs2 自体の構築はできたものの、ctdb が「」というエラーでファイルのロックに失敗してしまうため、あきらめました。
samba32a:~# apt-get install open-iscsi
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  open-iscsi
0 upgraded, 1 newly installed, 0 to remove and 101 not upgraded.
Need to get 540kB of archives.
After this operation, 1315kB of additional disk space will be used.
Get:1 http://ftp.jp.debian.org lenny/main open-iscsi 2.0.869.2-2.1 [540kB]
Fetched 540kB in 1s (279kB/s)
Selecting previously deselected package open-iscsi.
(Reading database ... 11687 files and directories currently installed.)
Unpacking open-iscsi (from .../open-iscsi_2.0.869.2-2.1_i386.deb) ...
Processing triggers for man-db ...
Setting up open-iscsi (2.0.869.2-2.1) ...
Starting iSCSI initiator service: iscsid.
Setting up iSCSI targets:
iscsiadm: No records found!
.
Mounting network filesystems:.
samba32a:~# apt-get install gfs-tools cman clvm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  binutils bochsbios debootstrap dpkg file gfs2-tools libasound2 libbrlapi0.5
  libcman2 libdb4.5 libdevmapper1.02.1 libdirectfb-1.0-0 libdlm2 libgnutls26
  libicu38 libmagic1 libnet-snmp-perl libnet-telnet-perl libnspr4-0d
  libnss3-1d libopenais2 libpcap0.8 libsdl1.2debian libsdl1.2debian-alsa
  libsqlite3-0 libsvga1 libsysfs2 libts-0.0-0 libvdemgmt0 libvdeplug2 libvirt0
  libx86-1 libxenstore3.0 libxml2 linux-image-2.6.26-1-486 lvm2 lzma
  mime-support openais openbios-sparc openhackware perl perl-base perl-doc
  perl-modules proll psmisc python python-minimal python2.5 python2.5-minimal
  qemu redhat-cluster-modules-2.6.26-1-486 sgml-base sharutils svgalibg1 vde2
  vgabios xml-core
Suggested packages:
  binutils-doc libasound2-plugins gnutls-bin libcrypt-des-perl
  libdigest-hmac-perl libdigest-sha1-perl libio-socket-inet6-perl
  linux-doc-2.6.26 dmsetup libterm-readline-gnu-perl
  libterm-readline-perl-perl groff python-doc python-tk python-profiler
  python2.5-doc binfmt-support sudo samba sgml-base-doc mailx vde2-cryptcab
  kvm debhelper
Recommended packages:
  redhat-cluster-modules
The following NEW packages will be installed:
  binutils bochsbios clvm cman debootstrap file gfs-tools gfs2-tools
  libasound2 libbrlapi0.5 libcman2 libdb4.5 libdirectfb-1.0-0 libdlm2 libicu38
  libmagic1 libnet-snmp-perl libnet-telnet-perl libnspr4-0d libnss3-1d
  libopenais2 libpcap0.8 libsdl1.2debian libsdl1.2debian-alsa libsqlite3-0
  libsvga1 libsysfs2 libts-0.0-0 libvdemgmt0 libvdeplug2 libvirt0 libx86-1
  libxenstore3.0 libxml2 linux-image-2.6.26-1-486 lzma mime-support openais
  openbios-sparc openhackware perl perl-doc perl-modules proll psmisc python
  python-minimal python2.5 python2.5-minimal qemu
  redhat-cluster-modules-2.6.26-1-486 sgml-base sharutils svgalibg1 vde2
  vgabios xml-core
The following packages will be upgraded:
  dpkg libdevmapper1.02.1 libgnutls26 lvm2 perl-base
5 upgraded, 57 newly installed, 0 to remove and 96 not upgraded.
Need to get 61.1MB/72.7MB of archives.
After this operation, 196MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.jp.debian.org lenny/main perl-modules 5.10.0-14 [3192kB]
Get:2 http://ftp.jp.debian.org lenny/main perl 5.10.0-14 [4547kB]
(省略)
Setting up sgml-base (1.26) ...
Setting up xml-core (0.11) ...
samba32a:~#apt-get install samba ctdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  ethtool iproute libatm1 libcups2 libkeyutils1 libkrb53 libpopt0 libtalloc1
  libwbclient0 lsof samba-common tdb-tools ucf
Suggested packages:
  iproute-doc cups-common krb5-doc krb5-user smbldap-tools
The following NEW packages will be installed:
  ctdb ethtool iproute libatm1 libcups2 libkeyutils1 libkrb53 libtalloc1
  libwbclient0 lsof samba samba-common tdb-tools ucf
The following packages will be upgraded:
  libpopt0
1 upgraded, 14 newly installed, 0 to remove and 95 not upgraded.
Need to get 9698kB of archives.
After this operation, 25.8MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.jp.debian.org lenny/main iproute 20080725-2 [363kB]
Get:2 http://ftp.jp.debian.org lenny/main libpopt0 1.14-4 [45.9kB]
(省略)
Samba パッケージのインストール時の質問には、以下のように答えます。
* ワークグループ名: SAMBA32GFS
* WINS の設定を DHCP から取得:しない
  • 再起動
これで、2.6.26-1-486 のカーネルで起動します。
  • iSCSI イニシエータの設定:ディスクの認識
以下のようにして、ディスクの認識を行います。
samba32a:~# iscsiadm -m node --targetname iqn.2008-09.com.monyo:iscsi1 -p 192.16
8.135.20 --op new
New iSCSI node [tcp:[hw=default,ip=,net_if=default,iscsi_if=default] 192.168.135
.20,3260,-1 iqn.2008-09.com.monyo:iscsi1] added
samba32a:~# iscsiadm -m node --targetname iqn.2008-09.com.monyo:iscsi1 -p 192.16
8.135.20 -l
Logging in to [iface: default, target: iqn.2008-09.com.monyo:iscsi1, portal: 192
.168.135.20,3260]
Login to [iface: default, target: iqn.2008-09.com.monyo:iscsi1, portal: 192.168.
135.20,3260]: successful
samba32a:~# fdisk -l

Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0001c09b

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         993     7976241   83  Linux
/dev/hda2             994        1044      409657+   5  Extended
/dev/hda5             994        1044      409626   82  Linux swap / Solaris

Disk /dev/sda: 536 MB, 536870912 bytes
17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes
Disk identifier: 0x00000000

Disk /dev/sda doesn't contain a valid partition table
  • iSCSI イニシエータの設定:ディスクの自動認識
以下のようにして、再起動時に iSCSI ターゲットおよびディスクの認識が自動で行われるようにします。
samba32a:~# vi /etc/iscsi/nodes/iqn.2008-09.com.monyo\:iscsi1/192.168.135.20\,3260
以下の項目を manual から automatic に変更します。
* node.startup
* node.conn[0].startup
  • gfs の設定:/etc/hosts の設定
自身の名前解決が可能なように設定を行います。
127.0.0.1       localhost
192.168.135.21  samba32a.local samba32a

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
  • gfs の設定:/etc/cluster/cluster.conf の設定
/etc/cluster ディレクトリを作成の上、/etc/cluster/cluster.conf ファイルを以下のように作成します。
<cluster name="cluster1" config_version="3">

<cman two_node="1" expected_votes="1"/>

<clusternodes>
<clusternode name="samba32a" votes="1" nodeid="1">
        <fence>
                <method name="single">
                        <device name="manual" ipaddr="192.168.135.21"/>
                </method>
        </fence>
</clusternode>

<clusternode name="samba32b" votes="1" nodeid="2">
        <fence>
                <method name="single">
                        <device name="manual" ipaddr="192.168.135.22"/>
                </method>
        </fence>
</clusternode>
</clusternodes>

<fencedevices>
        <fencedevice name="manual" agent="fence_manual"/>
</fencedevices>

</cluster>
  • パーティションの作成
parted をインストールの上、パーティションを作成します。
samba32a:~# apt-get install parted
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libparted1.8-10
Suggested packages:
  libparted1.8-dev libparted1.8-i18n parted-doc
The following NEW packages will be installed:
  libparted1.8-10 parted
0 upgraded, 2 newly installed, 0 to remove and 95 not upgraded.
Need to get 261kB of archives.
After this operation, 569kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.jp.debian.org lenny/main libparted1.8-10 1.8.8.git.2008.03.24-9
 [197kB]
Get:2 http://ftp.jp.debian.org lenny/main parted 1.8.8.git.2008.03.24-9 [64.0kB]
Fetched 261kB in 1s (199kB/s)
Selecting previously deselected package libparted1.8-10.
(Reading database ... 19195 files and directories currently installed.)
Unpacking libparted1.8-10 (from .../libparted1.8-10_1.8.8.git.2008.03.24-9_i386.
deb) ...
Selecting previously deselected package parted.
Unpacking parted (from .../parted_1.8.8.git.2008.03.24-9_i386.deb) ...
Processing triggers for man-db ...
Setting up libparted1.8-10 (1.8.8.git.2008.03.24-9) ...
Setting up parted (1.8.8.git.2008.03.24-9) ...
samba32a:~#
samba32a:~# parted /dev/sda
GNU Parted 1.8.8
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
Warning: The existing disk label on /dev/sda will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
New disk label type?  [gpt]?
(parted) mkpart primary
File system type?  [ext2]? ext3
Start? 0
End? 512MB
(parted) p
Model: IET VIRTUAL-DISK (scsi)
Disk /dev/sda: 537MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name     Flags
 1      17.4kB  512MB  512MB               primary

(parted) q
Information: You may need to update /etc/fstab.

samba32a:~#
  • gfs のフォーマット
以下のようにして、フォーマットを行います。
samba32a:~# gfs_mkfs -p lock_dlm -t cluster1:gfs -j 2 /dev/sda1
This will destroy any data on /dev/sda1.

Are you sure you want to proceed? [y/n] y

Device:                    /dev/sda1
Blocksize:                 4096
Filesystem Size:           59412
Journals:                  2
Resource Groups:           8
Locking Protocol:          lock_dlm
Lock Table:                cluster1:gfs

Syncing...
All Done
samba32a:~#

Samba サーバ2の構築

Sambaサーバ1と同様にして構築します。

同じく、base-system のインストールのみを行った lenny から構築する方法を紹介します。

  • telnetd のインストール
  • 作業用ユーザの作成
  • ホスト名の設定
ここではホスト名を「samba32b」に設定しました。
echo samba32b > /etc/hostname
  • IP アドレスの設定
検証だけなら DHCP でも動作しますが、ここでは一応 192.168.135.22 というアドレスを付与しました。
  • 再起動
IP アドレスの設定などを反映させるため、一度再起動します。
実際には、再起動しなくても設定の反映はできますが、気持ち悪いので……
  • iSCSI / gfs / Samba 関連パッケージのインストール
  • 再起動
これで、2.6.26-1-486 のカーネルで起動します。
  • iSCSI イニシエータの設定:ディスクの認識

クラスタの起動

  • cman の起動
samba32a と samba32b の両方で以下を実行します。
samba32a:~# /etc/init.d/cman start
Starting cluster manager:
 Loading kernel modules: done
 Mounting config filesystem: done
 Starting cluster configuration system: done
 Joining cluster:cman_tool: Node is already active
 done
 Starting daemons: groupd fenced dlm_controld gfs_controld
 Joining fence domain: done ← 片方のマシンしか起動していないと、ここで無限に待たされます。
 Starting Quorum Disk daemon: done
samba32a:~# cman_tool nodes
Node  Sts   Inc   Joined               Name
   1   M    180   2008-10-07 00:39:05  samba32a
   2   M    192   2008-10-07 00:44:27  samba32b
samba32a:~# cman_tool services
type             level name     id       state
fence            0     default  00010001 none
[1 2]
dlm              1     gfs      00020002 none
[1 2]
gfs              2     gfs      00010002 none
[1 2]
  • 起動順の変更
samba32a:~# update-rc.d -f open-iscsi remove
 Removing any system startup links for /etc/init.d/open-iscsi ...
   /etc/rc0.d/K81open-iscsi
   /etc/rc6.d/K81open-iscsi
   /etc/rcS.d/S45open-iscsi
samba32a:~# update-rc.d open-iscsi start 66 S . stop 81 0 6 .
 Adding system startup for /etc/init.d/open-iscsi ...
   /etc/rc0.d/K81open-iscsi -> ../init.d/open-iscsi
   /etc/rc6.d/K81open-iscsi -> ../init.d/open-iscsi
   /etc/rcS.d/S66open-iscsi -> ../init.d/open-iscsi


  • ファイルシステムのマウント
samba32a と samba32b の両方で以下を実行します。
samba32a:~# mkdir /media/iscsi1
samba32a:~# mount /dev/sda1 /media/iscsi1
samba32a:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1              7850996    769208   6682976  11% /
tmpfs                    63316         0     63316   0% /lib/init/rw
udev                     10240       100     10140   1% /dev
tmpfs                    63316         0     63316   0% /dev/shm
/dev/sda1               237648        20    237628   1% /media/iscsi1
  • /etc/fstab の設定
/dev/sda1       /media/iscsi1   gfs     _netdev         0       0
  • 動作確認
samba32a と samba32b で以下を実行します。
samba32a:~# echo dame1 > /media/iscsi1/dame.txt

samba32b:~# cat /media/iscsi1/dame.txt
dame1
samba32b:~# echo dame2 >> /media/iscsi1/dame.txt

samba32a:~# cat /media/iscsi1/dame.txt
dame1
dame2

ctdb の設定

  • /etc/default/ctdb ファイルの設定
事前に /media/iscsi1/ctdb ディレクトリを作成
CTDB_RECOVERY_LOCK="/media/iscsi1/ctdb/lockfile"
...
CTDB_PUBLIC_INTERFACE=eth0
...
CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
...
CTDB_MANAGES_SAMBA=yes
...
ulimit -n 10000
...
CTDB_NODES=/etc/ctdb/nodes
echo 192.168.135.29/24 eth0 > /etc/ctdb/public_addresses

echo 192.168.135.21 > /etc/ctdb/modes
echo 192.168.135.22 >> /etc/ctdb/modes
vi /etc/ctdb/functions

              if [ -x /usr/bin/netcat ]; then
                  /usr/bin/netcat -z 127.0.0.1 $p > /dev/null || all_ok=0
この行と      elif [ -x /bin/netcat ]; then
この行を          /bin/netcat -z 127.0.0.1 $p > /dev/null || all_ok=0
追加          elif [ -x /usr/bin/nc ]; then
(2箇所)           /usr/bin/nc -z 127.0.0.1 $p > /dev/null || all_ok=0
              elif [ -x /usr/bin/netstat ]; then
samba32b:/etc/ctdb# ctdb status
Number of nodes:2
pnn:0 192.168.135.21   OK
pnn:1 192.168.135.22   OK (THIS NODE)
Generation:1850584080
Size:2
hash:0 lmaster:0
hash:1 lmaster:1
Recovery mode:NORMAL (0)
Recovery master:0
  • Samba の自動起動を停止
samba32b:/etc/ctdb# update-rc.d  -f samba remove
 Removing any system startup links for /etc/init.d/samba ...
   /etc/rc0.d/K19samba
   /etc/rc1.d/K19samba
   /etc/rc2.d/S20samba
   /etc/rc3.d/S20samba
   /etc/rc4.d/S20samba
   /etc/rc5.d/S20samba
   /etc/rc6.d/K19samba
samba32b:/etc/ctdb# update-rc.d  samba stop 19 0 1 6 .
 Adding system startup for /etc/init.d/samba ...
   /etc/rc0.d/K19samba -> ../init.d/samba
   /etc/rc1.d/K19samba -> ../init.d/samba
   /etc/rc6.d/K19samba -> ../init.d/samba

Samba の設定

[global]
  netbios name = samba32
  clustering = yes
  cluster addresses = 192.168.135.29

  idmap backend = tdb2
  private dir = /media/iscsi1/ctdb
  ctdbd socket = /tmp/ctdb.socket

[share1]
  path = /media/iscsi1/samba/share1
  writeable = yes
  force create mode = 775
  force directory mode = 775
  force group = sambashare
samba32b:/etc/samba# /etc/init.d/samba stop
Stopping Samba daemons: nmbd smbd.
samba32b:/etc/samba# /etc/init.d/ctdb restart
Restarting Clustered TDB: ctdb.
samba32b:/etc/samba# ps ax | grep mbd
 5031 ?        SNs    0:00 /usr/sbin/nmbd -D
 5033 ?        SNs    0:00 /usr/sbin/smbd -D
 5039 ?        SN     0:00 /usr/sbin/smbd -D
 5200 pts/0    S+     0:00 grep mbd
samba32a:/etc/samba# smbpasswd -a local
New SMB password:
Retype new SMB password:
Added user local.
samba32a:/etc/samba#

動作検証

  • Windows マシンからクラスタのIPにping
C:\Documents and Settings\monyo>ping 192.168.135.29
 
Pinging 192.168.135.29 with 32 bytes of data:
 
Reply from 192.168.135.29: bytes=32 time=2ms TTL=64
Reply from 192.168.135.29: bytes=32 time<1ms TTL=64
Reply from 192.168.135.29: bytes=32 time<1ms TTL=64
Reply from 192.168.135.29: bytes=32 time<1ms TTL=64
 
Ping statistics for 192.168.135.29:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 2ms, Average = 0ms

参考にしたページ