尊龙凯时人生就是博

ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ý¿â¼¯Èº

ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ý¿â¼¯Èº

ÔÚÏÖ´úµÄ»¥ÁªÍøÓ¦ÓÃÖУ¬Êý¾Ý¿âÊÎÑÝןÜÊÇÖ÷ÒªµÄ½ÇÉ«¡£ÎªÁËÈ·±£Êý¾ÝµÄ¿É¿¿ÐԺ͸߿ÉÓÃÐÔ£¬Ðí¶à¹«Ë¾¶¼»áÉèÖø߿ÉÓõÄÊý¾Ý¿â¼¯Èº¡£±¾ÎĽ«ÏÈÈÝÔÚLinuxÉÏÔõÑùÉèÖø߿ÉÓõÄÊý¾Ý¿â¼¯Èº£¬ÒÔÈ·±£ÔÚÊý¾Ý¿â·ºÆð¹ÊÕÏʱ£¬¿ÉÒÔ¿ìËÙÇл»µ½±¸ÓÃÊý¾Ý¿â£¬´Ó¶ø°ü¹ÜÓ¦ÓõÄÒ»Á¬ÔËÐС£

ÎÒÃǽ«Ê¹ÓÃMySQL×÷ΪʾÀýÊý¾Ý¿â£¬ÒÔÑÝʾÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄMySQLÊý¾Ý¿â¼¯Èº¡£

×°ÖÃMySQL

Ê×ÏÈ£¬ÐèÒªÔÚLinuxÉÏ×°ÖÃMySQL¡ £¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

sudo apt-get install mysql-server

µÇ¼ºó¸´ÖÆ

ÉèÖÃÖ÷´Ó¸´ÖÆ

Ôڸ߿ÉÓõÄÊý¾Ý¿â¼¯ÈºÖУ¬Í¨³£»áʹÓÃÖ÷´Ó¸´ÖƵķ½·¨À´ÊµÏÖÊý¾ÝµÄͬ²½¡£ÔÚÕâÖÖģʽÏ£¬Ò»¸öÊý¾Ý¿âЧÀÍÆ÷×÷ΪÖ÷ЧÀÍÆ÷£¬ÈÏÕæдÈëºÍ¸üÐÂÊý¾Ý£¬ÆäËûÊý¾Ý¿âЧÀÍÆ÷×÷Ϊ´ÓЧÀÍÆ÷£¬ÈÏÕæ¶ÁÈ¡Êý¾Ý£¬²¢ÊµÊ±Í¬²½Ö÷ЧÀÍÆ÷µÄÊý¾Ý¡£

Ê×ÏÈ£¬ÐèÒªÔÚÖ÷ЧÀÍÆ÷ÉϾÙÐÐÉèÖᣱ༭MySQLµÄÉèÖÃÎļþmy.cnf£¬ÕÒµ½²¢ÐÞ¸ÄÒÔÏÂÉèÖãº

server-id=1
log_bin=mysql-bin
binlog_format=row

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÖØÆôMySQLЧÀÍ¡£

½ÓÏÂÀ´£¬ÔÚ´ÓЧÀÍÆ÷ÉϾÙÐÐÉèÖá£Í¬Ñù£¬ÐèÒª±à¼­MySQLµÄÉèÖÃÎļþmy.cnf£¬ÕÒµ½²¢ÐÞ¸ÄÒÔÏÂÉèÖãº

server-id=2
relay-log=mysql-relay-bin
log_slave_updates=1
read_only=1

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÖØÆôMySQLЧÀÍ¡£

ÉèÖÃÖ÷´Óͬ²½

ÏÖÔÚ£¬Ö÷´ÓЧÀÍÆ÷ÒѾ­ÀÖ³ÉÉèÖúÃÁË£¬½ÓÏÂÀ´ÐèÒªÉèÖÃÖ÷´Óͬ²½¡£ÔÚÖ÷ЧÀÍÆ÷ÉÏ£¬Ê¹ÓÃÒÔÏÂÏÂÁÉèÒ»¸öÓÃÓÚͬ²½µÄÓû§£º

CREATE USER 'replication'@'%' IDENTIFIED BY 'your_password';
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%';
FLUSH PRIVILEGES;

µÇ¼ºó¸´ÖÆ

