Two Linux perfect for dual-machine hot standby "source network has not yet been practiced"

Source: Internet
Author: User
Tags new set

"Source: http://rainbird.blog.51cto.com/211214/225541/"

      always wanted to do Linux-based dual-machine hot standby, there is no time and opportunity. Always thought that as long as the two-machine hot preparation of the experiment must be both machines to add a storage. Even one months ago in the study of keepalived is still pondering keepalvied remove what conditions can realize the dual-machine hot standby. Until one months ago, when the storage solution was designed, the department boss gave a foreign link to introduce the DRBD+NFS implementation of the NFS hot-standby program, my eyes bright, this is what I always want to do not rely on storage to implement hot standby solution?        First to correct your own mistakes, do not contact keepalived and heartbeat when, hearsay thought keepalived appeared after there is no need to use heartbeat again. After careful study of these two legends found that: keepavled is specifically for the high-availability of the cluster, and Heartbeat is a two-machine hot standby death is a two-machine hot prepared dead people.        Well, let's talk about the principles of this article. Generally speaking, it is HEARTBEAT+DRBD. Heartbeat, needless to say, uses it to achieve the unified scheduling of resources, and DRBD is the highlight of this article. What about this one? I will not say the official stuff. In our own words, it is the real-time full replication of two hard drives of two machines (DRBD is disk mirroring). It has solved the problem of data consistency when two machines do double machine.       ok, nonsense, talk about the implementation environment of this article:      os:ubuntu9.04      IP1 : 192.168.1.11 drbd1      ip2:192.168.1.12 drbd2      DISK:/DEV/SDB1 (8G partition)        via DRBD, this partition of SDB1 on each machine will become our "storage". Let's go!++++++ now start with two machine configurations like ++++++      1. Set hosts      vi/etc/hosts      &NBSp;192.168.1.11 drbd1      192.168.1.12 drbd2       Note: For example, on the 1.11 machine. DRBD1 is what you do hostname command to see, rather than the one you write:)       2. Install and configure drbd      1). Install DRBD.        You can go to http://oss.linbit.com/drbd/to download the latest version. This article is designed to facilitate installation directly from Ubuntu sources       apt-get install drbd8-utils      2). Create a profile         If you install with Apt-get or yum, the configuration file is created by default, and the compiled installation does not. Regardless of whether you directly empty or rename, write the following content.       vi/etc/drbd.conf      common {         & nbsp;syncer {rate 10M;}           #速率       }      resou Rce r0 {          protocol c;          disk {On-io -error detach; }          on drbd1 {                  &N Bsp #drbd1为第一台机器的机器名  &nbsP            device/dev/drbd0;         #创建的虚拟资源               disk/dev/sdb1;             #实际的物理分区, be aware that it is a separate partition and is unformatted               address 192.168.1.11:7788; #第一台机器的ip地址, and communication ports               meta-disk internal;         #类型, LAN           }              on drbd2 {              device/dev/drbd0;   & nbsp          disk/dev/sdb1;               Address 192.168.1.12:7788;              meta-disk internal;   & nbsp      }         }   &nbsP  3) Create a resource       drbdadm create-md r0 #r0为刚才配置文件里的资源名        will prompt three questions, If you can speak English, you can read it, otherwise, enter directly. At the end you'll see       success      :)       4) Start the DRBD service       /ETC/INIT.D/DRBD start      cat/proc/drbd       You should be able to see         Note inside I labeled "secondary/secondary" means that now this plate is from the plate, the main disk does not know.        ++++++ now starts to operate only on DRBD1 ++++++      5) initialize the network drive       drbdsetup/dev/drbd0 primary-o      cat/proc/drbd         & nbsp   You will find that it is now "primary/secondary" and that you have already started syncing the hard drive status.        In order to view the sync situation in real time, you can perform       watch-n1 cat/proc/drbd   on DRBD1     Sync is still in progress        After a while, you will find that the success is complete!        After synchronization is complete, check the drive status on Drbd2        Note that the disk status is: "Secondary/primary"        Format network disks       6) set up DRBD boot up        to execute on both machines        chkconfig DRBD on      7) manually test if DRBD is working correctly        Set up 3 files on drbd1        Validate results on drbd2       ok, we have now determined that DRBD is working properly. Also believe that under such meticulous introduction, you are already familiar with how it works. We now have "networked storage". The next step is to have an east to help us schedule resources. Simple steps configuration Please heartbeat appearances       3. Configuring heartbeat      1) installation heartbeat      apt-get install heartbeat      2) Configure heartbeat      vi/etc/ heartbeat/ha.cf      logfacility     local0      keepalive 2 & nbsp    deadtime 10      auto_failback off      bcast   eth0 & nbsp    node drbd1 drbd2       vi/etc/heartbeat/haresources       DRBD1 drbddisk::r0 FILESYSTEM::/DEV/DRBD0::/mnt::ext3       vi authkeys      auth 3      3 MD5 abc       chmod authkeys       3) Copy the same configuration to drbd2      SCP Authkeys haresources ha.cf [email protected]:/etc/heartbeat/      4) Make sure the service is operational       /ETC/INIT.D/DRBD start      /etc/init.d/heartbeat start        5) toggle Test        View the status of DRBD via CAT/PROC/DRBD or Mount View/ MNT is not already mounted to determine the machine on which the resource resides. Then in the machine's/mnt new set up some files and stop the machine on the heartbeat. See if the/mnt is automatically mounted on the other machine? Is there a file that you just created? Good luck!        Summary: The two basic Linux implementations of the dual-machine hot standby is about to end. Review the environment: two machines, two separate partitions, preferably the same size, partition only, not formatted; Linux operating system; DRBD network disk; heartbeat implements resource scheduling; It seems that there are so many things. Perhaps you have to say, after reading this article, a little bit of practical significance is not, because just realized the shared disk. Haha, I would like to say, to play the power of a careful look at the heartbeat resource scheduling, with the big housekeeper, there is nothing to achieve the service?

Two Linux perfect for dual-machine hot standby "source network not yet practiced"

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.