当前位置:首页 » 其他

聊一聊元数据

2005-08-18 11:44 本站整理 浏览(4)

规划:

vip 172.16.45.2

node1.yue.com 172.16.45.11

node2.yue.com 172.16.45.12

需要用到的相关软件包:

drbd83-8.3.8-1.el5.centos.i386.rpm

kmod-drbd83-8.3.8-1.el5.centos.i686.rpm

cluster-glue-1.0.6-1.6.el5.i386.rpm

cluster-glue-libs-1.0.6-1.6.el5.i386.rpm

corosync-1.2.7-1.1.el5.i386.rpm

corosynclib-1.2.7-1.1.el5.i386.rpm

heartbeat-3.0.3-2.3.el5.i386.rpm

heartbeat-libs-3.0.3-2.3.el5.i386.rpm

libesmtp-1.0.4-5.el5.i386.rpm

pacemaker-1.1.5-1.1.el5.i386.rpm

pacemaker-cts-1.1.5-1.1.el5.i386.rpm

pacemaker-libs-1.1.5-1.1.el5.i386.rpm

resource-agents-1.0.4-1.1.el5.i386.rpm

mysql-5.5.24(绿色版)

另外还要准备好系统光盘作为yum源

1. 配置双机互信

# ssh-keygen -t rsa

# ssh-copy-id -i ~/.ssh/id_rsa.pub root@node2

2. 主机名(在 /etc/hosts 文件中)

172.16.45.11 node1.yue.com node1

172.16.45.12 node2.yue.com node2

3. 时间同步

#hwcolock -s

一、

在node1 上的相关设置:

1. 创建一个512M的磁盘分区:

root@node1 ~]# fdisk -l 
 
Disk /dev/sda: 128.8 GB, 128849018880 bytes 
255 heads, 63 sectors/track, 15665 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
 
   Device Boot      Start         End      Blocks   Id  System 
/dev/sda1   *           1          13      104391   83  Linux 
/dev/sda2              14        5235    41945715   8e  Linux LVM 
/dev/sda3            5236        5366     1052257+  82  Linux swap / Solaris 
 
Disk /dev/sdb: 21.4 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
 
Disk /dev/sdb doesn't contain a valid partition table 
[root@node1 ~]# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel 
Building a new DOS disklabel. Changes will remain in memory only, 
until you decide to write them. After that, of course, the previous 
content won't be recoverable. 
 
The number of cylinders for this disk is set to 2610. 
There is nothing wrong with that, but this is larger than 1024, 
and could in certain setups cause problems with: 
1) software that runs at boot time (e.g., old versions of LILO) 
2) booting and partitioning software from other OSs 
   (e.g., DOS FDISK, OS/2 FDISK) 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 
 
Command (m for help): n 
Command action 
   e   extended 
   p   primary partition (1-4) 
p 
Partition number (1-4): 1 
First cylinder (1-2610, default 1):  
Using default value 1 
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +512M 
 
Command (m for help): p 
 
Disk /dev/sdb: 21.4 GB, 21474836480 bytes 
255 heads, 63 sectors/track, 2610 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
 
   Device Boot      Start         End      Blocks   Id  System 
/dev/sdb1               1          63      506016   83  Linux 
 
Command (m for help): w 
The partition table has been altered! 
 
Calling ioctl() to re-read partition table. 
Syncing disks. 
[root@node1 ~]# partprobe 
Warning: Unable to open /dev/hdc read-write (Read-only file system).  /dev/hdc has been opened read-only.
2. 安装drbd

[root@node1 tmp]# yum -y --nogpgcheck localinstall drbd83-8.3.8-1.el5.centos.i386.rpm kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
3.为drbd提供配置文件

