成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

SUSE Linux搭建企業服務器的雙機配置過程

系統 Linux
SUSE企業版以優秀的性能贏得了很多企業的信賴。尤其是在SUSE企業版中提供的HA軟件是一款專業的高可用集群軟件產品,它不僅僅是一款雙機熱備軟件,它還為您提供Linux平臺上完整的高可用性解決方案。

隨著信息化建設的不斷推進,各大企事業單位的活動越來越多的依賴于其關鍵的業務信息系統,這些業務信息系統對整個機構的運營和發展起著至關重要的作用,一旦發生宕機故障或應用停機,將給機構帶來巨大的經濟損失。Suse企業版里提供的HA軟件是一款專業的高可用集群軟件產品,它不僅僅是一款雙機熱備軟件,它還為您提供Linux平臺上完整的高可用性解決方案。

當集群中的某個節點由于軟件或硬件原因發生故障時,集群系統可以把資源切換到其他健康的節點上,使整個系統能連續不間斷的對外提供服務,從而為機構24x365的關鍵業務提供了可靠的保障,達到了系統99.999%的高可用性和可靠性。SuSE Enterprise Linux 10.0是內置Linux 2.6.16內核的企業級服務器,較之SuSE Enterprise Linux 9.0,它在性能、可擴展性、易管理性和安全等方面都予以加強,并有眾多硬件和應用軟件支持。

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

一、 HeartBeat、Mon、Rsync簡介

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

Mon是一個后臺服務運行情況的監控和告警軟件,能夠對大多數標準服務進行監控和告警,其中包括SMTP服務、Telnet服務、FTP服務、NNTP 服務、HTTP服務、POP3服務、Samba服務和NFS服務等,還可以自己編寫告警事件和自定義服務。在本系統中,將使用Mon對兩臺主機的網絡連接情況和服務運行情況進行監控,目的是及時告警,并且自動恢復服務。 Rsync是一個用于數據同步的軟件,除了數據拷貝外,還有增量備份、同步owner、group和文件權限等重要信息的功能。在本系統中,使用 Rsync來同步主服務器和備用服務器的數據。

二、安裝環境

首先,需要準備兩臺PC服務器,每臺服務器有兩塊網卡,其物理網絡圖如圖1

安裝環境

網絡拓撲圖

圖1 網絡拓撲圖

雖然在 YaST2控制中心里有"高可用性"圖形化的配置向導,我們這里不介紹一個過程,中在講述原理和方法,主要是基于命令行的配置方式。首先在PC服務器上安裝SuSE Enterprise Linux 10.0系統,并將eth0配置為192.168.8.*網段,eth1配置為10.1.1.*網段,eth0鏈接對外的交換機,eth1用于兩臺機器的對連。

修改/etc /hosts文件,修改內容如下:

  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.*為心跳線IP地址,192.168.8.*為對外IP,192.168.8.112為浮動IP。并且,拷貝hosts文件到 linux2上:

  1. #scp /etc/hosts 10.1.1.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 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 

最后,修改啟動級別為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

通過yast2工具添加heartbeat,如圖片2

安裝HeartBeat

heartbeat安裝

圖2 heartbeat安裝

1)安裝HeartBeat軟件包??梢酝ㄟ^SuSE的光盤進行安裝,安裝命令如下:

  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 三個文件考入/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 

② 認證方式文件/etc/ha.d/authkeys

修改認證方式文件/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 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)啟動HeartBeat服務:

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

系統顯示信息如下:

  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 

通過運行"ps -ef|grep heartbeat"命令來查看進程:

  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和相關軟件包如下:

  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)啟動Apache:

  1. /etc/init.d/apache2 start 

并運行"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 /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)創建并編輯一個index.html文件:

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

在其中輸入"linux ha"的字樣,并保存退出。通過Client端訪問浮動IP:192.168.8.112,在linux1上成功安裝Apache服務后,在linux2 上執行以上操作,并且同樣測試其結果如圖3。

安裝HeartBeat

linux上的測試結果 

圖3 linux上的測試結果

四、測試HA系統

首先,關閉linux1的網絡服務(也可以使用shutdown):

#/etc/init.d/network stop

然后,查看linux2的log文件。正確結果是HA系統發現linux1已經 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! 

同時,在linux2上面檢查浮動IP,此時浮動IP應該綁定在linux2上。用"ifconfig"查看如圖3示。

