Pavel Cizinsky | ccaeb94 | 2018-12-12 12:03:06 +0100 | [diff] [blame] | 1 | ===== |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 2 | Usage |
Pavel Cizinsky | ccaeb94 | 2018-12-12 12:03:06 +0100 | [diff] [blame] | 3 | ===== |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 4 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 5 | RabbitMQ is a complete and highly reliable enterprise messaging |
| 6 | system based on the emerging AMQP standard. |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 7 | |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 8 | Sample pillars |
| 9 | ============== |
| 10 | |
| 11 | Standalone Broker |
| 12 | ----------------- |
| 13 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 14 | RabbitMQ as AMQP broker with admin user and vhosts: |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 15 | |
| 16 | .. code-block:: yaml |
| 17 | |
| 18 | rabbitmq: |
| 19 | server: |
| 20 | enabled: true |
Buddy Lindsey, Jr | f0d58ae | 2018-07-16 16:36:55 -0500 | [diff] [blame] | 21 | memory: |
| 22 | vm_high_watermark: 0.4 |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 23 | bind: |
| 24 | address: 0.0.0.0 |
| 25 | port: 5672 |
| 26 | secret_key: rabbit_master_cookie |
| 27 | admin: |
| 28 | name: adminuser |
| 29 | password: pwd |
| 30 | plugins: |
| 31 | - amqp_client |
| 32 | - rabbitmq_management |
Nick Metz | 208245c | 2017-12-03 16:18:33 +0100 | [diff] [blame] | 33 | host: |
| 34 | '/monitor': |
| 35 | enabled: true |
| 36 | user: 'monitor' |
| 37 | password: 'password' |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 38 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 39 | RabbitMQ as a Stomp broker: |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 40 | |
| 41 | .. code-block:: yaml |
| 42 | |
| 43 | rabbitmq: |
| 44 | server: |
| 45 | enabled: true |
| 46 | secret_key: rabbit_master_cookie |
| 47 | bind: |
| 48 | address: 0.0.0.0 |
| 49 | port: 5672 |
Nick Metz | 208245c | 2017-12-03 16:18:33 +0100 | [diff] [blame] | 50 | host: |
| 51 | '/monitor': |
| 52 | enabled: true |
| 53 | user: 'monitor' |
| 54 | password: 'password' |
Michael Polenchuk | 8115f0f | 2018-05-30 21:27:45 +0400 | [diff] [blame] | 55 | plugins_runas_user: rabbitmq |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 56 | plugins: |
| 57 | - rabbitmq_stomp |
| 58 | |
| 59 | RabbitMQ cluster |
| 60 | ---------------- |
| 61 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 62 | RabbitMQ as base cluster node: |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 63 | |
| 64 | .. code-block:: yaml |
| 65 | |
| 66 | rabbitmq: |
| 67 | server: |
| 68 | enabled: true |
| 69 | bind: |
| 70 | address: 0.0.0.0 |
| 71 | port: 5672 |
| 72 | secret_key: rabbit_master_cookie |
| 73 | admin: |
| 74 | name: adminuser |
| 75 | password: pwd |
| 76 | cluster: |
| 77 | enabled: true |
| 78 | role: master |
| 79 | mode: disc |
| 80 | members: |
| 81 | - name: openstack1 |
| 82 | host: 10.10.10.212 |
| 83 | - name: openstack2 |
| 84 | host: 10.10.10.213 |
| 85 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 86 | HA Queues definition: |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 87 | |
| 88 | .. code-block:: yaml |
| 89 | |
| 90 | rabbitmq: |
| 91 | server: |
| 92 | enabled: true |
| 93 | ... |
Nick Metz | 208245c | 2017-12-03 16:18:33 +0100 | [diff] [blame] | 94 | host: |
| 95 | '/monitor': |
| 96 | enabled: true |
| 97 | user: 'monitor' |
| 98 | password: 'password' |
| 99 | policies: |
| 100 | - name: HA |
| 101 | pattern: '^(?!amq\.).*' |
| 102 | definition: '{"ha-mode": "all"}' |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 103 | |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 104 | Enable TLS support |
| 105 | ------------------ |
| 106 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 107 | To enable support of TLS for rabbitmq-server you need to provide |
| 108 | a path to cacert, server cert and private key: |
Kirill Bespalov | b0cd0ae | 2017-05-30 17:45:13 +0300 | [diff] [blame] | 109 | |
| 110 | .. code-block:: yaml |
| 111 | |
| 112 | rabbitmq: |
| 113 | server: |
| 114 | enabled: true |
| 115 | ... |
| 116 | ssl: |
| 117 | enabled: True |
| 118 | key_file: /etc/rabbitmq/ssl/key.pem |
| 119 | cert_file: /etc/rabbitmq/ssl/cert.pem |
| 120 | ca_file: /etc/rabbitmq/ssl/ca.pem |
| 121 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 122 | To manage content of these files you can either use the following |
| 123 | options: |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 124 | |
| 125 | .. code-block:: yaml |
| 126 | |
| 127 | rabbitmq: |
| 128 | server: |
| 129 | enabled: true |
| 130 | ... |
| 131 | ssl: |
| 132 | enabled: True |
| 133 | |
Kirill Bespalov | b0cd0ae | 2017-05-30 17:45:13 +0300 | [diff] [blame] | 134 | key_file: /etc/rabbitmq/ssl/key.pem |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 135 | key: | |
| 136 | -----BEGIN RSA PRIVATE KEY----- |
| 137 | ... |
| 138 | -----END RSA PRIVATE KEY------- |
| 139 | |
Kirill Bespalov | b0cd0ae | 2017-05-30 17:45:13 +0300 | [diff] [blame] | 140 | ca_file: /etc/rabbitmq/ssl/ca.pem |
| 141 | cacert_chain: | |
| 142 | -----BEGIN CERTIFICATE----- |
| 143 | ... |
| 144 | -----END CERTIFICATE------- |
| 145 | |
| 146 | cert_file: /etc/rabbitmq/ssl/cert.pem |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 147 | cert: | |
| 148 | -----BEGIN CERTIFICATE----- |
| 149 | ... |
| 150 | -----END CERTIFICATE------- |
| 151 | |
| 152 | |
Kirill Bespalov | b0cd0ae | 2017-05-30 17:45:13 +0300 | [diff] [blame] | 153 | Or you can use the `salt.minion.cert` salt state which |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 154 | creates all required files according to defined reclass model. |
| 155 | See |
| 156 | https://github.com/Mirantis/reclass-system-salt-model/tree/master/salt/minion/cert/rabbitmq |
| 157 | for details. In this case you need just to enable ssl and nothing more: |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 158 | |
| 159 | .. code-block:: yaml |
| 160 | |
| 161 | rabbitmq: |
| 162 | server: |
| 163 | enabled: true |
| 164 | ... |
| 165 | ssl: |
| 166 | enabled: True |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 167 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 168 | Defaut port for TLS is ``5671``: |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 169 | |
| 170 | .. code-block:: yaml |
| 171 | |
| 172 | rabbitmq: |
| 173 | server: |
| 174 | bind: |
| 175 | ssl: |
| 176 | port: 5671 |
| 177 | |
Michael Polenchuk | 161ebd1 | 2018-12-24 17:00:30 +0400 | [diff] [blame^] | 178 | Manage environment variables |
| 179 | ---------------------------- |
| 180 | |
| 181 | Create a config file with variable settings that override the defaults |
| 182 | built in to the RabbitMQ startup scripts: |
| 183 | |
| 184 | .. code-block:: yaml |
| 185 | |
| 186 | rabbitmq: |
| 187 | server: |
| 188 | enabled: true |
| 189 | ... |
| 190 | env_variables: |
| 191 | hostname: localhost |
| 192 | node_port: 5671 |
| 193 | export: |
| 194 | home: /var/lib/rabbitmq |
| 195 | erl_inetrc: /etc/rabbitmq/inetrc |
| 196 | |
| 197 | |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 198 | Usage |
| 199 | ===== |
| 200 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 201 | Check cluster status, example shows running cluster with 3 nodes: |
| 202 | ctl-1, ctl-2, ctl-3 |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 203 | |
| 204 | .. code-block:: yaml |
| 205 | |
| 206 | > rabbitmqctl cluster_status |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 207 | |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 208 | Cluster status of node 'rabbit@ctl-1' ... |
Kirill Bespalov | 09e5218 | 2017-05-10 14:20:30 +0300 | [diff] [blame] | 209 | [{nodes,[{disc,['rabbit@ctl-1','rabbit@ctl-2','rabbit@ctl-3']}]}, |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 210 | {running_nodes,['rabbit@ctl-3','rabbit@ctl-2','rabbit@ctl-1']}, |
| 211 | {partitions,[]}] |
| 212 | ...done. |
| 213 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 214 | Setup management user: |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 215 | |
| 216 | .. code-block:: yaml |
| 217 | |
| 218 | > rabbitmqctl add_vhost vhost |
| 219 | > rabbitmqctl add_user user alive |
| 220 | > rabbitmqctl set_permissions -p vhost user ".*" ".*" ".*" |
| 221 | > rabbitmqctl set_user_tags user management |
| 222 | |
OlgaGusarenko | e27a2ea | 2018-07-31 00:59:36 +0300 | [diff] [blame] | 223 | EPD process is Erlang Port Mapper Daemon. It's a feature of the |
| 224 | Erlang runtime that helps Erlang nodes to find each other. It's a |
| 225 | pretty tiny thing and doesn't contain much state (other than "what |
| 226 | Erlang nodes are running on this system?") so it's not a huge deal for |
| 227 | it to still be running. |
| 228 | |
| 229 | Although it's running as user rabbitmq, it was started automatically |
| 230 | by the Erlang VM when we started. We've considered adding "epmd -kill" |
| 231 | to our shutdown script - but that would break any other Erlang apps |
| 232 | running on the system; it's more "global" than RabbitMQ. |
Filip Pytloun | ef5b0af | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 233 | |
| 234 | Read more |
| 235 | ========= |
| 236 | |
| 237 | * http://www.rabbitmq.com/admin-guide.html |
| 238 | * https://github.com/saltstack/salt-contrib/blob/master/states/rabbitmq_plugins.py |
| 239 | * http://docs.saltstack.com/ref/states/all/salt.states.rabbitmq_user.html |
| 240 | * http://stackoverflow.com/questions/14699873/how-to-reset-user-for-rabbitmq-management |
| 241 | * http://www.rabbitmq.com/memory.html |
| 242 | |
| 243 | Clustering |
| 244 | ========== |
| 245 | |
| 246 | * http://www.rabbitmq.com/clustering.html#auto-config |
| 247 | * https://github.com/jesusaurus/hpcs-salt-state/tree/master/rabbitmq |
| 248 | * http://gigisayfan.blogspot.cz/2012/06/rabbit-mq-clustering-python-fabric.html |
| 249 | * http://docwiki.cisco.com/wiki/OpenStack_Havana_Release:_High-Availability_Manual_Deployment_Guide#RabbitMQ_Installation |