尊龙凯时人生就是博

ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳ

ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳ

СÐò£º

ÔÚÅÌËã»úÁìÓò£¬¸ß¿ÉÓÃÐÔ£¨high availability£©ÊÇÒ»ÖÖÊÖÒÕ£¬Ä¿µÄÊÇΪÁËÌá¸ßϵͳµÄ¿É¿¿ÐԺͿÉÓÃÐÔ¡£ÔÚ¼¯ÈºÇéÐÎÖУ¬¸ß¿ÉÓõÄÎļþϵͳÊÇ°ü¹ÜϽµµÍ¬ÐøÔËÐеÄÖ÷Òª×é³É²¿·ÖÖ®Ò»¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳ£¬ÒÔ¼°¸ø³öÏìÓ¦µÄ´úÂëʾÀý¡£

×°ÖÃÈí¼þ°ü

Ê×ÏÈ£¬È·±£ÏµÍ³ÉÏÒѾ­×°ÖÃÁËÐëÒªµÄÈí¼þ°ü¡£ÔÚ¾ø´ó´ó¶¼Linux¿¯ÐаæÖУ¬¿ÉÒÔʹÓðü¹ÜÀí¹¤¾ßÀ´×°ÖÃÕâЩÈí¼þ°ü¡£ÒÔÏÂÊdz£¼ûµÄÈí¼þ°ü£º

Pacemaker£º¼¯ÈºÖÎÀí¹¤¾ß£¬ÓÃÓÚÖÎÀíÎļþϵͳµÄ״̬ºÍ×ÊÔ´¡£

Corosync£ºÓÃÓÚ¹¹½¨ºÍά»¤¼¯ÈºÇéÐεÄͨѶ¹¤¾ß¡£

DRBD£ºÂþÑÜʽ¸´ÖÆ¿é×°±¸£¬ÓÃÓÚʵÏÖ´ÅÅ̾µÏñ¡£

GFS2»òOCFS2£ºÓÃÓÚÌṩ¸ß¿ÉÓõļ¯ÈºÎļþϵͳ¡£

ÔÚUbuntuÉÏ£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°ÖÃÈí¼þ°ü£º

sudo apt-get install pacemaker corosync drbd8-utils gfs2-utils

µÇ¼ºó¸´ÖÆ

ÉèÖü¯ÈºÇéÐÎ

Ê×ÏÈ£¬ÐèÒªÉèÖü¯ÈºÇéÐΣ¬°üÀ¨½ÚµãÖ®¼äµÄͨѶºÍ×ÊÔ´µÄÖÎÀí¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄÉèÖÃʾÀý£¬ÆäÖÐÓÐÁ½¸ö½Úµã£¨node1ºÍnode2£©£º

ÐÞ¸Ä/etc/hostsÎļþ£¬Ìí¼Ó½ÚµãµÄIPµØµãºÍÖ÷»úÃû£¬ÒÔ±ã½ÚµãÖ®¼ä¿ÉÒÔÏ໥»á¼û¡£

sudo nano /etc/hosts

µÇ¼ºó¸´ÖÆ

Ìí¼ÓÈçÏÂÄÚÈÝ£º

192.168.1.100    node1
192.168.1.101    node2

µÇ¼ºó¸´ÖÆ

ÉèÖÃCorosyncͨѶ¡£

½¨ÉèCorosyncÉèÖÃÎļþ¡£

sudo nano /etc/corosync/corosync.conf

µÇ¼ºó¸´ÖÆ

Ìí¼ÓÒÔÏÂÄÚÈÝ£º

totem {
    version: 2
    secauth: off
    cluster_name: mycluster
    transport: udpu
}

nodelist {
    node {
        ring0_addr: node1
        nodeid: 1
    }
    node {
        ring0_addr: node2
        nodeid: 2
    }
}

quorum {
    provider: corosync_votequorum
}

logging {
    to_syslog: yes
    to_logfile: yes
    logfile: /var/log/corosync.log
    debug: off
    timestamp: on
}

µÇ¼ºó¸´ÖÆ

ÆôÓÃCorosyncºÍPacemakerЧÀÍ¡£

sudo systemctl enable corosync
sudo systemctl enable pacemaker

µÇ¼ºó¸´ÖÆ

Æô¶¯Ð§ÀÍ¡£

sudo systemctl start corosync
sudo systemctl start pacemaker

µÇ¼ºó¸´ÖÆ

ÉèÖÃDRBD

DRBDÊÇÒ»¸öÂþÑÜʽ¸´ÖÆ¿é×°±¸£¬ËüÓÃÓÚÔÚ¶à¸ö½ÚµãÖ®¼äʵÏÖ´ÅÅ̾µÏñ¡£ÒÔÏÂÊÇDRBDµÄÉèÖÃʾÀý£¬ÆäÖÐÓÐÁ½¸ö½Úµã£¨node1ºÍnode2£©£¬²¢Ê¹ÓÃ/dev/sdb×÷Ϊ¹²Ïí¿é×°±¸£º

