nsq.reader错误connection closed
gorm模型定义原理借鉴分析

nsq双机集群部署

妙音 posted @ 2021年4月02日 13:27 in golang with tags nsq , 658 阅读

问题

 
双机nsq如果部署集群,如何保证高可用性
 
1. 单节点nsqlookup故障?
 
2. 单节点nsq故障?
 
3. 消息丢失?
 

环境说明

 
两台机器
 
机器A 192.168.120.1
 
机器B 192.168.120.101
 

部署过程

 
部署方法
 
1. 机器A部署一套nsqlookup+nsqd
 
2. 机器B部署一套nsqlookup+nsqd
 
3. 生产者将消息同时写入两个nsqd
 
3. 消费者监听两个nsqlookup
 
结构图
 
 
机器A
 
nsqlookupd -broadcast-address 192.168.120.1
nsqd -lookupd-tcp-address=192.168.120.1:4160 -lookupd-tcp-address=192.168.120.101:4160 -broadcast-address 192.168.120.1
 
机器B
 
nsqlookupd -broadcast-address 192.168.120.101
nsqd -lookupd-tcp-address=192.168.120.1:4160 -lookupd-tcp-address=192.168.120.101:4160 -broadcast-address 192.168.120.101
 

pynsq测试脚本

 
生产者
 
import nsq
import tornado.ioloop
import time

def pub_message():
    writer.pub('test', str(time.strftime('%H:%M:%S')).encode("utf-8"), finish_pub)

def finish_pub(conn, data):
    print(data)

# 写入两个nsq好处: 1.防止nsqd单点故障  2.防止消息丢失
writer = nsq.Writer(['192.168.120.101:4150', '192.168.120.1:4150'])

tornado.ioloop.PeriodicCallback(pub_message, 1000).start()
nsq.run()
 
消费者
 
import nsq


def handler(message):
    print(message, message.id, message.timestamp, message.attempts, message.body)
    return True

# 防止nsqlookup故障
r = nsq.Reader(message_handler=handler,
               lookupd_http_addresses=['http://192.168.120.1:4161', 'http://192.168.120.101:4161'],
               topic='test', channel='abc', lookupd_poll_interval=15)

nsq.run()
 

总结

 
只要有一个nsqlookup和一个nsqd存活,系统就不会挂
 
 
 
Avatar_small
Semify LLC SEO info 说:
2021年4月09日 21:35

International Market place for Smar*****ches, GPS, Fitness, Waterproof, Fitness Smart wach,

Avatar_small
click here 说:
2021年6月29日 02:59

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. click here

Avatar_small
dfg` 说:
2021年9月11日 21:21

I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. lepto sports

Avatar_small
dfg` 说:
2021年9月13日 14:09

Hi there! Nice post! Please tell us when I will see a follow up! 먹튀검증사이트

Avatar_small
dfg` 说:
2021年9月17日 18:43

There are lots of dissertation websites from the net dwell acquire unsurprisingly regarded from the internet websites. buy cigarettes online

Avatar_small
Hardik 说:
2021年9月19日 17:16

I’m impressed, I must say. Truly rarely must i encounter a weblog that’s both educative and entertaining, and without a doubt, you have hit the nail about the head. Your concept is outstanding; the thing is something too few people are speaking intelligently about. My business is happy that we stumbled across this within my search for some thing relating to this.
<a href="http://shoppingpossible.com"title="10 Smart Home Furniture Ideas Hacks">10 Smart Home Furniture Ideas Hacks
</a>

[url=https://shoppingpossible.com/]10 Smart Home Furniture Ideas Hacks[/url]

Avatar_small
dfg` 说:
2021年9月19日 22:16

I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! Instagram++

Avatar_small
dfg` 说:
2021年9月25日 01:17

Pubg Mobile Lite Official Redeem Code: If you are looking for the active PUBG Mobile Redeem Code 2021, then you have come to visit NewsGater. Here, we publish PUBG Lite Redeem Code Today and regularly. All working PUBG mobile lite redeem code listed on this website.

Avatar_small
dfg` 说:
2021年9月25日 23:43

