技術備忘錄
RabbitMQ
安裝篇->RabbitMQ 快速安裝筆記
入門篇->RabbitMQ 筆記
ip hostname
好像需要把現有的 Nodes 全部新增上去,不然在join時會出錯。
rabbitmqctl stop
rabbitmq-server -detached
rabbitmqctl start_app
rabbitmqctl stop_app
rabbitmqctl reset
#disk模式
rabbitmqctl join_cluster rabbit@hostname
#RAM模式
#rabbitmqctl join_cluster --ram rabbit@hostname
rabbitmqctl start_app
A.K.A. HA Queues
官方文件
在cluster多節點(Nodes)的情形下才可以新增的Queue格式
新增時會需要先綁在其中一個Node上
如果原先綁定的Node離線,會自動將資料導到另一個Node上
旁邊的"+"代表這個Queue現在有對應到的Node數
Quorum Queues 對應的 Node 只會包含 Queue 建立的當下有的 Node
換言之 Queue 建好後,之後再加入的 Node 就無法對應到
如果啟動中的 Node 小於 3 台
Quorum Queues 會因為 Node 過少而出錯誤
所以說啟動中 Node 必須要大於 3 台
不過這個錯誤並不會導致Queue裡的資料消失
特殊情況:
如果 Node 為 "?",新的資料將無法寫進 Queue 中
因為叢集多主機的特性,連線建立的時候如果將 HostName 寫在一般的 ConnectionFactory 裡,連線主機離線時,將無法自動重連。
如下改成 HostName List 後,即使任意節點斷線也不會影響連線。( 會自動斷線重連 )
string[] hostList = { "HostName1","HostName2","HostName3","HostName4" };
var connection = factory.CreateConnection(hostList)
另外可以藉由這兩個 Event 監聽連線狀態
//斷線後重新連線成功
connection.RecoverySucceeded
//斷線
connection.ConnectionShutdown
channel.QueueDeclare(
queue: "QueueName",
durable: true,
exclusive: false,
autoDelete: false,
arguments: new Dictionary<string, object>() { { "x-queue-type", "quorum" } }
);
如上, durable、exclusive、autoDelete 的值不可改
BTW , QueueName 如果直接不帶( 給 "" ),系統會自動產生 QueueName
官方文件
帶有CONSUL和VAULT的RABBITMQ集群
rabbitmq-plugins --offline enable rabbitmq_peer_discovery_consul
我的 /etc/rabbitmq/rabbitmq.conf
loopback_users.guest = false
listeners.tcp.default = 5672
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_consul
cluster_formation.consul.host = 192.168.11.191
cluster_formation.consul.svc_addr_auto = true
cluster_formation.consul.svc_addr_use_nodename = false
cluster_formation.consul.port = 8500
cluster_formation.consul.scheme = http
cluster_formation.consul.svc = rabbitmq
如果 /etc/rabbitmq 沒有 rabbitmq.conf,直接建一個就可以了
根據Rabbitmq叢集搭建-程式前沿步驟,在設定 /etc/hosts 參數時,參考內容:
192.168.127.139 basic-server
192.168.127.140 rabbitmq-m1
192.168.127.132 rabbitmq-m2
其中basic-server,rabbitmq-m1,rabbitmq-m2,為主機名稱
不是連線叢集時的rabbit@basic-server
如果上方/etc/hosts設定沒問題但出EPMD錯誤,執行
export ERL_EPMD_PORT="4369"
epmd -kill
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing