版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、SUSE Linux搭建企业服务器的双机配置过程随着信息化建设的不断推进,各大企事业单位的活动越来越多的依赖于其关键的业务信息系统,这些业务信息系统对整个机构的运营和发展起着至关重要的作用,一旦发生宕机故障或应用停机,将给机构带来巨大的经济损失。Suse企业版里提供的HA软件是一款专业的高可用集群软件产品,它不仅仅是一款双机热备软件,它还为您提供Linux平台上完整的高可用性解决方案。当集群中的某个节点由于软件或硬件原因发生故障时,集群系统可以把资源切换到其他健康的节点上,使整个系统能连续不间断的对外提供服务,从而为机构24x365的关键业务提供了可靠的保障,达到了系统99.999%的高可用性
2、和可靠性。SuSE Enterprise Linux 10.0是内置Linux 内核的企业级服务器,较之SuSE Enterprise Linux 9.0,它在性能、可扩展性、易管理性和安全等方面都予以加强,并有众多硬件和应用软件支持。最近,笔者使用SuSE Enterprise Linux 10.0作为系统平台(使用其它Linux平台在安装部署时可能有小差异),在其上采用HeartBeat、Mon和Rsync等开源软件打造了一个高可用系统,挖掘了SuSE Linux的高可用性。下面我为大家详细介绍如何在Suse Linux搭建双机的配置过程。一、 HeartBeat、Mon、Rsync简介H
3、eartBeat是一个高可用性解决方案,其官方网站是www.linux- 。HeartBeat目前被广泛地应用,是很多商业高可用性软件的重要组成部分。大多数Linux厂商已经把它很好地集成在自己的系统中,例如SuSE Linux、RedHat和Debian Linux等。此外,HeartBeat也能很好地部署在Solaris和FreeBSD系统上。Mon是一个后台服务运行情况的监控和告警软件,能够对大多数标准服务进行监控和告警,其中包括SMTP服务、Telnet服务、FTP服务、NNTP 服务、HTTP服务、POP3服务、Samba服务和NFS服务等,还可以自己编写告警事件和自定义
4、服务。在本系统中,将使用Mon对两台主机的网络连接情况和服务运行情况进行监控,目的是及时告警,并且自动恢复服务。 Rsync是一个用于数据同步的软件,除了数据拷贝外,还有增量备份、同步owner、group和文件权限等重要信息的功能。在本系统中,使用 Rsync来同步主服务器和备用服务器的数据。二、安装环境首先,需要准备两台PC服务器,每台服务器有两块网卡,其物理网络图如图1安装环境图1 网络拓扑图虽然在 YaST2控制中心里有"高可用性"图形化的配置向导,我们这里不介绍一个过程,中在讲述原理和方法,主要是基于命令行的配置方式。首先在PC服务器上安装SuSE Enterpr
5、ise Linux 10.0系统,并将eth0配置为192.168.8.*网段,eth1配置为.*网段,eth0链接对外的交换机,eth1用于两台机器的对连。修改/etc /hosts文件,修改内容如下:1. .1 linux1 2. .2 linux2 3. 2 svr1 4. 3 svr2 5. 12 svr 注意,.*为心跳线IP地址,192.168.8.*为对外IP,12为浮动IP。并且,拷贝
6、hosts文件到 linux2上:1. #scp /etc/hosts .2:/etc 同时,关闭不需要的服务如下:1. chkconfig -s alsasound off 2. chkconfig -s nfs off 3. chkconfig -s nfsboot off 4. chkconfig -s portmap off 5. chkconfig -s slpd
7、60;off 6. chkconfig -s smbfs off 7. chkconfig -s setserial off 8. chkconfig -s splash off 9. chkconfig -s splash_early off 10. chkconfig -s splash_late off 11. chkconfig -s xdm
8、60;off 12. chkconfig -s fbset off 13. chkconfig -s cups off 14. chkconfig -s nscd off 15. chkconfig -s random off 最后,修改启动级别为3。找到/etc/inittab文件的如下几行:1. #The default runlevel is defined he
9、re id:5:initdefault: 将其改为如下:1. #The default runlevel is defined here id:3:initdefault: 三、安装HeartBeat通过yast2工具添加heartbeat,如图片2安装HeartBeat图2 heartbeat安装1)安装HeartBeat软件包。可以通过SuSE的光盘进行安装,安装命令如下:1. #rpm -Uvh heartbeat-0.6.i586.rpm libnet-1.1.1-4
10、2.1.i586.rpm heartbeat-pils-1.2.2-0.6.i586.rpm heartbeat-stonith-1.2.2-0.6.i586.rpm 2)修改HeartBeat的配置文件 主配置文件/etc/ha.d/ha.cf将/usr/share /doc/packages/heartbeat/目录下ha.cf、authkeys、haresources 三个文件考入/etc/ha.d/目录下,再将主配置文件/etc/ha.d/ha.cf修改如下:1. node linux1 2. node linux2
11、60;3. keepalive 2 4. deadtime 30 5. warntime 10 6. initdead 120 7. auto_failback on 8. bcast eth1 9. ping .1 10. ping .2 11. respawn hacluster /usr/lib/heartbeat/ipfail 认证方式文件/etc/ha.d/authkeys修改认
12、证方式文件/etc/ha.d/authkeys如下:1. auth 2 2. 2 crc 资源配置文件/etc/ha.d heresources假设现在正在进行Apache服务的HA系统,这里设置的服务必须在/etc /ha.d/resource.d和/etc/rc.d/init.d下有响应的脚本。修改资源配置文件/etc/ha.d/haresources如下:1. linux1 12 apache2 拷贝配置文件到linux21. #scp /etc/ha.d/ha.cf .
13、2:/etc/ha.d 2. #scp /etc/ha.d/authkeys .2:/etc/ha.d 3. #scp /etc/ha.d/haresources .2:/etc/ha.d 3)启动HeartBeat服务:1. #chkconfig -s heartbeat on 2. #chmod 600 /etc/ha.d/authkeys 3. #/etc/init.d/heartbeat start 系统显示信息如下:1
14、. Starting High-Availability servicesheartbeat:2010/4/01_23:05:19 info: Neither logfile nor logfacility found. 2. heartbeat: 2010/4/01_23:05:19 info: Logging defaulting to /var/log/ha-log 3. heartbeat: 2010/4/01_2
15、3:05:19 info:* 4. heartbeat: 2010/4/01_23:05:19 info:Configuration validated.Starting heartbeat 5. done 通过运行"ps -ef|grep heartbeat"命令来查看进程:1. root 4240 1 0 23:25 ? 00:00:01 heartbeat:heartbeat:master co
16、ntrol process 2. nobody 4242 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:FIFO reader 3. nobody 4243 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:write:bcast eth1 4. nobody 4244 4240 0
17、 23:05 ? 00:00:00 heartbeat:heartbeat:read:bcast eth1 5. nobody 4245 4240 0 23:05 ?00:00:00 heartbeat:heartbeat:write:ping .1 6. nobody 4246 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:read:pin
18、g .1 7. nobody 4247 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:write:ping .2 8. nobody 4248 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:read:ping .2 9. haclust 4254 4240 0 23:0
19、7 ? 00:00:00 /usr/lib/heartbeat/ipfail 1 安装Apache1)安装Apache和相关软件包如下:1. #rpm -Uvh apahe2-27.8.i586.rpm apache2-prefork-2.0.49-27.8.i586.rpm libapr0-2.0.49-27.8.i586.rpm 2. #SuSEconfig -module apache2 2)启动Apache:1. /etc/init.d/apache2 s
20、tart 并运行"ps -ef|grep apache"查看进程:1. root 4387 1 10 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf 2. wwwrun 4388 4387 0 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /e
21、tc/apache2/httpd.conf 3. wwwrun 4389 4387 0 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf 4. wwwrun 4390 4387 0 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd
22、.conf 5. wwwrun 4391 4387 0 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf 6. wwwrun 4392 4387 0 23:33 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf 3)创建并
23、编辑一个index.html文件:1. #vi /srv/www/htdocs/index.html 在其中输入"linux ha"的字样,并保存退出。通过Client端访问浮动IP:12,在linux1上成功安装Apache服务后,在linux2 上执行以上操作,并且同样测试其结果如图3。安装HeartBeat 图3 linux上的测试结果四、测试HA系统首先,关闭linux1的网络服务(也可以使用shutdown):#/etc/init.d/network stop然后,查看linux2的log文件。正确结果是HA系统
24、发现linux1已经 dead,由linux2接替其工作。1. #tail -f /var/log/ha-log 2. heartbeat: 2010/4/02_14:18:16 WARN: node .1:is dead 3. heartbeat: 2010/4/02_14:18:16 info: Link .1: dead. 4. heartbeat: 2010/4/02_14:18:27 info:
25、 mach_down takeover complete. 5. heartbeat: 2010/4/02_14:18:27 info: mach_down takeober complete for node linux1. 6. heartbeat: 2010/4/02_14:18:27 ERROR: Both machines own our resources! 同时,在li
26、nux2上面检查浮动IP,此时浮动IP应该绑定在linux2上。用"ifconfig"查看如图3示。这时,通过Client端访问浮动IP:12,HTTP服务正常。1. Eth0:0 Link encap:Ethernet HWaddr 00:0C:29:35:E6:63 2. Inet addr:12 bcast:55 Mask: 3. Interrupt:9 Base
27、address:0x1000 重新启动linux1的网络服务,浮动IP将又重新绑定到 linux1。此时通过Client端访问浮动IP:12,HTTP服务同样正常。五、Mon服务监控使用Mon可以实现监控网络、监控服务、E-mail告警和自动重启服务等。1) 安装Mon软件及其相关软件包。从光盘安装Time-period、Convert-BER、perl-Mon和fping:1. #rpm -Uvh perl-Time-period-1.20-301.1.i586.rpm perl-Convert-BER-1.3101-190.1.
28、i586.rpm perl-Mon-0.11-294.1.i586.rpm fping-2.2b1-819.1.i586.rpm 从下载并安装Time-HiRes:1. #tar xvzf Time-HiRes-1.65.tar.gz 2. #3cd Time-HiRes-1.65/perl Makefile.PL && make &&make test && make i
29、nstall 从/software/mon/下载并安装软件包mon-0.99.2.tar.bz2:1. #tar xvjf mon-0.99.2.tar.bz2 2. #cp -r mon-0.99.2 /usr/lib/mon 3. #mkdir /etc/mon 4. #cp /usr/lib/mon/etc/auth.cf /etc/mon 2) 编辑/etc/mon/mon.cf文件:1. cfbasedir =&
30、#160;/etc/mon 2. alertdir = /usr/lib/mon/alert.d 3. mondir = /usr/lib/mon/mon.d 4. statedir = /usr/lib/mon/state.d 5. logdir = /usr/lib/mon/log.d 6. dtlogfile = /usr/lib/mon/log.d/dt.log 7. maxprocs = 20&
31、#160;8. histlength = 100 9. randstart = 60s 10. dtlogging = yes 11. authtype = getpwnam 12. hostgroup servers .1 13. hostgroup www .1 14. watch servers 15. service ping 16.
32、 interval 1m 17. monitor fping.moniter 18. period wd Sun-Sat 19. alert mail.alert 97140 (请指定邮件地址) 20. watch www 21. service http 22. interval 1m 23. monitor http.monitor 24. period wd Sun
33、-Sat 25. alert apacherestart.alert 26. alert mail.alert 97140 (请指定邮件地址) 然后编辑/ust/lib/mon/alert.d /apacherestart.alert文件:1. #!/bin/sh 2. /etc/init.d/apache2 restart 3. chmod +x /usr/lib/mon/alert.d/apacherestart.alert 同样地,在linux2完成以
34、上步骤。但注意,在配置/etc/mon/mon.cf时,"hostgroup www .1"应设置为"hostgroup www "。在两台服务器上分别安装和配置完成后,启动Mon服务:1. #/usr/lib/mon/mon -c /etc/mon/mon.cf & 查看log文件,检查服务状态:1. #tail /var/log/messages 2. Nov 2 17:15:20 linux mon14079: m
35、on server started 运行"ps -ef|grep mon"查看进程,可以看到Mon服务成功启动。1. root 14079 1 0 17:15 ? 00:00:00 /usr/bin/perl/usr/lib/mon/mon -c/etc/mon/mon.cf 3)对Mon服务进行测试。 测试Apache服务的邮件告警和服务重启功能先关闭linux1的Apache服务:1. #/etc/init.d/apache2 stop
36、60;查看log文件,检查Mon服务的处理步骤。Mon首先发现WWW服务不能访问,然后重启Apache服务,并且发Email到指定的邮箱。log文件内容如下:1. Nov 2 17:15:59 linux mon14079: failure for www http 1099386959 .1 2. Nov 2 17:15:59 linux mon14079: calling alert apacherestart.alert for www/http(/usr/lib/mon/alert.d/apacherestart.alert,) .1 3. Nov 2 17:16:03 linux mon14079: calling alert mail.alert for www/http(/usr/lib/mon/alert.d/mail.alert,)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 环保和消防就业前景
- 某预制构件厂模具保养管控办法
- 近期医患关系事件盘点
- 医患关系目标人群选择
- 中餐研发职业发展方向
- 数字消费项目薪酬管理方案
- 医学人类学PBL术语文化语境
- XX中学2025-2026学年春季学期校园高等教育发展方案
- 2026年劳动防护用品试题及答案
- 2026年江西省公务员行测判断推理题库及答案
- 国家深海基地管理中心招聘笔试题库2025
- 2025年工程监理招聘面试参考题库及答案
- 2026年南京城市职业学院单招职业适应性考试题库必考题
- 2025年上海证券交易所招聘笔试模拟题之金融专业知识篇
- 2025年党员个人检视问题清单及整改措施表(四篇)
- 提高销售技巧培训
- 起重司索信号工培训课件
- 《涉外法治概论》课件 杜涛 第7-10章 对外贸易与经济制裁法律制度-涉外应急管理法律制度
- 智慧园艺课件
- 区域国别学的规范性及其在我国东南亚研究中的应用
- 信号与系统(第2版)课件 4.9 抽样定理
评论
0/150
提交评论