自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SUSE Linux搭建企業(yè)服務(wù)器的雙機(jī)配置過(guò)程

系統(tǒng) Linux
SUSE企業(yè)版以?xún)?yōu)秀的性能贏得了很多企業(yè)的信賴(lài)。尤其是在SUSE企業(yè)版中提供的HA軟件是一款專(zhuān)業(yè)的高可用集群軟件產(chǎn)品,它不僅僅是一款雙機(jī)熱備軟件,它還為您提供Linux平臺(tái)上完整的高可用性解決方案。

隨著信息化建設(shè)的不斷推進(jìn),各大企事業(yè)單位的活動(dòng)越來(lái)越多的依賴(lài)于其關(guān)鍵的業(yè)務(wù)信息系統(tǒng),這些業(yè)務(wù)信息系統(tǒng)對(duì)整個(gè)機(jī)構(gòu)的運(yùn)營(yíng)和發(fā)展起著至關(guān)重要的作用,一旦發(fā)生宕機(jī)故障或應(yīng)用停機(jī),將給機(jī)構(gòu)帶來(lái)巨大的經(jīng)濟(jì)損失。Suse企業(yè)版里提供的HA軟件是一款專(zhuān)業(yè)的高可用集群軟件產(chǎn)品,它不僅僅是一款雙機(jī)熱備軟件,它還為您提供Linux平臺(tái)上完整的高可用性解決方案。

當(dāng)集群中的某個(gè)節(jié)點(diǎn)由于軟件或硬件原因發(fā)生故障時(shí),集群系統(tǒng)可以把資源切換到其他健康的節(jié)點(diǎn)上,使整個(gè)系統(tǒng)能連續(xù)不間斷的對(duì)外提供服務(wù),從而為機(jī)構(gòu)24x365的關(guān)鍵業(yè)務(wù)提供了可靠的保障,達(dá)到了系統(tǒng)99.999%的高可用性和可靠性。SuSE Enterprise Linux 10.0是內(nèi)置Linux 2.6.16內(nèi)核的企業(yè)級(jí)服務(wù)器,較之SuSE Enterprise Linux 9.0,它在性能、可擴(kuò)展性、易管理性和安全等方面都予以加強(qiáng),并有眾多硬件和應(yīng)用軟件支持。

最近,筆者使用SuSE Enterprise Linux 10.0作為系統(tǒng)平臺(tái)(使用其它Linux平臺(tái)在安裝部署時(shí)可能有小差異),在其上采用HeartBeat、Mon和Rsync等開(kāi)源軟件打造了一個(gè)高可用系統(tǒng),挖掘了SuSE Linux的高可用性。下面我為大家詳細(xì)介紹如何在Suse Linux搭建雙機(jī)的配置過(guò)程。

一、 HeartBeat、Mon、Rsync簡(jiǎn)介

HeartBeat是一個(gè)高可用性解決方案,其官方網(wǎng)站是www.linux- ha.org。HeartBeat目前被廣泛地應(yīng)用,是很多商業(yè)高可用性軟件的重要組成部分。大多數(shù)Linux廠商已經(jīng)把它很好地集成在自己的系統(tǒng)中,例如SuSE Linux、RedHat和Debian Linux等。此外,HeartBeat也能很好地部署在Solaris和FreeBSD系統(tǒng)上。

Mon是一個(gè)后臺(tái)服務(wù)運(yùn)行情況的監(jiān)控和告警軟件,能夠?qū)Υ蠖鄶?shù)標(biāo)準(zhǔn)服務(wù)進(jìn)行監(jiān)控和告警,其中包括SMTP服務(wù)、Telnet服務(wù)、FTP服務(wù)、NNTP 服務(wù)、HTTP服務(wù)、POP3服務(wù)、Samba服務(wù)和NFS服務(wù)等,還可以自己編寫(xiě)告警事件和自定義服務(wù)。在本系統(tǒng)中,將使用Mon對(duì)兩臺(tái)主機(jī)的網(wǎng)絡(luò)連接情況和服務(wù)運(yùn)行情況進(jìn)行監(jiān)控,目的是及時(shí)告警,并且自動(dòng)恢復(fù)服務(wù)。 Rsync是一個(gè)用于數(shù)據(jù)同步的軟件,除了數(shù)據(jù)拷貝外,還有增量備份、同步owner、group和文件權(quán)限等重要信息的功能。在本系統(tǒng)中,使用 Rsync來(lái)同步主服務(wù)器和備用服務(wù)器的數(shù)據(jù)。

