Linux HA installation and configuration example

Source: Internet
Author: User

In linux, the HA installation configuration example first installs HA (yast-I heartbeat) server1: 192.168.1.100server2: 192.168.1.101 on the two servers respectively. edit/etc/ha. d/authkeysTxt code auth 3 #1 crc #2 sha1 HI! 3. md5 ciaoskey edit/etc/ha. d/ha. cfTxt code logfile/var/log/ha-log logfacility local0 keepalive 2 deadtime 30 warntime 10 udpport 19871 ucast eth0 192.168.1.101 # for server 2 configure # ucast eth0 192.168.1.100 login on node server1 server2 ping 101_1.1 edit/etc/ha. d/haresourcesTxt code server1 IPaddr: 192.168.1.110/32 nginxd both servers listen to the virtual IP address 110, and the browser can access 192.168.1.110. The ha service can use/etc/init. d/heartbeat start | stop | reload and so on manage the following simple test A, start the heartbeat Txt code ciaos of the two machines respectively :~ #/Etc/init. d/heartbeat start Starting High-Availability services2012/11/22 _17: 10: 41 INFO: Resource is stopped heartbeat: udpport setting must precede media workflow: baudrate setting must precede media workflow [10368]: _ 17:10:41 info: Version 2 support: false heartbeat [10368]: 2012/11/22 _ 17:10:41 WARN: Logging daemon is disabled -- enabling logging daemon is recomme Nded heartbeat [10368]: _ 17:10:41 info: * *********************** heartbeat [10368]: _ 17:10:41 info: Configuration validated. starting heartbeat 2.1.3 done (access 192.168.1.110 with a browser to display first server) B. Close the HA above 100, as shown in the following: Txt code ciaos :~ #/Etc/init. d/heartbeat stop Stopping High-Availability services done logd [10282]: 2012/11/22 _ 17:10:04 debug: Stopping ha_logd with pid 9650 logd [10282]: 2012/11/22 _ 17:10:04 info: waiting for pid = 9650 to exit logd [10282]: 2012/11/22 _ 17:10:05 info: Pid 9650 exited (access 192.168.1.110 via browser to display second server) C. Restart HA of 100, the browser's access result is restored to the first server. In this way, a simple master-slave WEB server is built with the LSB script/etc/init. d/nginxd as follows (copy to heartbeat In the installation directory) (the online version cannot find the status command, I wrote a simple function here, the program has some problems) Shell code #! /Bin/sh. /usr/lib/ocf/resource. d // heartbeat /. ocf-shellfuncs RETVAL = 0 prog = "nginx" nginxDir =/usr/local/nginx nginxd = $ nginxDir/sbin/nginx nginxConf = $ nginxDir/conf/nginx. conf nginxPid = $ nginxDir/logs/nginx. pid nginx_check () {if [[-e $ nginxPid]; then ps aux | grep-v grep | grep-q nginx if ($? = 0); then echo "$ prog already running... "exit 1 else rm-rf $ nginxPid &>/dev/null fi} start () {nginx_check if ($?! = 0); then true else echo-n $ "Starting $ prog:" '$ nginxd-c $ nginxConf' RETVAL = $? Echo [$ RETVAL = 0] & touch/var/lock/subsys/nginx return $ RETVAL fi} stop () {echo-n $ "Stopping $ prog: "killproc $ nginxd RETVAL =$? Echo [$ RETVAL = 0] & rm-f/var/lock/subsys/nginx $ nginxPid} reload () {echo-n $ "Reloading $ prog: "killproc $ nginxd-hup retval =$? Echo} status () {nginx_check if ($?! = 0); then return 0 else return 1 fi} monitor () {status $ prog &>/dev/null if ($? = 0); then RETVAL = 0 else RETVAL = 7 fi} case "$1" in start) start; stop) stop; restart) stop start; reload) reload; status) status $ prog RETVAL =$?; Monitor) monitor; *) echo $ "Usage: $0 {start | stop | restart | reload | status | monitor}" RETVAL = 1 esac exit $ RETVAL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.