[root@node1 tmp]# cp /usr/share/doc/drbd83-8.3.8/drbd.conf  /etc/ 
cp: overwrite `/etc/drbd.conf'? y  
[root@node1 tmp]# cd /etc/drbd.d/ 
[root@node1 drbd.d]# cp global_common.conf global_common.conf.back 
[root@node1 drbd.d]# ll 
total 16 
-rwxr-xr-x 1 root root 1418 Jun  4  2010 global_common.conf 
-rwxr-xr-x 1 root root 1418 Aug 10 00:45 global_common.conf.back
4.编辑配置文件

[code][root@node1 drbd.d]# vi /etc/drbd.d/global-common.conf
global {

usage-count no;

# minor-count dialog-refresh disable-ip-verification

}

common {

protocol C;

handlers {

pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";

pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";

local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";

# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";

# split-brain "/usr/lib/drbd/notify-split-brain.sh root";

# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";

# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";

# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;

}

startup {

#wfc-timeout 120;

#degr-wfc-timeout 120;

}

disk {

on-io-error detach;

#fencing resource-only;

}

net {

cram-hmac-alg "sha1";

shared-secret "mydrbdlab";

}

syncer {

rate 1000M;

}

}

[/code]

5. 定义一个资源

[root@node1 ~]# vi /etc/drbd.d/web.res   内容如下
 
resource web { 
  on node1.yue.com { 
    device    /dev/drbd0; 
    disk      /dev/sdb1;               对应刚才创建的新分区
    address   172.16.45.11:7789; 
    meta-disk internal; 
  } 
 
 on node2.yue.com { 
    device    /dev/drbd0; 
    disk      /dev/sdb1; 
    address   172.16.45.12:7789; 
    meta-disk internal; 
  } 
}
6. 在node2 上做和以上相同的设置

7. 在两个节点上初始化已定义的资源并启动服务:

1)初始化资源,在Node1和Node2上分别执行:

[root@node1 tmp]# drbdadm create-md web 
Writing meta data... 
initializing activity log 
NOT initialized bitmap 
New drbd meta data block successfully created. 
 
[root@node1 tmp]# ssh node2 'drbdadm create-md web'    在node1 上利用双机互信远程执行node2上的资源初始化
NOT initialized bitmap 
Writing meta data... 
initializing activity log 
New drbd meta data block successfully created
2)启动服务,在Node1和Node2上分别执行

# /etc/init.d/drbd start

3)查看启动状态: -->也可以使用drbd-overview命令来查看

[root@node1 ~]# drbd-overview 
  0:web  Connected Secondary/Secondary Inconsistent/Inconsistent C r----
从上面的信息中可以看出此时两个节点均处于Secondary状态。于是,我们接下来需要将其中一个节点设置为Primary。

[root@node1 ~]# drbdsetup /dev/drbd0  primary -o         设置为Primary的节点
[root@node1 ~]# drbd-overview 
  0:web  SyncSource Primary/Secondary UpToDate/Inconsistent C r----  
    [===>................] sync'ed: 20.2% (408716/505964)K delay_probe: 8  数据同步过程已经开始       
[root@node1 ~]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r----  数据同步完成
8. 创建文件系统

文件系统的挂载只能在Primary节点进行,因此,也只有在设置了主节点后才能对drbd设备进行格式化

[root@node1 ~]# mke2fs -j /dev/drbd0 
mke2fs 1.39 (29-May-2006) 
Filesystem label= 
OS type: Linux 
Block size=1024 (log=0) 
Fragment size=1024 (log=0) 
126976 inodes, 505964 blocks 
25298 blocks (5.00%) reserved for the super user 
First data block=1 
Maximum filesystem blocks=67633152 
62 block groups 
8192 blocks per group, 8192 fragments per group 
2048 inodes per group 
Superblock backups stored on blocks:  
    8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 
 
Writing inode tables: done                             
Creating journal (8192 blocks): done 
Writing superblocks and filesystem accounting information: done 
 
This filesystem will be automatically checked every 32 mounts or 
180 days, whichever comes first.  Use tune2fs -c or -i to override.
挂载文件系统

[root@node1 ~]# mkdir /data              建立挂载目录 
[root@node1 ~]# mount /dev/drbd0 /data 
[root@node1 ~]# cd /data/ 
[root@node1 data]# ls 
lost+found 
[root@node1 data]# cp /etc/fstab .       拷贝一个文件到当前目录中 
[root@node1 data]# ls 
fstab  lost+found
9. 切换Primary和Secondary节点

对主Primary/Secondary模型的drbd服务来讲,在某个时刻只能有一个节点为Primary,因此,要切换两个节点的角色,只能在先将原有的Primary节点设置为Secondary后,才能原来的Secondary节点设置为Primary

[root@node1 ~]# umount /data/ 
[root@node1 ~]# drbdadm secondary web 
[root@node1 ~]# drbd-overview 
  0:web  Connected Secondary/Secondary UpToDate/UpToDate C r----  
 
设置node2 为主,查看文件
 
[root@node2 ~]# drbd-overview 
  0:web  Connected Secondary/Secondary UpToDate/UpToDate C r----  
[root@node2 ~]# drbdadm primary web 
[root@node2 ~]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r----  
[root@node2 ~]# mkdir /data               建立挂载目录,注意此时是在node2 上
[root@node2 ~]# mount /dev/drbd0 /data/  
[root@node2 ~]# ls /data/ 
fstab  lost+found
先让drbd切换回到node1 上

[root@node2 tmp]# umount /data/ 
[root@node2 tmp]# drbdadm secondary web 
[root@node2 tmp]# drbd-overview 
  0:web  Connected Secondary/Secondary UpToDate/UpToDate C r---- 
  
[root@node1 tmp]# drbdadm primary web 
[root@node1 tmp]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r---- 
[root@node1 tmp]# mount /dev/drbd0 /data/
二、安装MySQL-5.5.24

1.创建Mysql用户

[root@node1 tmp]# useradd -u 189 mysql 
[root@node1 tmp]# id mysql 
uid=189(mysql) gid=189(mysql) groups=189(mysql) context=root:system_r:unconfined_t:SystemLow-SystemHigh
2. 数据目录

[root@node1 tmp]# chown -R mysql:mysql /data    更改属主属组
[root@node1 tmp]# ll /data/ 
total 14 
-rw-r--r-- 1 mysql mysql   651 Aug 10 09:45 fstab 
drwx------ 2 mysql mysql 12288 Aug 10 09:44 lost+found
[root@node1 tmp]# tar xf  mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/   解压  
[root@node1 tmp]# cd /usr/local/ 
[root@node1 local]# ln -sv mysql-5.5.24-linux2.6-i686/ mysql     创建软连接 
create symbolic link `mysql' to `mysql-5.5.24-linux2.6-i686/' 
[root@node1 local]# cd mysql 
[root@node1 mysql]# chown -R mysql:mysql .      将当前目录下的文件的属主属组都改为mysql