二、安裝環(huán)境

首先,需要準(zhǔn)備兩臺(tái)PC服務(wù)器,每臺(tái)服務(wù)器有兩塊網(wǎng)卡,其物理網(wǎng)絡(luò)圖如圖1

安裝環(huán)境

網(wǎng)絡(luò)拓?fù)鋱D

圖1 網(wǎng)絡(luò)拓?fù)鋱D

雖然在 YaST2控制中心里有"高可用性"圖形化的配置向?qū)?,我們這里不介紹一個(gè)過(guò)程,中在講述原理和方法,主要是基于命令行的配置方式。首先在PC服務(wù)器上安裝SuSE Enterprise Linux 10.0系統(tǒng),并將eth0配置為192.168.8.*網(wǎng)段,eth1配置為10.1.1.*網(wǎng)段,eth0鏈接對(duì)外的交換機(jī),eth1用于兩臺(tái)機(jī)器的對(duì)連。

修改/etc /hosts文件,修改內(nèi)容如下:

  1. 10.1.1.1 linux1  
  2. 10.1.1.2 linux2  
  3. 192.168.8.92 svr1  
  4. 192.168.8.93 svr2  
  5. 192.168.8.112 svr 

注意,10.1.1.*為心跳線(xiàn)IP地址,192.168.8.*為對(duì)外IP,192.168.8.112為浮動(dòng)IP。并且,拷貝hosts文件到 linux2上:

  1. #scp /etc/hosts 10.1.1.2:/etc 

同時(shí),關(guān)閉不需要的服務(wù)如下:

  1. chkconfig -s alsasound off  
  2. chkconfig -s nfs off  
  3. chkconfig -s nfsboot off  
  4. chkconfig -s portmap off  
  5. chkconfig -s slpd 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 off  
  12. chkconfig -s fbset off  
  13. chkconfig -s cups off  
  14. chkconfig -s nscd off  
  15. chkconfig -s random off 

最后,修改啟動(dòng)級(jí)別為3。找到/etc/inittab文件的如下幾行:

  1. #The default runlevel is defined here id:5:initdefault: 

將其改為如下:

  1. #The default runlevel is defined here id:3:initdefault: 

#p#

三、安裝HeartBeat

通過(guò)yast2工具添加heartbeat,如圖片2

安裝HeartBeat

heartbeat安裝

圖2 heartbeat安裝

1)安裝HeartBeat軟件包??梢酝ㄟ^(guò)SuSE的光盤(pán)進(jìn)行安裝,安裝命令如下:

  1. #rpm -Uvh heartbeat-1.2.2-0.6.i586.rpm libnet-1.1.1-42.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 三個(gè)文件考入/etc/ha.d/目錄下,再將主配置文件/etc/ha.d/ha.cf修改如下:

  1. node linux1  
  2. node linux2  
  3. keepalive 2  
  4. deadtime 30  
  5. warntime 10  
  6. initdead 120  
  7. auto_failback on  
  8. bcast eth1  
  9. ping 10.1.1.1  
  10. ping 10.1.1.2  
  11. respawn hacluster /usr/lib/heartbeat/ipfail 

② 認(rèn)證方式文件/etc/ha.d/authkeys

修改認(rèn)證方式文件/etc/ha.d/authkeys如下:

  1. auth 2  
  2. 2 crc 

③ 資源配置文件/etc/ha.d heresources