這時,通過Client端訪問浮動IP:192.168.8.112,HTTP服務正常。

  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 

重新啟動linux1的網絡服務,浮動IP將又重新綁定到 linux1。此時通過Client端訪問浮動IP:192.168.8.112,HTTP服務同樣正常。#p#

五、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.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 (請指定郵件地址)  
  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 (請指定郵件地址) 

然后編輯/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時,"hostgroup www 10.1.1.1"應設置為"hostgroup www 10.1.1.2"。

在兩臺服務器上分別安裝和配置完成后,啟動Mon服務:

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

查看log文件,檢查服務狀態:

  1. #tail /var/log/messages  
  2. Nov 2 17:15:20 linux mon[14079]: mon 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 

查看log文件,檢查Mon服務的處理步驟。Mon首先發現WWW服務不能訪問,然后重啟Apache服務,并且發Email到指定的郵箱。

log文件內容如下:

  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 

郵件內容則如下:

  1. ALERT www/http: 10.1.1.1(Tue Nov 2 17:16:03)(標題)  
  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 

② 測試網絡監控和警告

關閉linux1的網絡服務:

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

Mon會發送告警郵件到指定郵箱,郵件內容略。

六、數據同步

假設這里只更新linux1服務器上的數據,由linux1定時向linux2復制數據,這就需要進行數據同步設置。

首先,設置linux1到linux2的SSH無密碼登錄:

  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 (應該不用輸入密碼就能登錄) 

然后,在linux1上運行Rsync進行數據同步:

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

這時會顯示如下內容:

  1. building file list ... done 

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

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

至此,具有數據同步、服務監控的高可用性服務系統搭建完成。

【編輯推薦】

  1. openSUSE中YaST包管理器的更新實戰
  2. Novell尋找買家 SUSE將落誰家?
  3. 在SUSE Linux下安裝ADSL上網撥號程序
  4. Linux操作系統中的智者 OpenSUSE 11.2
  5. openSUSE操作系統一個低調的王者
責任編輯:張浩 來源: IT168
相關推薦

2011-02-23 08:57:18

SUSE Linux企業服務器

2009-12-02 19:09:25

Open Suse L

2010-07-27 10:46:31

Linux NFS服務

2009-12-03 14:42:43

配置cvs服務器

2009-12-03 14:35:09

DHCP服務器配置

2009-11-26 09:24:48

Suse Linux

2014-08-06 11:25:00

LinuxSVN服務器

2012-09-25 14:45:09

SUSE ManageLinux服務器Linux

2009-12-03 17:33:19

Suse Linux系

2012-09-24 11:16:23

SUSE操作系統

2010-06-30 15:40:11

IISWEB FTP服務器

2010-03-29 09:00:11

Linux企業服務器

2010-06-30 15:24:04

FTP服務器配置過程

2009-10-10 17:29:00

RHEL 5搭建Sam

2010-08-23 11:04:12

Suse Linux

2010-09-25 15:04:07

LinuxDHCP服務器測試

2012-09-21 09:31:48

Linux服務器Windows

2010-08-03 13:26:36

linux搭建NFS服

2019-01-15 08:12:56

Linux服務器標配

2014-03-14 16:06:26

Linux服務器
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 黄频视频| 亚洲欧美日韩网站 | 91亚洲精华国产 | 亚洲精品九九 | 成人免费精品 | 在线日韩 | 国产精品一区二区久久 | 一级二级三级在线观看 | 狠狠av| 欧美电影网 | 亚洲综合在线网 | 日韩字幕| 成人亚洲一区 | 不卡一区二区三区四区 | 亚洲视频一区在线观看 | 最新中文字幕在线 | 成人免费黄视频 | 国产黄色av网站 | 日韩欧美二区 | 美女黄18岁以下禁止观看 | 久久er99热精品一区二区 | 激情综合五月 | 成人av鲁丝片一区二区小说 | 国产91丝袜在线18 | 日本免费一区二区三区 | 久久国产精品视频 | 在线看无码的免费网站 | 男女在线免费观看 | www.久草.com| 国产精品www | 亚洲精品美女视频 | 日韩五月天 | 国产一在线观看 | 日韩三区| 日日干天天操 | 婷婷久久一区 | 粉嫩av久久一区二区三区 | 免费看片国产 | 国产91观看 | 精品一区国产 | 亚洲国产成人精品久久 |