3. 初始化

[root@node1 mysql]# scripts/mysql_install_db --datadir=/data --user=mysql  指定数据目录和用户
Installing MySQL system tables... 
OK 
Filling help tables... 
OK 
 
To start mysqld at boot time you have to copy 
support-files/mysql.server to the right place for your system 
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 
To do so, start the server, then issue the following commands: 
 
./bin/mysqladmin -u root password 'new-password' 
./bin/mysqladmin -u root -h node1.yue.com password 'new-password' 
 
Alternatively you can run: 
./bin/mysql_secure_installation 
 
which will also give you the option of removing the test 
databases and anonymous user created by default.  This is 
strongly recommended for production servers. 
 
See the manual for more instructions. 
 
You can start the MySQL daemon with: 
cd . ; ./bin/mysqld_safe & 
 
You can test the MySQL daemon with mysql-test-run.pl 
cd ./mysql-test ; perl mysql-test-run.pl 
 
Please report any problems with the ./bin/mysqlbug script!
4. 配置文件

[root@node1 mysql]# cp support-files/my-large.cnf /data/my.cnf      将mysql的配置文件放在drbd0上,以便于当文件修改时可以同步到两台主机上
[root@node1 mysql]# vi /data/my.cnf
           在[mysqld]段修改如下两项:
                    thread_concurrency = 2