We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. blackpods pro

Avatar_small
dfg` 说:
2021年9月27日 20:36

Only strive to mention one's content can be as incredible. This clarity with your post is superb! Thanks a lot, hundreds of along with you should go on the pleasurable get the job done. https://blackpods.org/product/blackpods-2/

Avatar_small
Dr.Billa 说:
2021年12月11日 06:14

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing 온라인바카라

Avatar_small
Dr.Billa 说:
2022年1月12日 06:16

Good day! I could have sworn I’ve been to this site before but after going through some of the articles I realized it’s new to me. Anyhow, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back frequently nclex practice test

Avatar_small
Dr.Billa 说:
2022年2月18日 05:19

Online Hold'em Community in Korea 텍사스홀덤 

Avatar_small
Dr.Billa 说:
2022年2月23日 12:40

Bolaku Situs Bandar Bola Agen Judi Online Terpercaya , Bolaku merupakan situs bandar bola resmi yang telah diakui berbagai agen dunia asia tepatnya di Indonesia dengan menyediakan pasaran taruhan judi online hingga puluhan tipe game terlengkap. bolaku

Avatar_small
Dr.Billa 说:
2022年3月01日 23:39

The Netgear extenders can be used to increase the coverage area. Network. The Netgear extender setup is highly effective. Double their wireless network range. If you have any problems, however, problem with how to setup a netgear wifi extender, you can call on toll free and take technical assistance from experts. 192.168.1.250

Avatar_small
Dr.Billa 说:
2022年3月18日 07:58

Great post, I want to thank you for this informative read; I really appreciate sharing this great post. Keep up the good work! joker สล็อต

Avatar_small
Dr.Billa 说:
2022年3月22日 02:15

You make so many great points here that I read your article a couple of times. This is great content for your readers. ufabet เข้าสู่ระบบ

Avatar_small
cyber 说:
2022年4月14日 06:49

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing 작업대출사이트

Avatar_small
Digital_Zone 说:
2022年4月19日 06:31

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. Vloer isoleren

Avatar_small
Digital_Zone 说:
2022年4月19日 06:38

I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers Zwembad aanleggen tuin

Avatar_small
Digital_Zone 说:
2022年4月19日 06:42

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... Polyester zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 06:46

Great job here on _______ I read a lot of blog posts, but I never heard a topic like this. I Love this topic you made about the blogger's bucket list. Very resourceful. Zwembad plaatsen tuin

Avatar_small
Digital_Zone 说:
2022年4月19日 06:50

Yes, I am entirely agreed with this article, and I just want say that this article is very helpful and enlightening. I also have some precious piece of concerned info !!!!!!Thanks. Inox zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 08:35

Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! Zwembad bouwen tuin

Avatar_small
Digital_Zone 说:
2022年4月19日 08:41

Excellent post. I was always checking this blog, and I’m impressed! Extremely useful info specially the last part, I care for such information a lot. I was exploring this particular info for a long time. Thanks to this blog my exploration has ended. Sunpower Maxeon zonnepanelen

Avatar_small
Digital_Zone 说:
2022年4月19日 08:47

I visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! Vloerisolatie

Avatar_small
Digital_Zone 说:
2022年4月19日 08:51

Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! Monoblok zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 08:55

Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! Zwembad aanleggen

Avatar_small
Digital_Zone 说:
2022年4月19日 08:59

Hey, this day is too much good for me, since this time I am reading this enormous informative article here at my home. Thanks a lot for massive hard work. Keramische zwembaden

Avatar_small
Digital_Zone 说:
2022年4月19日 09:03

i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future.. Zwembad plaatsen

Avatar_small
Digital_Zone 说:
2022年4月19日 09:08

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. Chapewerken

Avatar_small
Digital_Zone 说:
2022年4月19日 09:19

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing. Vinylester zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 09:23

I am continually amazed by the amount of information available on this subject. What you presented was well researched and well worded in order to get your stand on this across to all your readers. Tuinaanleg

Avatar_small
Digital_Zone 说:
2022年4月19日 09:27

You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. Zwembad bouwen

Avatar_small
Digital_Zone 说:
2022年4月19日 09:30

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. Aanleg zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 09:34

Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. Tuinontwerp

Avatar_small
Digital_Zone 说:
2022年4月19日 09:38

The article looks magnificent, but it would be beneficial if you can share more about the suchlike subjects in the future. Keep posting. Zonnepanelen plaatsen

Avatar_small
Digital_Zone 说:
2022年4月19日 09:43

I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing. Belinus zonnepanelen

Avatar_small
Digital_Zone 说:
2022年4月19日 09:47

I am jovial you take pride in what you write. It makes you stand way out from many other writers that can not push high-quality content like you. Chape

Avatar_small
Digital_Zone 说:
2022年4月19日 09:51

This article is an appealing wealth of informative data that is interesting and well-written. I commend your hard work on this and thank you for this information. You’ve got what it takes to get attention. LPW zwembad

Avatar_small
Digital_Zone 说:
2022年4月19日 09:55

I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content. Zwembad aanleggen

Avatar_small
Digital_Zone 说:
2022年4月19日 09:59

I am continually amazed by the amount of information available on this subject. What you presented was well researched and well worded in order to get your stand on this across to all your readers. Monoblock zwembaden

Avatar_small
Digital_Zone 说:
2022年4月19日 10:04

I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. Zwembad plaatsen

Avatar_small
Digital_Zone 说:
2022年4月19日 10:08

Wow, this is fascinating reading. I am glad I found this and got to read it. Great job on this content. I liked it a lot. Thanks for the great and unique info. Zonnepanelen installateur gezocht

Avatar_small
cyber 说:
2022年5月04日 06:28

สล็อต สล็อตออนไลน์ เกมสล็อต เว็บสล็อต สล็อต เล่น ฟรี สล็อต 888 สล็อตออนไลน์ มือ ถือ เกมสล็อต ทดลองเล่นสล็อต สล็อต

Avatar_small
Dr.Billa 说:
2022年5月26日 10:33

I was seeking this particular information for a very long time. ✅ I also have some information related to this Topic on my website strap-on

Avatar_small
Dr.Billa 说:
2022年6月04日 05:29

Nice post ✅. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part 다음드최신주소

Avatar_small
Dr.Billa 说:
2022年6月05日 11:43

Play Slope Unblocked game at your school. Control the ball in pixel world and collect a lot of points. slope game unblocked

Avatar_small
Dr.Billa 说:
2022年6月10日 04:30

mtpolice.kr provides sports betting information, sports analysis, and sports tips as a sports community.먹튀

Avatar_small
Dr.Billa 说:
2022年6月13日 10:13

Buy fresh Garlic online on lowest prices this link

Avatar_small
cyber 说:
2022年6月15日 22:18

This article was written by a real thinking writer✅. I agree many of the with the solid points made by the writer of เน็ตทรู

 

 

 

 

Great post, I want to thank you for this informative read; I really appreciate sharing this great post. Keep up the good work! เน็ตทรูรายเดือน

 

 

 

 

 

Superior post keeps up with this exceptional work✅. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! สมัครเน็ตทรูรายเดือน

 

 

 

 

Thanks for this great post, I find it very interesting and very well thought out and put together. I look forward to reading your work in the future. เน็ตทรูรายสัปดาห์

 

 

 

 

 

Thanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. I will certainly bookmark your blog and definitely will come back sometime soon. I want to encourage you to continue your great writing เน็ตทรูรายวัน

 

 

 

 

 

Everything is very open with a very clear description of the challenges. It was definitely informative. Your website is very helpful. Thanks for sharing On that website page, you'll see your description, why not read through this เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

 

 

Great work✅ This is the type of information that should be shared around the web. I also have some information related to on my website สมัครเน็ตทรู

 

 

 

 

 

 

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! เน็ตทรูรายเดือน

 

 

 

 

 

 

Fabulous post✅ you have denoted out some fantastic points regarding ไม่ลดสปีด สมัครเน็ตทรูรายเดือน

 

 

 

 

 

 

 

​What a fantabulous post ✅. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much เน็ตทรูรายสัปดาห์

Avatar_small
cyber 说:
2022年6月16日 11:40

The polar fleece used has been hand picked for its luxurious comfort but also for its printing qualities and most people are astonished when they see how realistic photos look when they are printed on the front of the blanket fleece. this link

 

 

 

 

 

 

 

 

 

 

​We publish daily results of the biggest lottery in India called the Lottery Sambad. It is also called Dear Lottery. Dear Lottery

Avatar_small
Dr.Billa 说:
2022年6月18日 04:39

These very small facts are produced using wide range of qualifications✅ I favor the idea such a good deal. This specific seems to be definitely excellent เน็ตทรูรายวัน

 

 

 

 

 

This was really very informative site for me I really liked it I felt very happy while reading this site เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

 

 

 

I prefer merely excellent resources and you can see these in เน็ตทรูรายวัน ไม่ลดสปีด

 

 

 

 

 

 

 

You amazingly have terrific article content. Cheers for sharing your blog site. Thank you for sharing this เน็ตทรูรายเดือน

 

 

 

 

 

 

 

Wow, What an Outstanding post✅. I found this too much informatics. It is what I was seeking for เน็ตทรูรายสัปดาห์

 

 

 

 

 

 

 

Excellent article. I want to thank you for this informative read; I really appreciate sharing this great post. Keep up your work! เน็ตทรูรายอาทิตย์ ไม่ลดสปีด

 

 

 

 

 

 

 

 

It’s really a fantastic website ✅ thanks for sharing. There's no doubt I would fully rate it after i read what the idea about this article is โปรเน็ต AIS

 

 

 

 

 

 

 

 

 

Hi there! You make so many good points here that I read your article a couple of times. This is really nice content for your readers. เน็ต ais รายสัปดาห์

 

 

 

 

 

 

 

 

 

 

I found useful information on this topic✅. Thank you posting relative information and its currently becoming easier to complete this project เน็ต ais รายเดือน

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Good day! I could have sworn I’ve been to this site before but after going through some of the articles I realized it’s new to me. Anyhow, I’m certainly delighted I came across it and I’ll be bookmarking it and checking back frequently aw8

Avatar_small
cyber 说:
2022年6月18日 20:46

This is a great article and great read for me✅. It's my first visit to your blog aw8

 

 

 

 

I am hoping that you will continue writing this kind of blog. Thanks for sharing this information. aw8

 

 

 

 

 

This Post is providing valuable and unique information✅ I know that you take a time and effort to make a awesome article ut9winth

 

 

 

 

 

I enjoyed reading this post such an interesting info post. Thanks for providing good info on the topic of ut9winth

 

 

 

 

 

Everything has its own value, but this is really precious information✅ shared by Author of ut9winth

 

 

 

 

I appreciate your efforts in preparing this post. I really like your blog articles on happyluke

 

 

 

 

 

What a fantabulous post ✅. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much happyluke

 

 

 

 

Fabulous post✅ you have denoted out some fantastic points regarding happyluke

 

 

 

 

 

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! jbo

 

 

 

 

 

​Great work✅ This is the type of information that should be shared around the web. I also have some information related to on my website jbo

Avatar_small
cyber 说:
2022年6月26日 22:48

Online poker information community in Korea 텍사스홀덤

Avatar_small
cyber 说:
2022年6月30日 22:15

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! Teesside University

Avatar_small
cyber 说:
2022年7月08日 00:08

Wow, What an Outstanding post✅. I found this too much informatics. It is what I was seeking for 온라인바둑이

Avatar_small
바카라사이트 说:
2022年7月30日 14:39

very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. 바카라사이트 카지노사이트

Avatar_small
aqsa 说:
2022年8月03日 05:30

Superb blog post, I have book marked this internet site so ideally I’ll see much more on this subject in the foreseeable future https://totoworld24.com

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:03

There are ways to tell whether or not a site is on the Dark Web though. For example, if you go to any major search engine, you will definitely come across a lot of webpages that are linking to them.  dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:38

This is an industry on which there is no real regulation, so you have to be especially careful. As a result, before you start linking, make sure you find out if the person you are linking with is allowed to do so. deep web

Avatar_small
dark web/deep web/d 说:
2022年8月06日 23:55

The Dark Web is filled with dangerous predators and hackers who prey on unsuspecting individuals who trust that the Web sites they visit are safe.  dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:15

Hackers use these links to send you phishing scams and offer false links to make you think that you are downloading a valuable application.  dark web sites

Avatar_small
dark web/deep web/d 说:
2022年8月07日 00:33

These phrases are more likely to produce genuine searches that will result in results which are legitimate. dark web

Avatar_small
dark web/deep web/d 说:
2022年8月07日 01:02

ClickBank markets thousands of products, and they display the highest quality of each product on their marketplace page.  work from home jobs

Avatar_small
dark web/deep web/d 说:
2022年8月07日 01:24

Now that you have products to promote, it's time to create a sales page. A sales page is just a short text or a short blog post about the product or service that you are promoting. affiliate marketing success

Avatar_small
aqsa 说:
2022年8月09日 08:10

Royalgreen by Allgreen Properties Limited. Hotline 61004343. Get Discounts, Direct Developer Price, Floor Plan, Price List, Brochure & More. royalgreen condo

Avatar_small
cyber 说:
2022年8月14日 05:21

This article was written by a real thinking writer✅. I agree many of the with the solid points made by the writer of 파라오카지노

Avatar_small
aqsa 说:
2022年8月19日 01:54

I found useful information on this topic✅. Thank you posting relative information and its currently becoming easier to complete this project How to Sell Credit Card Processing

Avatar_small
cyber 说:
2022年8月22日 21:19

Startupo.fr est un site web qui propose des formations en ligne pour les entrepreneurs. Les cours sont divisés en trois niveaux : débutant, intermédiaire et expert. Chaque niveau contient plusieurs modules, et chaque module contient plusieurs leçons. Le niveau débutant est destiné aux personnes qui découvrent le monde de l'entrepreneuriat et aborde des sujets tels que le business plan et le marketing. Le niveau intermédiaire s'adresse à ceux qui ont une certaine expérience dans ce domaine et couvre des sujets tels que la planification financière et la gestion d'équipe. Le niveau expert est conçu pour ceux qui sont déjà des entrepreneurs expérimentés, et il couvre des sujets tels que le pitching aux investisseurs et la mise à l'échelle d'une entreprise. Startupo.fr propose également un cours sur Enlign, qui est un outil utilisé par les entrepreneurs pour gérer leur entreprise. Enlign est un logiciel qui aide les utilisateurs à suivre leurs progrès, à fixer des objectifs et à gérer leur temps. Il est disponible en version française et anglaise. Startupo.fr propose un essai gratuit d'Enlign afin que les utilisateurs puissent l'essayer avant de décider de l'acheter. Startupo.fr

Avatar_small
Dr.Billa 说:
2022年9月23日 10:05

This is a great article and great read for me✅. It's my first visit to your blog ALLIANT PRO REACH

Avatar_small
Dr.Billa 说:
2022年9月25日 08:25

Superior post keeps up with this exceptional work✅. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! 스웨디시

 

 

 

 

 

 

 

 

 

It’s really a fantastic website ✅ thanks for sharing. There's no doubt I would fully rate it after i read what the idea about this article is 마사지


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter