sles11-ha配置

一:实验环境:

节点
OS IP(eth0) DRBD_IP(eth1)
VIP DRBD_DISK
web1 sles11 sp2 192.168.10.11 172.16.1.1 192.168.10.100 /dev/sdb
web2 sles11 sp2 192.168.10.12 172.16.1.2

注:                                          

  1. 节点web1web2操作系统完全安装(gnome桌面环境)

  2. IP已按上图设置好

  3. 节点web1web2都添加了一块大小为2G的硬盘作为drbd使用

  4. hosts文件添加完毕

  5. 168.10.11  web1

  6. 168.10.12  web2

  7. ssh无密码访问已设置完毕

  8. 两节点时间已同步

 

 

二:安装SLES-HA扩展(其中包含drbd)和apache2

1.把下载好的SLE-HA-11-SP2-x86_64-GM-CD1.iso复制到任意目录下,这里为/root

2.输入yast2 repositories打开软件源配置

wKiom1WUy2byksDPAAFMKXEe-EQ658.jpg

3.点击“add”,选择“Local ISO Image”后,点击“Nest”,如下图所示

wKioL1WUzTuyKqU-AADkq2wDedc033.jpg

4.输入repository名称和具体路径,然后一直点击“Next”直至添加完成,如下图所示

wKioL1WUzVLTelTvAADLp9OIFr0108.jpg

5.查看配置好的安装源并刷新安装源

web1:~ # zypper lr

# | Alias                                            |Name                                            | Enabled | Refresh

--+--------------------------------------------------+--------------------------------------------------+---------+--------

1 | SUSE-linux-Enterprise-Server-11-sp211.2.2-1.234 | SUSE-linux-Enterprise-Server-11-sp2 11.2.2-1.234 | Yes     | No    

2 | sles11sp2-ha                                     |sles11sp2-ha                                    | Yes     | No  

web1:~ # zypper ref

Repository 'sles11sp2-ha' is up to date.

All repositories have been refreshed.

 

6.输入yast2 sw_single选择“Patterns”下的“High Availability”后点击“Accept”以完成“High Availability”的安装,如下图所示

wKiom1WUy5qTST85AAIzKbebUZg532.jpg

 

web2操作同web1

 

7.安装apache2

web1:~ # for i in 1 2; do ssh web$i zypper -n install apache2; done

8.设置apache2服务不随机启动

web1:~ # for i in 1 2; do ssh web$i chkconfig apache2 off; done

 

 

三:配置drbd

1.复制主配置文件drbd.conf到etc目录下

web1:~ # for i in 1 2; do ssh web$i chkconfig drbd off; done

web1:~ # for i in 1 2; do ssh web$i cp /usr/share/doc/packages/drbd-utils/drbd.conf /etc/drbd.conf; done

2.全局通用配置

web1:~ # cd /etc/drbd.d/

web1:/etc/drbd.d # cat global_common.conf   //红色字体处为修改或增加部分

global {

       # usage-count yes;

       usage-count no;

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

}

 

common {

       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 degr-wfc-timeoutoutdated-wfc-timeout wait-after-sb

       }

 

       options {

                # cpu-maskon-no-data-accessible

       }

 

       disk {

                # size max-bio-bvecson-io-error fencing disk-barrier disk-flushes

                # disk-drain md-flushesresync-rate resync-after al-extents

                # c-plan-ahead c-delay-targetc-fill-target c-max-rate

                # c-min-rate disk-timeout

       }

 

       net {

                # protocol timeoutmax-epoch-size max-buffers unplug-watermark

                # connect-int ping-intsndbuf-size rcvbuf-size ko-count

                # allow-two-primariescram-hmac-alg shared-secret after-sb-0pri

                # after-sb-1pri after-sb-2prialways-asbp rr-conflict

                # ping-timeoutdata-integrity-alg tcp-cork on-congestion

                # congestion-fillcongestion-extents csums-alg verify-alg

                # use-rle

                protocol C;

                cram-hmac-alg sha1;

                shared-secret"wjcyf";

       }

       syncer {

                rate 150M;

        }

}

3.增加一个名为r0的资源

web1:/etc/drbd.d # touch r0.res

web1:/etc/drbd.d # cat r0.res

resource r0 {

       device /dev/drbd0;

       disk /dev/sdb;

       meta-disk internal;

       on web1 {

                address 172.16.1.1:7789;

                }

       on web2 {

                address 172.16.1.2:7789;

                }

}

4.复制global_common.conf和r0.res到web2对应的目录下

web1:/etc/drbd.d # scp global_common.conf r0.res web2:/etc/drbd.d/

5.为资源r0创建元数据

web1:~ # drbdadm create-md r0

Writing meta data...

initializing activity log

NOT initializing bitmap

New drbd meta data block successfully created.

web1:~ # ssh web2 drbdadm create-md r0

NOT initializing bitmap

Writing meta data...

initializing activity log

New drbd meta data block successfullycreated.

6.启动drbd服务

web1:~ # /etc/init.d/drbd start

Starting DRBD resources: [

    create res: r0

  prepare disk: r0

   adjust disk: r0

    adjust net: r0

]

web2:~ # /etc/init.d/drbd start

Starting DRBD resources: [

    create res: r0

  prepare disk: r0

   adjust disk: r0

    adjust net: r0

]

7.查看目前的状态

web1:~ # drbd-overview

 0:r0/0  Connected Secondary/Secondary Inconsistent/Inconsistent C r-----

8.把web1设置为主节点开始同步数据

web1:~ # drbdadm -- --overwrite-data-of-peer primary r0

web1:~ # cat /proc/drbd

version: 8.4.1 (api:1/proto:86-100)

GIT-hash:91b4c048c1a0e06777b5f65d312b38d47abaea80 build by phil@fat-tyre, 2011-12-2012:43:15

 0:cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----

   ns:536912 nr:0 dw:0 dr:541336 al:0 bm:32 lo:0 pe:2 ua:4 ap:0 ep:1 wo:boos:1561500

       [====>...............] sync'ed: 25.6% (1561500/2097052)K

       finish: 0:00:14 speed: 107,108 (107,108) K/sec

web1:~ # cat /proc/drbd

version: 8.4.1 (api:1/proto:86-100)

GIT-hash:91b4c048c1a0e06777b5f65d312b38d47abaea80 build by phil@fat-tyre, 2011-12-20 12:43:15

 0:cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDateC r-----

   ns:2097052 nr:0 dw:0 dr:2097716 al:0 bm:128 lo:0 pe:0 ua:0 ap:0 ep:1wo:b oos:0

由上述红色字体处可知同步完成

9.创建文件系统,并挂载到/srv/www/htdocs目录下,放入测试网页,然后再卸载该挂载

web1:~ # mkfs.xfs /dev/drbd0

web1:~ # mount /dev/drbd0 /srv/www/htdocs

web1:~ # echo "SuSE Test Page">/srv/www/htdocs/index.html

web1:~ # umount /srv/www/htdocs

10.恢复drbd主备状态并停止drbd服务

web1:~ # drbdadm secondary r0

web1:~ # for i in 1 2; do ssh web$i /etc/init.d/drbd stop; done

 

至此drbd配置完成

 

四:配置ha

1.在任一节点上输入yast2 cluster(这里为web1),打开集群通信通道配置窗口,选择好节点间通讯的网口,输入多播地址和端口,并勾选“Auto Generate Node ID”后,点击“Next”,如下图所示

wKioL1WUzXjwurY9AAFp4qj5vag274.jpg

2.在集群安全页面,直接点击“Next”,如下图所示

wKiom1WUy7rgfkuKAADLVwr1kW8462.jpg

3.在集群服务页面,直接点击“Next”,如下图所示

wKioL1WUzYmxBkKoAADk2UCTbj0445.jpg

4. 后面一直“Next”直至完成

5.复制配置文件/etc/corosync/corosync.conf到web2的对应目录下

web1:~ # scp /etc/corosync/corosync.conf web2:/etc/corosync/

6.启动openais服务

web1:~ # rcopenais start

Starting OpenAIS/Corosync daemon(corosync): starting... OK

web1:~ # ssh web2 rcopenais start

Starting OpenAIS/Corosync daemon(corosync): starting... OK

7.设置openais服务开机启动

web1:~ # for i in 1 2; do ssh web$i chkconfig openais on; done

web1:~ # for i in 1 2; do ssh web$i chkconfig openais --list; done

openais                   0:off  1:off 2:off  3:on   4:off 5:on   6:off

openais                   0:off  1:off 2:off  3:on   4:off 5:on   6:off

8.查看目前的集群状态

web1:~ # crm status

============

Last updated: Wed Jul  1 17:06:26 2015

Last change: Wed Jul  1 17:01:16 2015 by hacluster via crmd on web1

Stack: openais

Current DC: web1 - partition with quorum

Version: 1.1.6-b988976485d15cb702c9307df55512d323831a5e

2 Nodes configured, 2 expected votes

0 Resources configured.

============

 

Online: [ web2 web1 ]

由以上可知web1和web2都在线,而且DC为web1,但未配置任何服务

 

五:配置和添加资源

1.设置hacluster用户密码为admin

web1:~ # for i in 1 2; do ssh web$i 'echo admin | passwd --stdin hacluster'; done

2.在web1节点上输入hb_gui &,打开集群配置窗口,点击左上角的连接,选择用户hacluster并输入密码admin,如下图所示

wKiom1WUy9GSnPKgAADbyEv8FeQ113.jpg

3.点击“OK”登录,登录后如下图所示

wKioL1WUzaOR-i2tAAGDR-S9Pqo721.jpg

