尊龙凯时人生就是搏

ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁÐ

ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁÐ

СÐò£º

ÐÂÎÅÐÐÁÐÊÇÏÖ´úÂþÑÜʽϵͳÖг£ÓõÄÒ»ÖÖͨѶ·½·¨£¬Ëü¿ÉÒÔÔÚ¶à¸öÀú³Ì»òÕ߶ą̀ЧÀÍÆ÷Ö®¼äת´ïÊý¾Ý£¬ÊµÏÖ½âñîºÍÒ첽ͨѶµÄÄ¿µÄ¡£ÔÚLinuxϵͳÉÏ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýһЩ¿ªÔ´µÄÐÂÎÅÐÐÁÐÈí¼þÀ´´î½¨¸ß¿ÉÓõÄÐÂÎÅÐÐÁÐϵͳ¡£±¾ÎĽ«ÒÔRabbitMQΪÀý£¬ÏÈÈÝÔõÑùÔÚLinuxÉϴºÍÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁС£

°ì·¨Ò»£º×°ÖÃRabbitMQ

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚLinuxϵͳÉÏ×°ÖÃRabbitMQ¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃRabbitMQ£º

sudo apt-get install rabbitmq-server

µÇ¼ºó¸´ÖÆ

°ì·¨¶þ£ºÉèÖÃRabbitMQ¼¯Èº

ΪÁËʵÏָ߿ÉÓÃÐÔ£¬ÎÒÃÇÐèÒª½«¶à¸öRabbitMQ½ÚµãÉèÖÃΪ¼¯Èº¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄÀý×Ó£¬¼ÙÉèÎÒÃÇÓÐÁ½Ì¨Ð§ÀÍÆ÷£¬»®·ÖΪNode1ºÍNode2¡£ÎÒÃÇÐèÒªÔÚÁ½Ì¨Ð§ÀÍÆ÷ÉÏ»®·Ö±à¼­RabbitMQµÄÉèÖÃÎļþ¡£

ÔÚNode1ÉÏ£¬·­¿ª/etc/rabbitmq/rabbitmq.configÎļþ£¬²¢Ìí¼ÓÒÔÏÂÄÚÈÝ£º

[{rabbit, [{cluster_nodes, {['rabbit@Node1', 'rabbit@Node2'], disc}}]}].

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

ÔÚNode2ÉÏ£¬·­¿ª/etc/rabbitmq/rabbitmq.configÎļþ£¬²¢Ìí¼ÓÒÔÏÂÄÚÈÝ£º

[{rabbit, [{cluster_nodes, {['rabbit@Node1', 'rabbit@Node2'], disc}}]}].

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

ÐèҪעÖصÄÊÇ£¬ÉÏÊöÉèÖÃÎļþÖеĽڵãÃû³ÆÐèҪƾ֤ÏÖÕæÏàÐξÙÐÐÐ޸ġ£ÉúÑÄÎļþºó£¬ÖØÆôRabbitMQЧÀÍ£º

sudo systemctl restart rabbitmq-server

µÇ¼ºó¸´ÖÆ

°ì·¨Èý£ºÉèÖÃRabbitMQ¾µÏñÐÐÁÐ

RabbitMQÌṩÁ˾µÏñÐÐÁеĹ¦Ð§£¬¿ÉÒÔ½«ÐÂÎÅÐÐÁÐÔÚ¶à¸ö½ÚµãÖ®¼ä¾ÙÐи´ÖÆ£¬ÊµÏÖÊý¾ÝµÄÈßÓà´æ´¢£¬Ìá¸ßϵͳµÄ¿É¿¿ÐÔ¡£ÎÒÃÇ¿ÉÒÔÔÚ½¨ÉèÐÐÁÐʱͨ¹ýÉèÖÃdurableºÍarguments²ÎÊýÀ´ÊµÏÖ¾µÏñÐÐÁеĹ¦Ð§¡£

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

# ÔÚÉùÃ÷ÐÐÁÐʱ£¬Í¨¹ýÉèÖÃdurable²ÎÊýΪTrueÀ´³¤ÆÚ»¯ÐÐÁÐ
channel.queue_declare(queue='my_queue', durable=True)

# ÔÚÉùÃ÷ÐÐÁÐʱ£¬Í¨¹ýÉèÖÃarguments²ÎÊýÀ´ÉèÖþµÏñÐÐÁеÄÕ½ÂÔ
channel.queue_declare(queue='my_queue', durable=True,
                     arguments={"x-ha-policy": 'all'})

connection.close()

µÇ¼ºó¸´ÖÆ

ÐèҪעÖصÄÊÇ£¬ÔÚÉèÖþµÏñÐÐÁÐʱÐèÒª°ü¹Ü¼¯ÈºÖеÄËùÓнڵ㶼ÒѾ­ÉèÖóɼ¯Èº¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´Éó²é¼¯ÈºÖеĽڵãÐÅÏ¢£º

sudo rabbitmqctl cluster_status

µÇ¼ºó¸´ÖÆ

°ì·¨ËÄ£ºÉèÖøºÔØƽºâ

ΪÁËʵÏÖ¸ºÔØƽºâ£¬ÎÒÃÇ¿ÉÒÔʹÓÃNginx×÷ΪÐÂÎÅÐÐÁеÄÊðÀíЧÀÍÆ÷¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄNginxÉèÖÃÎļþʾÀý¡£

http {
   upstream rabbitmq_servers {
        server 192.168.1.100:5672 fail_timeout=60s max_fails=3;
        server 192.168.1.101:5672 fail_timeout=60s max_fails=3;
    }
    
    server {
        listen          5672;
        
        location / {
            proxy_pass  http://rabbitmq_servers;
            proxy_redirect off;
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöÉèÖÃÎļþÖУ¬ÎÒÃǽç˵ÁËÁ½¸öRabbitMQЧÀÍÆ÷µÄµØµãºÍ¶Ë¿Ú£¬Í¨¹ýproxy_passÖ¸ÁÇëÇóת·¢µ½ÕâЩЧÀÍÆ÷ÉÏ¡£Nginx»áƾ֤¸ºÔØƽºâËã·¨£¬½«ÐÂÎÅÇëÇóÔȳƵطַ¢µ½²î±ðµÄRabbitMQ½ÚµãÉÏ£¬´Ó¶øʵÏÖ¸ºÔØƽºâµÄЧ¹û¡£

½áÂÛ£º

ͨ¹ýÉÏÊö°ì·¨£¬ÎÒÃÇ¿ÉÒÔÔÚLinuxϵͳÉϴºÍÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁÐϵͳ¡£Ê¹ÓÃRabbitMQÌṩµÄ¼¯Èº¹¦Ð§£¬¿ÉÒÔʵÏÖ½ÚµãÖ®¼äµÄÊý¾Ý¸´Öƺ͹ÊÕÏתÒÆ£¬°ü¹ÜϵͳµÄ¿É¿¿ÐԺ͸߿ÉÓÃÐÔ¡£¶øͨ¹ýÉèÖøºÔØƽºâ£¬¿ÉÒÔʵÏÖÐÂÎÅÐÐÁеĸºÔØƽºâºÍÐÔÄÜÓÅ»¯¡£Ï£Íû±¾ÎÄÄܶԶÁÕßÔÚLinuxϵͳÉÏÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁÐÓÐËù×ÊÖú¡£

²Î¿¼Á´½Ó£º

[RabbitMQ](https://www.rabbitmq.com/)

[Nginx](https://nginx.org/)

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÐÂÎÅÐÐÁеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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