datadir=/data
[root@node1 mysql]# ln -sv /data/my.cnf  /etc/my.cnf               为mysql的主配置文件创建一个链接文件
create symbolic link `/etc/my.cnf' to `/data/my.cnf' 
[root@node1 mysql]# ll /etc/my.cnf 
lrwxrwxrwx 1 root root 12 Aug 10 10:15 /etc/my.cnf -> /data/my.cnf 
 
[root@node1 mysql]# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld        提供mysql的启动脚本
[root@node1 mysql]# chown -R root .     将当前文件夹下文件属主改为root
5. 启动mysql

[root@node1 mysql]# export PATH=$PATH:/usr/local/mysql/bin/       为了简化实验过程,这里的设置只时临时有效,(若想要永久有效需要写入相应的配置文件中,具体内容可以参考本博客的其它文章)
 
[root@node1 mysql]# /etc/init.d/mysqld start 
Starting MySQL.......                                      [  OK  ]  
[root@node1 mysql]# mysql                         mysql在第一次登录时密码为空,最好在登录后为mysql建立一个密码
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.5.24-log MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 
 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql> SHOW DATABASES; 
+---------------------+ 
| Database            | 
+---------------------+ 
| information_schema  | 
| #mysql50#lost+found | 
| mysql               | 
| performance_schema  | 
| test                | 
+---------------------+ 
5 rows in set (0.00 sec) 
 
mysql> CREATE DATABASE testdb;           创建一个数据库
Query OK, 1 row affected (0.04 sec) 
 
mysql> SHOW DATABASES; 
+---------------------+ 
| Database            | 
+---------------------+ 
| information_schema  | 
| #mysql50#lost+found | 
| mysql               | 
| performance_schema  | 
| test                | 
| testdb              | 
+---------------------+ 
6 rows in set (0.00 sec) 
 
mysql> quit 
Bye
[root@node1 mysql]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r---- /data ext3 479M 40M 415M 9%  
   
[root@node1 mysql]# /etc/init.d/mysqld stop 
Shutting down MySQL.                                       [  OK  ] 
[root@node1 mysql]# umount /data 
[root@node1 mysql]# drbdadm secondary web 
[root@node1 mysql]# drbd-overview 
  0:web  Connected Secondary/Secondary UpToDate/UpToDate C r----   
[root@node1 mysql]# scp /etc/rc.d/init.d/mysqld  node2:/etc/rc.d/init.d/          将mysql的启动脚本传到node2上  
mysqld                                                  100%   10KB  10.4KB/s   00:00

mysql在node2 上的相关设置(注意:此时的mysql不能再初始化了)

[root@node2 tmp]# useradd -u 189 mysql 
[root@node2 tmp]# id mysql 
uid=189(mysql) gid=189(mysql) groups=189(mysql) context=root:system_r:unconfined_t:SystemLow-SystemHigh 

 
[root@node2 tmp]# tar xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/ 
 
[root@node2 tmp]# cd /usr/local/ 
[root@node2 local]# ln -sv mysql-5.5.24-linux2.6-i686/ mysql 
create symbolic link `mysql' to `mysql-5.5.24-linux2.6-i686/' 
[root@node2 local]# cd mysql 
[root@node2 mysql]# chown -R root:mysql .
设置node2 为primary

[root@node2 ~]# drbd-overview 
  0:web  Connected Secondary/Secondary UpToDate/UpToDate C r----  
[root@node2 ~]# drbdadm primary web 
[root@node2 ~]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r----
[root@node2 ~]# mkdir /data 
[root@node2 ~]# mount /dev/drbd0 /data/ 
[root@node2 mysql]# drbd-overview 
  0:web  Connected Primary/Secondary UpToDate/UpToDate C r---- /data ext3 479M 40M 415M 9%  