ÉèÖÃDRBD¡£

½¨ÉèDRBDÉèÖÃÎļþ¡£

sudo nano /etc/drbd.d/myresource.res

µÇ¼ºó¸´ÖÆ

Ìí¼ÓÒÔÏÂÄÚÈÝ£º

resource myresource {
    protocol C;

    on node1 {
        device /dev/drbd0;
        disk   /dev/sdb;
        address 192.168.1.100:7789;
        meta-disk internal;
    }

    on node2 {
        device /dev/drbd0;
        disk   /dev/sdb;
        address 192.168.1.101:7789;
        meta-disk internal;
    }

    net {
        allow-two-primaries;
    }

    startup {
        wfc-timeout     15;
        degr-wfc-timeout 60;
    }

    syncer {
        rate    100M;
        al-extents 257;
    }

    on-node-upgraded {
        # promote node1 to primary after a successful upgrade
        if [ "$(cat /proc/sys/kernel/osrelease)" != "$TW_AFTER_MAJOR.$TW_AFTER_MINOR.$TW_AFTER_UP" ] && 
           [ "$(cat /proc/mounts | grep $DRBD_DEVICE)" = "" ] ; then
            /usr/bin/logger "DRBD on-node-upgraded handler: Promoting to primary after upgrade.";
            /usr/sbin/drbdsetup $DRBD_DEVICE primary;
        fi;
    }
}

µÇ¼ºó¸´ÖÆ

³õʼ»¯DRBD¡£

sudo drbdadm create-md myresource

µÇ¼ºó¸´ÖÆ

Æô¶¯DRBD¡£

sudo systemctl start drbd

µÇ¼ºó¸´ÖÆ

ÉèÖü¯ÈºÎļþϵͳ

ÓжàÖÖ¼¯ÈºÎļþϵͳ¿É¹©Ñ¡Ôñ£¬ÈçGFS2ºÍOCFS2¡£ÒÔÏÂÊÇʹÓÃGFS2ΪÀýµÄÉèÖÃʾÀý¡£

½¨ÉèÎļþϵͳ¡£

sudo mkfs.gfs2 -p lock_gulmd -t mycluster:myresource /dev/drbd0

µÇ¼ºó¸´ÖÆ

¹ÒÔØÎļþϵͳ¡£

sudo mkdir /mnt/mycluster
sudo mount -t gfs2 /dev/drbd0 /mnt/mycluster

µÇ¼ºó¸´ÖÆ

Ìí¼ÓÎļþϵͳ×ÊÔ´¡£

sudo pcs resource create myresource Filesystem device="/dev/drbd0" directory="/mnt/mycluster" fstype="gfs2"  op start  timeout="60s"  op stop  timeout="60s"  op monitor interval="10s"  op monitor timeout="20s"  op monitor start-delay="5s"  op monitor stop-delay="0s"

µÇ¼ºó¸´ÖÆ

ÆôÓúÍÆô¶¯×ÊÔ´¡£

sudo pcs constraint order myresource-clone then start myresource
sudo pcs constraint colocation add myresource with myresource-clone

µÇ¼ºó¸´ÖÆ

²âÊԸ߿ÉÓÃÐÔ

Íê³ÉÒÔÉÏÉèÖú󣬿ÉÒÔ²âÊԸ߿ÉÓÃÐÔ¡£ÒÔÏÂÊDzâÊԵİ취£º

×èÖ¹Ö÷½Úµã¡£

sudo pcs cluster stop node1

µÇ¼ºó¸´ÖÆ

¼ì²éÎļþϵͳÊÇ·ñÔÚ±¸ÓýڵãÉÏÕý³£ÔËÐС£

sudo mount | grep "/mnt/mycluster"

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

Êä³öӦΪ±¸ÓýڵãµÄµØµãºÍ¹ÒÔصã¡£

»Ö¸´Ö÷½Úµã¡£

sudo pcs cluster start node1

µÇ¼ºó¸´ÖÆ

¼ì²éÎļþϵͳÊÇ·ñ»Ö¸´µ½Ö÷½ÚµãÉÏ¡£

sudo mount | grep "/mnt/mycluster"

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

Êä³öӦΪÖ÷½ÚµãµÄµØµãºÍ¹ÒÔصã¡£

½áÂÛ£º

ÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳ¿ÉÒÔÌá¸ßϵͳµÄ¿É¿¿ÐԺͿÉÓÃÐÔ¡£±¾ÎÄÏÈÈÝÁËÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳ£¬²¢ÌṩÁËÏìÓ¦µÄ´úÂëʾÀý¡£¶ÁÕß¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇó¾ÙÐÐÊʵ±µÄÉèÖú͵÷½â£¬ÒÔʵÏÖ¸ü¸ßµÄ¿ÉÓÃÐÔ¡£

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõļ¯ÈºÎļþϵͳµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