假設(shè)現(xiàn)在正在進(jìn)行Apache服務(wù)的HA系統(tǒng),這里設(shè)置的服務(wù)必須在/etc /ha.d/resource.d和/etc/rc.d/init.d下有響應(yīng)的腳本。修改資源配置文件/etc/ha.d/haresources如下:

  1. linux1 192.168.8.112 apache2 

④ 拷貝配置文件到linux2

  1. #scp /etc/ha.d/ha.cf 10.1.1.2:/etc/ha.d  
  2. #scp /etc/ha.d/authkeys 10.1.1.2:/etc/ha.d  
  3. #scp /etc/ha.d/haresources 10.1.1.2:/etc/ha.d 

3)啟動(dòng)HeartBeat服務(wù):

  1. #chkconfig -s heartbeat on  
  2. #chmod 600 /etc/ha.d/authkeys  
  3. #/etc/init.d/heartbeat start 

系統(tǒng)顯示信息如下:

  1. 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_23:05:19 info:**************************  
  4. heartbeat: 2010/4/01_23:05:19 info:Configuration validated.Starting heartbeat 1.2.2  
  5. done 

通過(guò)運(yùn)行"ps -ef|grep heartbeat"命令來(lái)查看進(jìn)程:

  1. root 4240 1 0 23:25 ? 00:00:01 heartbeat:heartbeat:master control 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 23:05 ? 00:00:00 heartbeat:heartbeat:read:bcast eth1  
  5. nobody 4245 4240 0 23:05 ?00:00:00 heartbeat:heartbeat:write:ping 10.1.1.1  
  6. nobody 4246 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:read:ping 10.1.1.1  
  7. nobody 4247 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:write:ping 10.1.1.2  
  8. nobody 4248 4240 0 23:05 ? 00:00:00 heartbeat:heartbeat:read:ping 10.1.1.2  
  9. haclust 4254 4240 0 23:07 ? 00:00:00 /usr/lib/heartbeat/ipfail 

1 安裝Apache

1)安裝Apache和相關(guān)軟件包如下:

  1. #rpm -Uvh apahe2-2.0.49-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)啟動(dòng)Apache:

  1. /etc/init.d/apache2 start 

并運(yùn)行"ps -ef|grep apache"查看進(jìn)程:

  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 /etc/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.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)創(chuàng)建并編輯一個(gè)index.html文件:

  1. #vi /srv/www/htdocs/index.html 

在其中輸入"linux ha"的字樣,并保存退出。通過(guò)Client端訪(fǎng)問(wèn)浮動(dòng)IP:192.168.8.112,在linux1上成功安裝Apache服務(wù)后,在linux2 上執(zhí)行以上操作,并且同樣測(cè)試其結(jié)果如圖3。

安裝HeartBeat

linux上的測(cè)試結(jié)果 

圖3 linux上的測(cè)試結(jié)果

四、測(cè)試HA系統(tǒng)

首先,關(guān)閉linux1的網(wǎng)絡(luò)服務(wù)(也可以使用shutdown):

#/etc/init.d/network stop

然后,查看linux2的log文件。正確結(jié)果是HA系統(tǒng)發(fā)現(xiàn)linux1已經(jīng) dead,由linux2接替其工作。

  1. #tail -f /var/log/ha-log  
  2. heartbeat: 2010/4/02_14:18:16 WARN: node 10.1.1.1:is dead  
  3. heartbeat: 2010/4/02_14:18:16 info: Link 10.1.1.1:10.1.1.1 dead................  
  4. heartbeat: 2010/4/02_14:18:27 info: 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! 

同時(shí),在linux2上面檢查浮動(dòng)IP,此時(shí)浮動(dòng)IP應(yīng)該綁定在linux2上。用"ifconfig"查看如圖3示。

這時(shí),通過(guò)Client端訪(fǎng)問(wèn)浮動(dòng)IP:192.168.8.112,HTTP服務(wù)正常。

  1. Eth0:0 Link encap:Ethernet HWaddr 00:0C:29:35:E6:63  
  2. Inet addr:192.168.0.112 bcast:192.168.9.255 Mask:255.255.254.0  
  3. Interrupt:9 Base address:0x1000 

