<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>hirohama mysql cluster</title>
        <link>http://www.hirohama.biz/mysql/</link>
        <description>MySQL関連のメモ/最近はMySQL Clusterネタが多い</description>
        <language>en</language>
        <copyright>Copyright 2008</copyright>
        <lastBuildDate>Mon, 18 Aug 2008 15:41:21 +0900</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>binlog-format=mixed</title>
            <description><![CDATA[<a href="http://dev.mysql.com/doc/refman/5.1/ja/replication-formats-mixed.html">MySQL :: MySQL 5.1 リファレンスマニュアル :: 5.1.2.2 ミックス レプリケーション フォーマット</a>


<blockquote>MIXED  モードで実行している場合、次の条件下にあるレプリケーションはステートメント ベースから行ベースに自動的に切り替わります。

DML ステートメントが NDB テーブルを更新するとき </blockquote>

]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/18-150821.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/18-150821.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">MySQL Cluster</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Replication</category>
            
            <pubDate>Mon, 18 Aug 2008 15:41:21 +0900</pubDate>
        </item>
        
        <item>
            <title>Zone構成へのMySQL Serverインストール・メモ</title>
            <description>バイナリの配置（Global Zone）

データ格納用のディレクトリ作成（各Zone）
/export/home/mysql/
/export/home/mysql-cluster/

設定ファイルの確認（各Zone）
/export/home/mysql-cluster/config.ini
/etc/my.cnf
</description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-180811.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-180811.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">Solaris</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Zone</category>
            
            <pubDate>Mon, 04 Aug 2008 18:39:11 +0900</pubDate>
        </item>
        
        <item>
            <title>Oracle無料版のインストール</title>
            <description><![CDATA[<a href="http://builder.japan.zdnet.com/sp/oracle-db-2008/story/0,3800086786,20375936,00.htm">無料で使える「Oracle Database XE」をインストール - builder by ZDNet Japan</a>

を参考にして、Oracle Database Expressをoracle.comからダウンロードしてインストール

日本オラクルのページではユーザ登録した記憶があったのだけど、アカウントは統一されていないのかな？
oracle.comで再度アカウントを作成した。

インストール後、ポート番号8080はPOPFileの管理画面で利用しているので、<a href="http://builder.japan.zdnet.com/sp/oracle-db-2008/story/0,3800086786,20377021,00.htm">「Oracle Databaseは難しいなぁ」と思うあなたに：Application Express - builder by ZDNet Japan</a>を参考にして、8081へ変更した。

あとは、<a href="file:///C:/oraclexe/app/oracle/doc/getting_started.htm">Oracle® Database Express Edition Getting Started Guide</a>を参考にして、一通りみてみる。






]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-180858.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-180858.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">Oracle</category>
            
            <pubDate>Mon, 04 Aug 2008 18:36:58 +0900</pubDate>
        </item>
        
        <item>
            <title>DRBDとHeartbeat2でMySQLをHA対応にしてみる: 4/4 - Heartbeat2のインストールと設定 -</title>
            <description><![CDATA[<strong>Heartbeat2のインストール（両方のノードで）</strong>

http://www.linux-ha.org/ja/DownloadSoftware_ja
からRedHat Enterprise 4用のRPMを利用する。

<pre>
[root@h1 heartbeat-2.1.2-2.rhel4.x86_64.RPMS]# rpm -ivh heartbeat-pils-2.1.2-2.x86_64.rpm
Preparing...                ########################################### [100%]
   1:heartbeat-pils         ########################################### [100%]
[root@h1 heartbeat-2.1.2-2.rhel4.x86_64.RPMS]# rpm -ivh heartbeat-stonith-2.1.2-2.x86_64.rpm
Preparing...                ########################################### [100%]
   1:heartbeat-stonith      ########################################### [100%]
[root@h1 heartbeat-2.1.2-2.rhel4.x86_64.RPMS]# rpm -ivh heartbeat-2.1.2-2.x86_64.rpm
Preparing...                ########################################### [100%]
   1:heartbeat              ########################################### [100%]
[root@h1 heartbeat-2.1.2-2.rhel4.x86_64.RPMS]# rpm -ivh heartbeat-gui-2.1.2-2.x86_64.rpm
Preparing...                ########################################### [100%]
   1:heartbeat-gui          ########################################### [100%]
</pre>


インストールする順番は、

   1. pils
   2. stonith
   3. heartbeat

<strong>Heartbeat2の設定ファイル：ha.cf</strong>
/etc/ha.d/ha.cf

<pre>
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility syslog
#use_logd yes
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
bcast   eth1			# dedicated interconnect
mcast eth0 224.1.1.1 694 1 0
auto_failback off
node h1
node h2
crm yes
</pre>

<strong>cib.xml</strong>
/var/lib/heartbeat/crm/cib.xml

haresourcesから生成する場合は、drbddiskの後にリソース名を指定すること。
h1 172.20.95.50 drbddisk::d0 Filesystem::/dev/drbd0::/mnt/drbd/mysql::ext3 mysql

sticknessはINFINITYに変更すること。（変更しないと自動フェールバックしてしまう。）

またmysqlスクリプトのファイル権限にも注意すること。

<pre>
&lt;?xml version="1.0" ?&gt;
&lt;cib admin_epoch="0" epoch="0" num_updates="0"&gt;
	&lt;configuration&gt;
		&lt;crm_config&gt;
			&lt;cluster_property_set id="cib-bootstrap-options"&gt;
				&lt;attributes&gt;
					&lt;nvpair id="cib-bootstrap-options-symmetric-cluster" name="symmetric-cluster" value="true"/&gt;
					&lt;nvpair id="cib-bootstrap-options-no-quorum-policy" name="no-quorum-policy" value="stop"/&gt;
					&lt;nvpair id="cib-bootstrap-options-default-resource-stickiness" name="default-resource-stickiness" value="INFINITY"/&gt;
					&lt;nvpair id="cib-bootstrap-options-default-resource-failure-stickiness" name="default-resource-failure-stickiness" value="0"/&gt;
					&lt;nvpair id="cib-bootstrap-options-stonith-enabled" name="stonith-enabled" value="false"/&gt;
					&lt;nvpair id="cib-bootstrap-options-stonith-action" name="stonith-action" value="reboot"/&gt;
					&lt;nvpair id="cib-bootstrap-options-stop-orphan-resources" name="stop-orphan-resources" value="true"/&gt;
					&lt;nvpair id="cib-bootstrap-options-stop-orphan-actions" name="stop-orphan-actions" value="true"/&gt;
					&lt;nvpair id="cib-bootstrap-options-remove-after-stop" name="remove-after-stop" value="false"/&gt;
					&lt;nvpair id="cib-bootstrap-options-short-resource-names" name="short-resource-names" value="true"/&gt;
					&lt;nvpair id="cib-bootstrap-options-transition-idle-timeout" name="transition-idle-timeout" value="5min"/&gt;
					&lt;nvpair id="cib-bootstrap-options-default-action-timeout" name="default-action-timeout" value="15s"/&gt;
					&lt;nvpair id="cib-bootstrap-options-is-managed-default" name="is-managed-default" value="true"/&gt;
				&lt;/attributes&gt;
			&lt;/cluster_property_set&gt;
		&lt;/crm_config&gt;
		&lt;nodes/&gt;
		&lt;resources&gt;
			&lt;group id="group_1"&gt;
				&lt;primitive class="ocf" id="IPaddr_172_20_95_50" provider="heartbeat" type="IPaddr"&gt;
					&lt;operations&gt;
						&lt;op id="IPaddr_172_20_95_50_mon" interval="5s" name="monitor" timeout="5s"/&gt;
					&lt;/operations&gt;
					&lt;instance_attributes id="IPaddr_172_20_95_50_inst_attr"&gt;
						&lt;attributes&gt;
							&lt;nvpair id="IPaddr_172_20_95_50_attr_0" name="ip" value="172.20.95.50"/&gt;
						&lt;/attributes&gt;
					&lt;/instance_attributes&gt;
				&lt;/primitive&gt;
				&lt;primitive class="heartbeat" id="drbddisk_2" provider="heartbeat" type="drbddisk"&gt;
					&lt;operations&gt;
						&lt;op id="drbddisk_2_mon" interval="120s" name="monitor" timeout="60s"/&gt;
					&lt;/operations&gt;
					&lt;instance_attributes id="drbddisk_2_inst_attr"&gt;
						&lt;attributes&gt;
							&lt;nvpair id="drbddisk_2_attr_1" name="1" value="d0"/&gt;
						&lt;/attributes&gt;
					&lt;/instance_attributes&gt;
				&lt;/primitive&gt;
				&lt;primitive class="ocf" id="Filesystem_3" provider="heartbeat" type="Filesystem"&gt;
					&lt;operations&gt;
						&lt;op id="Filesystem_3_mon" interval="120s" name="monitor" timeout="60s"/&gt;
					&lt;/operations&gt;
					&lt;instance_attributes id="Filesystem_3_inst_attr"&gt;
						&lt;attributes&gt;
							&lt;nvpair id="Filesystem_3_attr_0" name="device" value="/dev/drbd0"/&gt;
							&lt;nvpair id="Filesystem_3_attr_1" name="directory" value="/mnt/drbd"/&gt;
							&lt;nvpair id="Filesystem_3_attr_2" name="fstype" value="ext3"/&gt;
						&lt;/attributes&gt;
					&lt;/instance_attributes&gt;
				&lt;/primitive&gt;
				&lt;primitive class="heartbeat" id="mysql_4" provider="heartbeat" type="mysql"&gt;
					&lt;operations&gt;
						&lt;op id="mysql_4_mon" interval="60s" name="monitor" timeout="30s"/&gt;
					&lt;/operations&gt;
				&lt;/primitive&gt;
			&lt;/group&gt;
		&lt;/resources&gt;
		&lt;constraints&gt;
			&lt;rsc_location id="rsc_location_group_1" rsc="group_1"&gt;
				&lt;rule id="prefered_location_group_1" score="100"&gt;
					&lt;expression attribute="#uname" id="prefered_location_group_1_expr" operation="eq" value="h1"/&gt;
				&lt;/rule&gt;
			&lt;/rsc_location&gt;
		&lt;/constraints&gt;
	&lt;/configuration&gt;
	&lt;status/&gt;
&lt;/cib&gt;
</pre>

<strong>authkeys</strong>
/etc/ha.d/authkeys

<pre>auth 1
1 crc</pre>

<strong>Heartbeat2の設定</strong>
<strong>
mysqlスタートアップスクリプトのコピー </strong>

<pre>
[root@h1 resource.d]# cp /etc/rc.d/init.d/mysql /etc/ha.d/resource.d/
[root@h2 resource.d]# cp /etc/rc.d/init.d/mysql /etc/ha.d/resource.d/</pre>

このスクリプトは、本来はMySQLバイナリに入っているものだが、バグが（<a href="http://bugs.mysql.com/bug.php?id=31785">MySQL Bugs: #31785: mysql.server stop does not spot server gone away</a>）あるので、修正版を利用する。

<strong>各サービスの停止 </strong>

必要に応じてサービスを停止する。

<pre>[root@h1 resource.d]# service drbd stop
Stopping all DRBD resources.
[root@h1 resource.d]# service mysql stop
MySQL manager or server PID file could not be found!       [失敗]
[root@h1 resource.d]# service heartbeat stop
Stopping High-Availability services: 
                                                           [  OK  ]
logd is already stopped
</pre>

h2でも同様の処理を行う。

<strong>スタートアップスクリプトに登録（両方のノードで）</strong>

<pre>
[root@h1 resource.d]# chkconfig drbd on
[root@h1 resource.d]# chkconfig mysql off
[root@h1 resource.d]# chkconfig heartbeat on</pre>

h2でも同様の処理を行う。

<strong>drbdの起動 （両方のノードで）</strong>

<pre>[root@h1 resource.d]# service drbd start
Starting DRBD resources:    [ d0 s0 n0 ].</pre>

h2でも同様の処理を行う。

<strong>heartbeatの起動（両方のノードで）</strong>

<pre>[root@h1 resource.d]# service heartbeat start</pre>

h2でも同様の処理を行う。

<strong>Heartbeat2の稼働確認</strong>

<pre>[root@h1 ha.d]# crm_mon -i 3
Refresh in 1s...

============
Last updated: Thu Nov  8 18:16:25 2007
Current DC: h2 (73553d5d-1a50-4f55-99de-8ba7aec48426)
2 Nodes configured.
1 Resources configured.
============

Node: h2 (73553d5d-1a50-4f55-99de-8ba7aec48426): online
Node: h1 (ce2c28c3-585e-494b-baa8-d38b7e7ebd9e): online

Resource Group: group_1
    IPaddr_172_20_95_50 (heartbeat::ocf:IPaddr):        Started h1
    drbddisk_2  (heartbeat:drbddisk):   Started h1
    Filesystem_3        (heartbeat::ocf:Filesystem):    Started h1
    mysql_4     (heartbeat:mysql):      Started h1

</pre>]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-140831.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-140831.html</guid>
            
            
            <pubDate>Mon, 04 Aug 2008 14:40:31 +0900</pubDate>
        </item>
        
        <item>
            <title>DRBDとHeartbeat2でMySQLをHA対応にしてみる: 3/4 - MySQLのインストール -</title>
            <description><![CDATA[MySQL Enterprise BinaryのRedHat 4.4向けEM64T対応のサーバとクライアントを　RPMからインストール
データディレクトリをDRBD管理配下へ 

<pre>basedir=/mnt/drbd/mysql</pre>

<strong>DRBD構成用my.cnf</strong>

<pre>#BEGIN CONFIG INFO
#DESCR: h1 for DRBD Eval. by hirohama
#END CONFIG INFO

###########################################
# GENERIC configuration options
###########################################

[client]
# Connection
port = 3306

[mysqld]
server-id=11
datadir=/mnt/drbd/mysql
skip-name-resolve

# Character Set

# Connection
port = 3306
user=mysql
max_connections = 100

# File Open

# Thread
thread_cache_size = 100

# Query Cache
query_cache_size = 64M
query_cache_type = 1

default_table_type = INNODB

###########################################
# Log Specific options
###########################################

log-bin=h-bin

log=h.log

log-error=h.err

binlog_cache_size = 1M
log-warnings = 2
log_slow_queries
long_query_time = 10
sync_binlog = 1

###########################################
# BDB Specific options
###########################################

skip-bdb

###########################################
# MyISAM Specific options
###########################################

key_buffer_size = 8M

###########################################
# INNODB Specific options
###########################################

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 1G
innodb_log_buffer_size = 8M
innodb_log_file_size = 200M
innodb_log_files_in_group = 3
innodb_lock_wait_timeout = 50
</pre>

<strong>DRBDを使わない場合のmy.cnf</strong>

datadirをコメントアウトして、デフォルトの/var/lib/mysql以下にデータディレクトリを設定する。

<strong>スタートアップスクリプトを差し替える</strong>

既存のmysql.serverはバグがあるので、手動で差し替えること。

/etc/init.d/mysql
/etc/ha.d/resource.d/mysql　（後ほど/etc/init.d/mysqlをコピーする）

]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-140859.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-140859.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">DRBD</category>
            
            <pubDate>Mon, 04 Aug 2008 14:36:59 +0900</pubDate>
        </item>
        
        <item>
            <title>DRBDとHeartbeat2でMySQLをHA対応にしてみる: 2/4 - DRBDの稼働テスト -</title>
            <description><![CDATA[<strong>同期が完了したらファイルシステムを作成して、マウントする。（プライマリノード）</strong>

mke2fs -jまたはmkfs.ext3を利用する。

<pre>[root@h1 ~]# mke2fs -j /dev/drbd0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
8896512 inodes, 17789979 blocks
889498 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
543 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:



done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@h1 ~]# mkdir /mnt/drbd
[root@h1 ~]# mount /dev/drbd0 /mnt/drbd/
</pre>

手動でフェールオーバ(プライマリノード)

<pre>
[root@h1 ~]# umount /mnt/drbd/
[root@h1 ~]# cat /proc/drbd
version: 8.0.7 (api:86/proto:86)
GIT-hash: cf14288833afe95db396075f8530a5960d29e498 build by buildsystem@linbit, 2007-11-02 15:08:55
 0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---
    ns:72313830 nr:0 dw:1153913 dr:71160107 al:568 bm:4344 lo:0 pe:0 ua:0 ap:0
        resync: used:0/31 hits:4443152 misses:4344 starving:0 dirty:0 changed:4344
        act_log: used:0/257 hits:2306894 misses:795 starving:0 dirty:227 changed:568
[root@h1 ~]# drbdsetup /dev/drbd0 secondary
[root@h1 ~]# cat /proc/drbd
version: 8.0.7 (api:86/proto:86)
GIT-hash: cf14288833afe95db396075f8530a5960d29e498 build by buildsystem@linbit, 2007-11-02 15:08:55
 0: cs:Connected st:Secondary/Secondary ds:UpToDate/UpToDate C r---
    ns:72313830 nr:0 dw:1153913 dr:71160107 al:568 bm:4599 lo:0 pe:0 ua:0 ap:0
        resync: used:0/31 hits:4443152 misses:4344 starving:0 dirty:0 changed:4344
        act_log: used:0/257 hits:2306894 misses:795 starving:0 dirty:227 changed:568
</pre>

<strong>手動でフェールオーバ(セカンダリノード)</strong>

<pre>[root@h2 ~]# drbdsetup /dev/drbd0 primary
[root@h2 ~]# cat /proc/drbd
version: 8.0.7 (api:86/proto:86)
GIT-hash: cf14288833afe95db396075f8530a5960d29e498 build by buildsystem@linbit, 2007-11-02 15:08:55
 0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---
    ns:0 nr:72313830 dw:72313830 dr:0 al:0 bm:4344 lo:0 pe:0 ua:0 ap:0
        resync: used:0/31 hits:4443152 misses:4344 starving:0 dirty:0 changed:4344
        act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0
[root@h2 ~]# mount /dev/drbd0 /mnt/drbd/
[root@h2 ~]# ls /mnt/drbd/
lost+found/ test.txt

</pre>
でprimary側で作成したファイルを確認できる。

]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-140842.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-140842.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">DRBD</category>
            
            <pubDate>Mon, 04 Aug 2008 14:33:42 +0900</pubDate>
        </item>
        
        <item>
            <title>DRBDとHeartbeat2でMySQLをHA対応にしてみる: 1/4 - DRBDのインストールと設定 -</title>
            <description><![CDATA[2007/12に書いたものが埋もれていたので整理。


DRBDのインストール方法は、いくつかある。
   1. drbd.orgからソースをダウンロードしてビルド、インストール
   2. LINBIT社提供のRPMを利用する（有償）
   3. MySQL Enterpriseのオプションを購入して、LINBIT社提供のRPMを利用する（有料）
   4. CentOSのyumを利用する。（CentOS4.5ではVer.0.7.23のみdrbd本体とkernel module共に用意されているが、CentOS5ではVer.8.0.3のdrbd本体のみでkernel moduleは提供されていない。 ）
   5. SUSE Linux（SUSE Linux Professional 9.3以降、SUSE Linux Enterprise Server 9以降）では標準パッケージとして提供されている（らしい） 

今回は「LINBIT社提供のRPMを使ってDRBD 8.0.7をインストール」した。 RPMを使ったインストールにあたっては、「kernelのバージョンを(uname -aなどで)ちゃんと確認すること」、くらい。

<strong>DRBDのインストール</strong>

<pre>[root@h1 ~]# rpm -ivh drbd-8.0.7-3.x86_64.rpm
Preparing...                ########################################### [100%]
   1:drbd                   ########################################### [100%]
[root@h1 ~]# rpm -ivh drbd-km-2.6.9_42.ELsmp-8.0.7-3.x86_64.rpm
Preparing...                ########################################### [100%]
   1:drbd-km-2.6.9_42.ELsmp ########################################### [100%]</pre>

<pre>[root@h2 ~]# rpm -ivh drbd-8.0.7-3.x86_64.rpm
Preparing...                ########################################### [100%]
   1:drbd                   ########################################### [100%]
[root@h2 ~]# rpm -ivh drbd-km-2.6.9_42.ELsmp-8.0.7-3.x86_64.rpm
Preparing...                ########################################### [100%]
   1:drbd-km-2.6.9_42.ELsmp ########################################### [100%]</pre>

<strong>DRBD用パーティションの準備</strong>

fdisk /dev/sdbなどでパーティションを作成。（h1/h2）

<pre>コマンド (m でヘルプ): p

Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          65      522081   83  Linux
/dev/sdb2              66        8924    71159917+  83  Linux</pre>

<strong>設定</strong>

/usr/share/doc/drbd/drbd.confを参考にして/etc/drbd.conf設定ファイルを作成する。

<pre>resource d0 {
  protocol C;
  startup {
    degr-wfc-timeout 120;    # 2 minutes.
  }
  disk {
    on-io-error   detach;
  }
  net {
  }
  syncer {
    rate 500M;
    al-extents 257;
  }
  on h1 {
    device     /dev/drbd0;
    disk       /dev/sdb2;
    address    10.0.0.11:7788;
    meta-disk  /dev/sdb1[0];
  }

  on h2 {
    device    /dev/drbd0;
    disk      /dev/sdb2;
    address   10.0.0.12:7788;
    meta-disk /dev/sdb1[0];
  }
}


</pre>

<u>resource</u>
ここでは、d0という名前のresourceを設定している。

<u>protocol</u>
DRBDを使う以上、Cでリモートのディスクへの書き込みまで確認するべき。ただし、Write Cacheアリのストレージを使う場合も、Bはありえない。理由は、"remote buffer cache"はLinux buffer cache(VFSの一部)で、File SystemとDRBDの中間に位置する。一方、"disk write cache"はDiskとDRBDの中間に位置するので。

<pre># transfer protocol to use.
 # C: write IO is reported as completed, if we know it has
 #    reached _both_ local and remote DISK.
 #    * for critical transactional data.
 # B: write IO is reported as completed, if it has reached
 #    local DISK and remote buffer cache.
 #    * for most cases.
 # A: write IO is reported as completed, if it has reached
 #    local DISK and local tcp send buffer. (see also sndbuf-size)
 #    * for high latency networks
 #**********
 # uhm, benchmarks have shown that C is actually better than B.
 # this note shall disappear, when we are convinced that B is
 # the right choice "for most cases".
 # Until then, always use C unless you have a reason not to.
 #     --lge
 #**********
</pre>

このコメントによると、ベンチマークするとCの方がBよりもいいとのこと。

<u>C </u>
クリティカルなトランザクションデータ向け。ローカルディスクへの書き込みと、リモートのディスクへの書き込みが完了したことを確認して「書き込み完了」（write IO is completed）とする。 

<u>B </u>
多くの場合に使えるでしょう。ローカルディスクへの書き込みと、リモートのバッファキャッシュへの書き込みが完了したことを確認して「書き込み完了」（write IO is completed）とする。 

<u>A </u>
高いレイテンシのネットワークで有効。ローカルディスクへの書き込みと、書き込みの要求をリモートのサーバへ送信したことを確認して「書き込み完了」（write IO is completed）とする。

<u>on-io-error</u>
on-io-errorでは、低レベルデバイスでIOエラーが発生した場合の挙動を設定する。

Ver. 0.8系ではpanic（カーネルパニックを引き起こす）が無くなってcall-local-io-errorが新しく追加されている。
可用性を考慮するのであれば、ディスクレスモードで動作するdetachを選択する。


<pre>   # if the lower level device reports io-error you have the choice of
   #  "pass_on"  ->  Report the io-error to the upper layers.
   #                 Primary   -> report it to the mounted file system.
   #                 Secondary -> ignore it.
   #  "call-local-io-error"
   #	          ->  Call the script configured by the name "local-io-error".
   #  "detach"   ->  The node drops its backing storage device, and
   #                 continues in disk less mode.</pre>

<u>pass_on </u>

　上位層にI/Oエラーを返す。プライマリの場合はマウントしたファイルシステムへ、セカンダリでは無視される。実際の挙動は稼働中にディスクを抜いくことで確認できる。

<u>call-local-io-error </u>

　local-io-errorという名前のスクリプトを実行する。 

<u>detach </u>

　該当のストレージデバイスを切り離し、ディスクレスモードで継続して動作する。 挙動は、その名のとおり、ローカルディスクへのアクセス無しで動作する。

<strong>device fileの作成</strong>

<blockquote>for i in `seq 0 15` ; do mknod /dev/drbd$i b 147 $i; done</blockquote>

<strong>DRBDモジュールのロードと確認（両方のノードで実施）</strong>

minor_countで管理する最大の共有ディスクの数を指定する。

<pre>[root@h1 ~]# lsmod |grep drbd
[root@h1 ~]# modprobe drbd minor_count=1
[root@h1 ~]# lsmod |grep drbd
drbd                  225832  0
[root@h1 ~]# cat /proc/drbd
version: 8.0.7 (api:86/proto:86)
GIT-hash: cf14288833afe95db396075f8530a5960d29e498 build by buildsystem@linbit, 2007-11-02 15:08:55</pre>

参考：
<pre>
[root@h2 ha]# modinfo drbd
filename:       /lib/modules/2.6.9-42.ELsmp/kernel/drivers/block/drbd.ko
author:         Philipp Reisner <phil@linbit.com>, Lars Ellenberg <lars@linbit.com>
description:    drbd - Distributed Replicated Block Device v8.0.7
license:        GPL
parm:           minor_count:Maximum number of drbd devices (1-255)
alias:          block-major-147-*
parm:           allow_oos:DONT USE!
license:        GPL
author:         Evgeniy Polyakov <johnpol@2ka.mipt.ru>
description:    Generic userspace <-> kernelspace connector.
parm:           cn_idx:Connector's main device idx.
parm:           cn_val:Connector's main device val.
vermagic:       2.6.9-42.ELsmp SMP 686 REGPARM 4KSTACKS gcc-3.4
depends:</pre>

<strong>meta dataの作成（両方のノードで実施）</strong>

<pre>[root@h1 ~]# drbdadm create-md d0
v08 Magic number not found
v07 Magic number not found
About to create a new drbd meta data block
on /dev/sdb1.

 ==> This might destroy existing data! <==

Do you want to proceed?
[need to type 'yes' to confirm] yes

Creating meta data...
initialising activity log
NOT initialized bitmap (131036 KB)
New drbd meta data block sucessfully created.

                --== Creating metadata ==--
As with nodes we count the total number of devices mirrored by DRBD at
at http://usage.drbd.org.

The counter works completely anonymous. A random number gets created for
this device, and that randomer number and the devices size will be sent.

[cut]

Enter 'no' to opt out, or just press [return] to continue:
success

</pre>

<strong>開始と確認（両方のノードで実施）</strong>

<pre>[root@h1 ~]# drbdadm up all
[root@h1 ~]# cat /proc/drbd
version: 8.0.7 (api:86/proto:86)
GIT-hash: cf14288833afe95db396075f8530a5960d29e498 build by buildsystem@linbit, 2007-11-02 15:08:55
 0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0
        resync: used:0/31 hits:0 misses:0 starving:0 dirty:0 changed:0
        act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0</pre>

<strong>同期開始(primary node側で実施)</strong>

<pre>[root@h1 ~]# drbdadm -- --overwrite-data-of-peer primary all</pre>

これは0.7系の--do-what-I-sayオプションの名前が変わったもの。

<strong>service開始</strong>

次のどちらかのコマンドでサービスを起動する。

<pre>/etc/init.d/drbd start</pre>

<pre>service drbd start</pre>

<strong>同期途中</strong>

<pre>[root@h1 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.0.3 (api:86/proto:86)
SVN Revision: 2881 build by buildsystem@linbit, 2007-05-07 19:20:34
 0: cs:SyncSource st:Primary/Secondary ds:UpToDate/Inconsistent C r---
   ns:14648428 nr:0 dw:0 dr:14656512 al:0 bm:894 lo:1 pe:6 ua:253 ap:0
       [======>.............] sync'ed: 30.1% (33246/47551)M
       finish: 0:48:29 speed: 11,696 (11,460) K/sec
       resync: used:1/31 hits:914879 misses:895 starving:0 dirty:0 changed:895
       act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0</pre>

cs:SyncSourceは、自ノード（h1）からピアノード（h2）へ同期中であると。このとき、h2では、cs:SyncTargetとなっている。]]></description>
            <link>http://www.hirohama.biz/mysql/2008/08/04-140828.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/08/04-140828.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">DRBD</category>
            
            <pubDate>Mon, 04 Aug 2008 14:18:28 +0900</pubDate>
        </item>
        
        <item>
            <title>RPMで削除するときにエラー「複数のパッケージを指定しています」</title>
            <description><![CDATA[<a href="http://ysmt.blog21.fc2.com/blog-entry-206.html">Freak: rpmで同一の複数のパッケージを削除する</a>

<blockquote>rpmでパッケージを削除しようとしたら、同じ名前の複数のパッケージがインストールされてる（？）みたいで削除できない場合がある。↓みたいな感じ。

# rpm -e nss_ldap-226-10
エラー: "nss_ldap-226-10" は複数のパッケージを指定しています

そんなときは
# rpm -e --allmatches nss_ldap-226-10</blockquote>

ここにも記述があった。
<a href="http://shinjuku-vipper.cocolog-nifty.com/blog/2007/12/mysql50420.html">Linuxでやる夫: やる夫がMySQL-5.0.42-0をインストールするようです。</a>]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/30-170714.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/30-170714.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">Linux</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">RPM</category>
            
            <pubDate>Wed, 30 Jul 2008 17:12:14 +0900</pubDate>
        </item>
        
        <item>
            <title>二つ目以降のzone作成方法</title>
            <description><![CDATA[


<strong>zoneのインストール</strong>

zoneadm -z zone1 install

<strong>zoneのブート</strong>
zoneadm -z zone1 boot

<strong>コンソールに接続して初期設定</strong>
zlogin -C zone1

<strong>設定ファイルのエクスポート</strong>
[root@Solaris1 zones]# zonecfg -z zone1
zonecfg:zone1> export
create -b
set zonepath=/export/home/zones/zone1
set autoboot=false
set ip-type=shared
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add net
set address=172.20.100.25/21
set physical=e1000g0
end
zonecfg:zone1> export -f /export/home/zones/zone_config

<strong>設定ファイルを編集</strong>
[root@Solaris1 zones]# cat zone2_config
create -b
set zonepath=/export/home/zones/zone2
set autoboot=false
set ip-type=shared
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add net
set address=172.20.100.26/21
set physical=e1000g0
end

設定ファイルを使ってzone2の構成

[root@Solaris1 zones]# zonecfg -z zone2 -f zone2_config

<strong>zoneのインストール</strong>

zoneadm -z zone2 install


-----


あとは一緒

-----

ユーザーの作成
mkdir /export/home
useradd -d /export/home/hirohama -m -s /bin/ksh hirohama
passwd hirohama



]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/29-150703.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/29-150703.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">Solaris</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Zone</category>
            
            <pubDate>Tue, 29 Jul 2008 15:46:03 +0900</pubDate>
        </item>
        
        <item>
            <title>Zone作成のログ</title>
            <description><![CDATA[zone作成のログ
前回は/export/home以外に作成してしまったので、再度イメージを作成
ついでのautoboot=falseに変更した

-----

[root@Solaris1 ~]# zoneadm list -vc
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
[root@Solaris1 ~]# zonecfg -z zone1
zone1: そのような構成済みゾーンはありません
'create' を使用して、新しいゾーンの構成を開始してください。
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/export/home/zones/zone1
zonecfg:zone1> set autoboot=false
zonecfg:zone1> add net
zonecfg:zone1:net> set address=xxxxx/21
zonecfg:zone1:net> set physical=e1000g0
zonecfg:zone1:net> end
zonecfg:zone1> info
zonename: zone1
zonepath: /export/home/zones/zone1
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
net:
        address: xxxxx/21
        physical: e1000g0
zonecfg:zone1> export
create -b
set zonepath=/export/home/zones/zone1
set autoboot=false
set ip-type=shared
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add net
set address=xxxxx/21
set physical=e1000g0
end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
[root@Solaris1 ~]# zoneadm list -vc
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - zone1            configured /export/home/zones/zone1            native   shared
[root@Solaris1 ~]# zoneadm -z zone1 install
Preparing to install zone <zone1>.
Creating list of files to copy from the global zone.
Copying <7614> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1245> packages on the zone.
Initialized <1245> packages on zone.
Zone <zone1> is initialized.
The file </export/home/zones/zone1/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
[root@Solaris1 ~]#
]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/29-150739.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/29-150739.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">Solaris</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Zone</category>
            
            <pubDate>Tue, 29 Jul 2008 15:14:39 +0900</pubDate>
        </item>
        
        <item>
            <title>Drizzle</title>
            <description><![CDATA[<a href="http://alpha.mixi.co.jp/blog/?p=189">mixi Engineers’ Blog » Introducing the Drizzle Project</a>

<blockquote>Drizzleとは必要のないものは一切存在しない、最低限でパフォーマンス重視な「MySQLよりシンプルで、軽く、安定して、高速な」 MySQLのforkです。</blockquote>

<a href="http://krow.livejournal.com/602409.html">Brian "Krow" Aker's Idle Thoughts - Drizzle, Clouds, "What If?"</a>
<a href="http://monty-says.blogspot.com/2008/07/what-if.html">Monty says: What if</a>]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/23-140728.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/23-140728.html</guid>
            
            
            <pubDate>Wed, 23 Jul 2008 14:48:28 +0900</pubDate>
        </item>
        
        <item>
            <title>MySQL ClusterでData Nodeが起動しない</title>
            <description>どうやら、
LockPagesInMainMemory=1
が怪しそうだ。

OSはSolaris 10 (Sparc)</description>
            <link>http://www.hirohama.biz/mysql/2008/07/09-150703.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/09-150703.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">MySQL Cluster</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Solaris</category>
            
            <pubDate>Wed, 09 Jul 2008 15:29:03 +0900</pubDate>
        </item>
        
        <item>
            <title>とある環境のメモ</title>
            <description><![CDATA[<strong>MySQL Cluster起動方法</strong>

1. 
@172.20.100.24
cd /export/home/mysql-cluster
ndb_mgmd

2.
@172.20.100.24
cd /export/home/mysql-cluster
ndbd --connect-string=172.20.100.24

3.
@172.20.100.23
ndbd --connect-string=172.20.100.24

4.
@172.20.100.24
mysqld_safe --user=mysql &

5.
@172.20.100.23
mysqld_safe --user=mysql &

6.
ローカルのSQL Nodeへ接続
mysql -uroot -proot
または
mysql -uroot


<strong>MySQL Clusterバックアップ</strong>

@172.20.100.23

/export/home/hirohama/BACKUP

MySQL Clusterのndb_restoreコマンドでリストア可能

ndb_restore -m -b 1 -n 2
ndb_restore -r -b 1 -n 2
ndb_restore -r -b 1 -n 3

この後でcreate database mysqlslapしても、タブン大丈夫

NDBでmysqlslap.t1を生成して、100万行のロード（800MB弱）

<strong>各種ファイル</strong>

@172.20.100.23

/export/home/hirohama/

data_load_innodb.sql: InnoDBでmysqlslap.t1を生成して、100万行のロード（800MB弱）
data_load_myisam.sql: MyISAMでmysqlslap.t1を生成して、100万行のロード（800MB弱）
select.sql: SELECT w/ PKクエリが50000件

mysqlslap_50_file.sh: select.sqlを利用してベンチマーク実施





]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/07-140727.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/07-140727.html</guid>
            
            
            <pubDate>Mon, 07 Jul 2008 14:41:27 +0900</pubDate>
        </item>
        
        <item>
            <title>Solarisでデフォルトゲートウェイを設定する</title>
            <description><![CDATA[<a href="http://www2.odn.ne.jp/~cag07740/tech_info/unix_ans9.html">デフォルトゲートウェイの設定方法は？</a>
<blockquote># routeコマンドでの設定方法
hogehoge% /usr/sbin/route add default XXX.XXX.XXX.XXX

# ルーティング情報の確認方法
hogehoge% /bin/netstat -rn </blockquote>

あとは、こんな感じで。

ifconfig e1000g0  172.20.100.23 netmask  255.255.248.0 broadcast 172.20.103.255

ifconfig e1000g up

route add default 172.20.96.254]]></description>
            <link>http://www.hirohama.biz/mysql/2008/07/03-160701.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/03-160701.html</guid>
            
            
            <pubDate>Thu, 03 Jul 2008 16:33:01 +0900</pubDate>
        </item>
        
        <item>
            <title>MySQL Clusterのパラメータ初期値</title>
            <description>DataMemoryによって変えた方がいいのは、次のパラメータくらい？

DataMemory=20480M
IndexMemory=2560M
NoOfFragmentLogFiles=120

あとはベンチマークなどで負荷をかけつつ、チューニングか。</description>
            <link>http://www.hirohama.biz/mysql/2008/07/03-140739.html</link>
            <guid>http://www.hirohama.biz/mysql/2008/07/03-140739.html</guid>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">MySQL Cluster</category>
            
            <pubDate>Thu, 03 Jul 2008 14:27:39 +0900</pubDate>
        </item>
        
    </channel>
</rss>