[root@node2 ~]# ln -sv /data/my.cnf  /etc/my.cnf         软链接到mysql的主配置文件加
create symbolic link `/etc/my.cnf' to `/data/my.cnf' 
[root@node2 ~]# export PATH=$PATH:/usr/local/mysql/bin/

启动mysql验证是否是可以使用相同的数据目录:

[root@node2 mysql]# mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.5.24-log MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 
 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql> SHOW DATABASES; 
+--------------------+ 
| Database           | 
+--------------------+ 
| information_schema | 
| mysql              | 
| performance_schema | 
| test               | 
| testdb             | 
+--------------------+ 
5 rows in set (0.09 sec) 
 
mysql> quit 
Bye
三、安装corosync 和 pacemaker (在node1 和node2 上都要安装和配置)

首先停掉node1和node2 上的mysql、drbd,不能让其开机自动启动

[root@node2 ~]# /etc/init.d/mysqld stop 
Shutting down MySQL.                                       [  OK  ] 
[root@node2 ~]# /etc/init.d/drbd status 
drbd driver loaded OK; device status: 
version: 8.3.8 (api:88/proto:86-94) 
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16 
m:res  cs         ro                 ds                 p  mounted  fstype 
0:web  Connected  Primary/Secondary  UpToDate/UpToDate  C  /data    ext3 
 
[root@node2 ~]# umount /data/ 
[root@node2 ~]# /etc/init.d/drbd status 
drbd driver loaded OK; device status: 
version: 8.3.8 (api:88/proto:86-94) 
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16 
m:res  cs         ro                 ds                 p  mounted  fstype 
0:web  Connected  Primary/Secondary  UpToDate/UpToDate  C 
[root@node2 ~]# /etc/init.d/drbd stop
Stopping all DRBD resources: .
[root@node2 ~]# drbd-overview 
drbd not loaded 
 
[root@node2 ~]# chkconfig --list drbd 
drbd            0:off   1:off   2:on    3:on    4:on    5:on    6:off 
[root@node2 ~]# chkconfig  drbd off 
[root@node2 ~]# chkconfig --list drbd 
drbd            0:off   1:off   2:off   3:off   4:off   5:off   6:off 
[root@node1 ~]# /etc/init.d/drbd stop
Stopping all DRBD resources: .

[root@node1 ~]# chkconfig  drbd off
在node1 上的安装和配置:

需要用到以下几个rpm包:

cluster-glue-1.0.6-1.6.el5.i386.rpm              
cluster-glue-libs-1.0.6-1.6.el5.i386.rpm          
corosync-1.2.7-1.1.el5.i386.rpm             
corosynclib-1.2.7-1.1.el5.i386.rpm            
heartbeat-3.0.3-2.3.el5.i386.rpm                 
heartbeat-libs-3.0.3-2.3.el5.i386.rpm                             
libesmtp-1.0.4-5.el5.i386.rpm                               
pacemaker-1.1.5-1.1.el5.i386.rpm                                     
pacemaker-cts-1.1.5-1.1.el5.i386.rpm                                      
pacemaker-libs-1.1.5-1.1.el5.i386.rpm                                     
resource-agents-1.0.4-1.1.el5.i386.rpm
1. 安装: # yum -y --nogpgcheck localinstall *.rpm

2. 关闭 heartbeat服务: # chkconfig heartbeat off

3. 提供 corosync的配置文件

[root@node1 cluster]# cd /etc/corosync/ 
[root@node1 corosync]# cp corosync.conf.example corosync.conf 
 # vi /etc/corosync/corosync.conf
 
compatibility: whitetank                            兼容性,兼容以前的版本 
 
totem {                                        多个corosynce 的节点之间心跳信息的传递方式 
        version: 2                            
        secauth: off                        安全认证 
        threads: 0                            启动几个线程 
        interface {                            通过哪个网络接口传递心跳信息,若有多个接口,则ringnumber不能相同 
                ringnumber: 0 
                bindnetaddr: 172.16.45.0        绑定的网络地址 
                mcastaddr: 226.94.100.1            多播地址 
                mcastport: 5405 
        } 
} 
 