重新啟動(dòng)linux1的網(wǎng)絡(luò)服務(wù),浮動(dòng)IP將又重新綁定到 linux1。此時(shí)通過(guò)Client端訪(fǎng)問(wèn)浮動(dòng)IP:192.168.8.112,HTTP服務(wù)同樣正常。#p#

五、Mon服務(wù)監(jiān)控

使用Mon可以實(shí)現(xiàn)監(jiān)控網(wǎng)絡(luò)、監(jiān)控服務(wù)、E-mail告警和自動(dòng)重啟服務(wù)等。

1) 安裝Mon軟件及其相關(guān)軟件包。

從光盤(pán)安裝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.i586.rpm 
    perl-Mon-0.11-294.1.i586.rpm fping-2.2b1-819.1.i586.rpm 

從www.cpan.org下載并安裝Time-HiRes:

  1. #tar xvzf Time-HiRes-1.65.tar.gz  
  2. #3cd Time-HiRes-1.65/perl Makefile.PL && make &&make test && make install 

從www.kernel.org/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 = /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 
  8. histlength = 100 
  9. randstart = 60s 
  10. dtlogging = yes 
  11. authtype = getpwnam 
  12. hostgroup servers 10.1.1.1 10.1.1.2  
  13. hostgroup www 10.1.1.1  
  14. watch servers  
  15. service ping  
  16. interval 1m  
  17. monitor fping.moniter  
  18. period wd {Sun-Sat}  
  19. alert mail.alert 97140@263.com (請(qǐng)指定郵件地址)  
  20. watch www  
  21. service http  
  22. interval 1m  
  23. monitor http.monitor  
  24. period wd {Sun-Sat}  
  25. alert apacherestart.alert  
  26. alert mail.alert 97140@263.com (請(qǐng)指定郵件地址) 

然后編輯/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完成以上步驟。但注意,在配置/etc/mon/mon.cf時(shí),"hostgroup www 10.1.1.1"應(yīng)設(shè)置為"hostgroup www 10.1.1.2"。

在兩臺(tái)服務(wù)器上分別安裝和配置完成后,啟動(dòng)Mon服務(wù):

  1. #/usr/lib/mon/mon -c /etc/mon/mon.cf & 

查看log文件,檢查服務(wù)狀態(tài):

  1. #tail /var/log/messages  
  2. Nov 2 17:15:20 linux mon[14079]: mon server started 

運(yùn)行"ps -ef|grep mon"查看進(jìn)程,可以看到Mon服務(wù)成功啟動(dòng)。

  1. root 14079 1 0 17:15 ? 00:00:00 /usr/bin/perl/usr/lib/mon/mon -c/etc/mon/mon.cf 

3)對(duì)Mon服務(wù)進(jìn)行測(cè)試。

① 測(cè)試Apache服務(wù)的郵件告警和服務(wù)重啟功能

先關(guān)閉linux1的Apache服務(wù):

  1. #/etc/init.d/apache2 stop 

查看log文件,檢查Mon服務(wù)的處理步驟。Mon首先發(fā)現(xiàn)WWW服務(wù)不能訪(fǎng)問(wèn),然后重啟Apache服務(wù),并且發(fā)Email到指定的郵箱。

log文件內(nèi)容如下:

  1. Nov 2 17:15:59 linux mon[14079]: failure for www http 
    1099386959 10.1.1.1  
  2. Nov 2 17:15:59 linux mon[14079]: calling alert apacherestart.
    alert for www/http(/usr/lib/mon/alert.d/apacherestart.alert,) 10.1.1.1  
  3. Nov 2 17:16:03 linux mon[14079]: calling alert mail.alert for 
    www/http(/usr/lib/mon/alert.d/mail.alert,song@heming.org) 10.1.1.1 