由上图也可知,目前无任何资源

4.点击“CRM Config”,把右边的“No Quorum Policy”值改为“ignore”,把“Stonith Enabled”的钩去掉后,点击右下角的“Apply”保存配置,如下图所示

wKioL1WUza2h0fOXAAHXJblyH50174.jpg

5.添加资源,点击“Resources”后点击右边的“Add”,选择“Master”后,再点击“OK”,如下图所示

wKiom1WUy_XRRQ9aAAEVhPHltaM827.jpg

6.在弹出的页面内,输入ID为“ms_webdrbd”,同时加勾选最下方的三个复选框后,点击“Forward”,如下图所示

wKioL1WUzcrBQo6dAAIHRmdaj5o023.jpg

7.在弹出的界面内,直接点击“OK”,如下图所示

wKioL1WUzdfSwKFfAAEn8o39bfY512.jpg

8.为ms_webdrbd添加子资源,如下图所示

wKioL1WUzefRV7EcAAHFxomCVkI901.jpg

9.点击“Forward”,设置实例属性drbd_resource的值为“r0”,其他默认,如下图所示

wKiom1WUzDKwVjIyAAGJ_0YQx3M802.jpg

10.连续两次点击“Apply”保存配置后,点击左边的“Management”,查看配置好的资源,如下图所示

wKioL1WUzgXDOR0XAAGlvc90DFs828.jpg

11.添加一个名为websrv的组,其中包括webstore、apache2、webip,点击“Resource”―“Add”,资源类型选择“Group”,如下图所示

wKioL1WUzhSxoE31AAFHW79T2Dw152.jpg

12.点击“OK”输入组名“websrv”,如下图所示

wKioL1WUziDC4BhRAAGJ08xnTlM916.jpg

13.点击“Forward”,再点击“OK”,如下图所示

wKiom1WUzGXBdFo3AAFeLK85ejI493.jpg

14.添加webstore子资源

wKioL1WUzjihGIxCAAHakTm9G84866.jpg

wKiom1WUzH6DA98LAAG1ODL3K1g191.jpg

15.接着添加apache2子资源

wKiom1WUzI3TF15lAAFr1JM9k-c153.jpg

wKiom1WUzJjC3HQVAAG1oRyQH_s172.jpg

wKiom1WUzKLBbo01AAGWm9ZLTuU155.jpg

16,接着再添加webip子资源

wKiom1WUzKzgbVC7AAFr1JM9k-c075.jpg

wKioL1WUzn6Svu_qAAHKtnlFhd0941.jpg

wKiom1WUzMPTOThRAAGtflAri70679.jpg

17.最后点击“Cancel”取消继续添加子资源

wKioL1WUzpSBjMM6AAFsIOBLs64001.jpg

wKioL1WUzp7SJSx1AAGz-nZc0jA650.jpg

18.点击“Management”,查看添加好的所有资源

wKioL1WUzqqTTL9oAAGsgBSnbsw863.jpg

19.现在不要启动,点击“Constraints”―“Add”,选择“Resource Colocation”,如下图所示

wKioL1WUzrXBmklSAAEuLFjcovc598.jpg

20.设置的参数如下图所示(webstore必须和ms_webdrbd的Master角色在一起)

wKiom1WUzPnjrOyUAAHrYAwwOgo794.jpg

21.点击“OK”保存配置,接着添加“Resource Order”,如下图所示

wKiom1WUzQaRMVFeAAGLOBvUubo056.jpg

22. 设置的参数如下图所示(必须等到ms_webdrbd提升完成后,websrv才能启动)

wKioL1WUztmDyXn2AAH8u241DCQ585.jpg

23.最后点击“OK”保存配置

24.启动所有资源,首先启动ms_webdrbd,右击“ms_webdrbd”选择“start”,如下图所示

wKiom1WUzRyBGEm6AAG4zcOsagY919.jpg

25.接着再启动websrv(方法同启动ms_webdrbd)

26.所有资源启动后的状态如下图所示

wKioL1WUzu3ANSZKAAHHDfnikrg756.jpg

至此配置和资源添加完毕

 

六:高可用测试

1.右击上图中的“web1”选择“standby”,如下图所示

wKiom1WUzTOQu73EAAHoQQGGogE083.jpg

2.资源会切换到web2上,如下图所示

wKioL1WUzwOSU-xqAAHceiqSZ8o511.jpg

3.再重新使web1上线,右击“web1”选择“Active”,资源没有切回web1(由于是drbd的原因,当出现脑裂时,最好手动消除脑裂,所以最好不要设置资源回切)

wKiom1WUzUvytdhIAAHfXe_WOKU247.jpg

4.并且在资源切换过程中,访问http://192.168.10.100,都能看到页面“SuSE Test Page”

 

至此sles11-HA配置完成


本文出自 “永不止步” 博客,谢绝转载!

你可能感兴趣的:(HA,SLES)