logging { 
        fileline: off 
        to_stderr: no                            发往到标准错误输出 
        to_logfile: yes 
#        to_syslog: yes 
        logfile: /var/log/cluster/corosync.log            
        debug: off 
        timestamp: on                            是否记录时间戳 
        logger_subsys { 
                subsys: AMF                    想要启用AMF         需要安装OpenAIS  和OpenAis-libs 
                debug: off 
        } 
} 
 
amf { 
        mode: disabled 
} 
    
    另外在配置文件中还需要添加如下内容: 
service { 
        ver:  0 
        name: pacemaker 
        use_mgmtd: yes 
} 
 
aisexec { 
        user:   root 
        group:  root    
        }
4. 节点密钥文件

[root@node1 corosync]# corosync-keygen                    生成节点密钥文件 
Corosync Cluster Engine Authentication key generator. 
Gathering 1024 bits for key from /dev/random. 
Press keys on your keyboard to generate entropy. 
Writing corosync key to /etc/corosync/authkey. 
 
[root@node1 corosync]# scp -p authkey corosync.conf  node2:/etc/corosync/        传送到node2 
authkey                                                                 100%  128     0.1KB/s   00:00    
corosync.conf                                                           100%  526     0.5KB/s   00:00
5. 记得在node2 安装corosync和其相关的rpm包

6. 启动corosync 服务

root@node1 ~]# /etc/init.d/corosync start  
Starting Corosync Cluster Engine (corosync):               [  OK  ]   
      
[root@node1 ~]#  grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/corosync.log   查看corosync引擎是否正常启动    
      
[root@node1 ~]# grep "TOTEM" /var/log/corosync.log   查看初始化成员节点通知是否正常发出 
 
 
[root@node1 ~]# grep pcmk_startup /var/log/corosync.log   查看pacemaker是否正常启动     
 
[root@node1 ~]# grep "ERROR" /var/log/corosync.log    检查启动过程中是否有错误产生
如果上面命令执行均没有问题,接着可以执行如下命令启动node2上的corosync

注意:启动node2需要在node1上使用如上命令进行,不要在node2节点上直接启动

[root@node1 corosync]# ssh node2 '/etc/init.d/corosync start' 
Starting Corosync Cluster Engine (corosync): [  OK  ]
配置集群的工作属性,禁用stonith

corosync默认启用了stonith,而当前集群并没有相应的stonith设备,因此此默认配置目前尚不可用, 我们里可以通过如下方式先禁用stonith

[root@node1 ~]# crm configure 
crm(live)configure# show 
node node1.yue.com \ 
    attributes standby="off" 
node node2.yue.com 
property $id="cib-bootstrap-options" \ 
    dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \ 
    cluster-infrastructure="openais" \ 
    expected-quorum-votes="2" 
crm(live)configure# property stonith-enabled=false      禁用stonith
crm(live)configure# property no-quorum-policy=ignore 
crm(live)configure# show 
node node1.yue.com \ 
    attributes standby="off" 
node node2.yue.com 
property $id="cib-bootstrap-options" \ 
    dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \ 
    cluster-infrastructure="openais" \ 
    expected-quorum-votes="2" \ 
    stonith-enabled="false" \ 
    no-quorum-policy="ignore" 
crm(live)configure# commit 
crm(live)configure# exit 
bye
7. 查看集群节点状态

[root@node1 ~]# crm status 
============ 
Last updated: Fri Aug 10 12:51:26 2012 
Stack: openais 
Current DC: node1.yue.com - partition with quorum 
Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f 
2 Nodes configured, 2 expected votes 
0 Resources configured. 
============ 
 
Online: [ node1.yue.com node2.yue.com ]
本文出自 “昶x月” 博客,请务必保留此出处http://xyuex.blog.51cto.com/5131937/960617