郵件內(nèi)容則如下:

  1. ALERT www/http: 10.1.1.1(Tue Nov 2 17:16:03)(標(biāo)題)  
  2. Sunmmary output : 10.1.1.1  
  3. Group : www  
  4. Service : http  
  5. Time noticed : Tue Nov 2 17:16:03 2004  
  6. Secs until next alert :  
  7. Members : 10.1.1.1  
  8. Detailed text (if any) follows:  
  9. HOST 10.1.1.1: connect: Connection refused 

② 測(cè)試網(wǎng)絡(luò)監(jiān)控和警告

關(guān)閉linux1的網(wǎng)絡(luò)服務(wù):

  1. #/etc/init.d/network stop 

Mon會(huì)發(fā)送告警郵件到指定郵箱,郵件內(nèi)容略。

六、數(shù)據(jù)同步

假設(shè)這里只更新linux1服務(wù)器上的數(shù)據(jù),由linux1定時(shí)向linux2復(fù)制數(shù)據(jù),這就需要進(jìn)行數(shù)據(jù)同步設(shè)置。

首先,設(shè)置linux1到linux2的SSH無(wú)密碼登錄:

  1. #ssh-keygen -t dsa  
  2. #scp /root/.ssh/id_dsa.pub 10.1.1.2:/root/.ssh/authorized_keys  
  3. #ssh 10.1.1.2 (應(yīng)該不用輸入密碼就能登錄) 

然后,在linux1上運(yùn)行Rsync進(jìn)行數(shù)據(jù)同步:

  1. #/usr/bin/rsync -avzoge ssh /srv/www/htdocs 10.1.1.2:/srv/www/htdocs 

這時(shí)會(huì)顯示如下內(nèi)容:

  1. building file list ... done 

將數(shù)據(jù)同步服務(wù)加入到Crontab,設(shè)置30分鐘(時(shí)間可以根據(jù)具體需要決定)定時(shí)數(shù)據(jù)同步一次。命令如下:

  1. #crontab -e  
  2. */30 * * * * /usr/sbin/rsync -avzoge ssh 10.1.1.2:/srv/www/html 

至此,具有數(shù)據(jù)同步、服務(wù)監(jiān)控的高可用性服務(wù)系統(tǒng)搭建完成。

【編輯推薦】

  1. openSUSE中YaST包管理器的更新實(shí)戰(zhàn)
  2. Novell尋找買(mǎi)家 SUSE將落誰(shuí)家?
  3. 在SUSE Linux下安裝ADSL上網(wǎng)撥號(hào)程序
  4. Linux操作系統(tǒng)中的智者 OpenSUSE 11.2
  5. openSUSE操作系統(tǒng)一個(gè)低調(diào)的王者
責(zé)任編輯:張浩 來(lái)源: IT168
相關(guān)推薦

2011-02-23 08:57:18

SUSE Linux企業(yè)服務(wù)器

2010-07-27 10:46:31

Linux NFS服務(wù)

2009-12-02 19:09:25

Open Suse L

2009-12-03 14:42:43

配置cvs服務(wù)器

2009-12-03 14:35:09

DHCP服務(wù)器配置

2009-11-26 09:24:48

Suse Linux

2014-08-06 11:25:00

LinuxSVN服務(wù)器

2012-09-25 14:45:09

SUSE ManageLinux服務(wù)器Linux

2009-12-03 17:33:19

Suse Linux系

2010-06-30 15:40:11

IISWEB FTP服務(wù)器

2012-09-24 11:16:23

SUSE操作系統(tǒng)

2009-10-10 17:29:00

RHEL 5搭建Sam

2010-06-30 15:24:04

FTP服務(wù)器配置過(guò)程

2010-03-29 09:00:11

Linux企業(yè)服務(wù)器

2012-09-21 09:31:48

Linux服務(wù)器Windows

2010-09-25 15:04:07

LinuxDHCP服務(wù)器測(cè)試

2014-03-14 16:06:26

Linux服務(wù)器

2019-01-15 08:12:56

Linux服務(wù)器標(biāo)配

2010-08-03 13:26:36

linux搭建NFS服

2010-01-07 15:37:09

Linux配置DNS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)