È»ºó£¬Ö´ÐÐÒÔÏÂÏÂÁî»ñÈ¡Ö÷ЧÀÍÆ÷µÄ¶þ½øÖÆÈÕÖ¾ÎļþºÍλÖãº

SHOW MASTER STATUS;

µÇ¼ºó¸´ÖÆ

»ñµÃµÄЧ¹ûÀàËÆÓÚ£º

+---------------+----------+--------------+------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| mysql-bin.0001| 107       | test         |                  |
+---------------+----------+--------------+------------------+

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´£¬ÔÚ´ÓЧÀÍÆ÷ÉÏÖ´ÐÐÒÔÏÂÏÂÁî×îÏȾÙÐÐÖ÷´Óͬ²½£º

CHANGE MASTER TO MASTER_HOST='master_server_ip', MASTER_USER='replication', MASTER_PASSWORD='your_password', MASTER_LOG_FILE='mysql-bin.0001', MASTER_LOG_POS=107;
START SLAVE;

µÇ¼ºó¸´ÖÆ

ÔÚ´ÓЧÀÍÆ÷ÉÏÖ´ÐÐÒÔÏÂÏÂÁîÉó²éÖ÷´Óͬ²½×´Ì¬£º

SHOW SLAVE STATUSG

µÇ¼ºó¸´ÖÆ

ÈôÊÇÏÔʾSlave_IO_RunningºÍSlave_SQL_Running¶¼ÎªYes£¬ÌåÏÖÖ÷´Óͬ²½ÒÑÀÖ³ÉÉèÖá£

ÉèÖÃÖ÷´ÓÇл»

µ±Ö÷ЧÀÍÆ÷·ºÆð¹ÊÕÏʱ£¬ÐèÒªÊÖ¶¯Çл»µ½±¸ÓÃÊý¾Ý¿â¡£ÎªÁËÀû±ãÇл»£¬¿ÉÒÔʹÓÃKeepalivedºÍHAProxyÀ´ÊµÏÖ×Ô¶¯Çл»¡£

Ê×ÏÈ£¬ÐèҪװÖÃKeepalivedºÍHAProxy¡ £¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

sudo apt-get install keepalived haproxy

µÇ¼ºó¸´ÖÆ

È»ºó£¬±à¼­KeepalivedµÄÉèÖÃÎļþ/etc/keepalived/keepalived.conf£¬ÐÞ¸ÄÒÔÏÂÉèÖãº

vrrp_script chk_mysql {
    script "killall -0 mysqld"
    interval 2
    weight -2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass your_password
    }
    track_script {
        chk_mysql
    }
    virtual_ipaddress {
        192.168.1.100/24
    }
}

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

½ÓÏÂÀ´£¬±à¼­HAProxyµÄÉèÖÃÎļþ/etc/haproxy/haproxy.cfg£¬Ìí¼ÓÒÔÏÂÉèÖãº

listen mysql-cluster
    bind 192.168.1.100:3306
    mode tcp
    option mysql-check user haproxy_check
    balance roundrobin
    server mysql1 192.168.1.101:3306 check
    server mysql2 192.168.1.102:3306 check backup

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÎļþ¡£

×îºó£¬ÖØÆôKeepalivedºÍHAProxyЧÀÍ£º

sudo service keepalived restart
sudo service haproxy restart

µÇ¼ºó¸´ÖÆ

ÏÖÔÚ£¬µ±Ö÷ЧÀÍÆ÷·ºÆð¹ÊÕÏʱ£¬Keepalived»á½«ÐéÄâIPµØµãÇл»µ½±¸ÓÃÊý¾Ý¿â£¬²¢½«Á÷Á¿×ª·¢µ½HAProxyÉÏ¡£

ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇÀÖ³ÉÔÚLinuxÉÏÉèÖÃÁËÒ»¸ö¸ß¿ÉÓõÄÊý¾Ý¿â¼¯Èº¡£ÔÚÊý¾Ý¿â·ºÆð¹ÊÕÏʱ£¬ÏµÍ³»á×Ô¶¯Çл»µ½±¸ÓÃÊý¾Ý¿â£¬´Ó¶ø°ü¹ÜÁËÊý¾ÝµÄ¿É¿¿ÐԺ͸߿ÉÓÃÐÔ¡£Ï£Íû±¾ÎÄÄܶÔÄãÔÚÉèÖø߿ÉÓõÄÊý¾Ý¿â¼¯ÈºÉÏÓÐËù×ÊÖú¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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