头图

RabbitMQ windows installation

Download RabbitMQ

https://www.rabbitmq.com/install-windows.html

Search keyword Download

Download the erlang environment installation package

https://www.erlang.org/downloads

Install and configure erlang

Click the otp_win64_24.0.exe

Just keep next, remember your own installation path, just use the default one, if you customize, it’s best to have the entire path in English

New environment variable

  • New system variable-type in the variable name ERLANG_HOME

  • %ERLANG_HOME%\bin is added to Path

  • Enter cmd to view the effect

image-

As shown in the figure above, the erlang environment is successfully configured for installation

Install and configure RabbitMQ server

  • Install the rabbitmq-server-3.8.19.exe downloaded above, just keep next, remember your installation path, and use the default one. If you customize it, it is recommended that the entire path be in English
  • Open cmd and enter the directory, for example, my directory is: C:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.19\sbin
  • Execute rabbitmq-plugins enable rabbitmq_management

You will see the above effect, the three plug-ins are activated

Account: guest

Password: guest

Command (can be executed in cmd)

net start RabbitMQ  启动
net stop RabbitMQ  停止
rabbitmqctl status  查看状态

RabbitMQ ubuntu installation

Let's take a look at how to install and use RabbitMQ in Linux

RabbitMQ is written in erlang language, so before installing RabbitMQ, we need to install erlang, and erlang needs to install python and simplejson

Install pyhton

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz

tar xvf  Python-3.5.2.tar.xz

cd Python-3.5.2

./configure

make && make install

Install simplejson

sudo apt-get install python-simplejson -y

Install Erlang dependencies

sudo apt-get install build-essential -y
sudo apt-get install libncurses5-dev -y
sudo apt-get install libssl-dev -y
sudo apt-get install m4 -y
sudo apt-get install unixodbc unixodbc-dev -y
sudo apt-get install freeglut3-dev libwxgtk2.8-dev -y
sudo apt-get install xsltproc -y
sudo apt-get install fop -y
sudo apt-get install tk8  -y

Install Erlang

sudo apt-get install erlang -y

Install RabbitMQ

sudo apt-get update

sudo apt-get install rabbitmq-server

View RabbitMQ status

# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ Messaging Server
   Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-07-23 14:51:31 CST; 7min ago
 Main PID: 426 (beam.smp)
   Status: "Initialized"
    Tasks: 85 (limit: 2338)
   CGroup: /system.slice/rabbitmq-server.service
           ├─ 413 /bin/sh /usr/sbin/rabbitmq-server
           ├─ 426 /usr/lib/erlang/erts-9.2/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true -- -root /usr/lib/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa
           ├─ 604 /usr/lib/erlang/erts-9.2/bin/epmd -daemon
           ├─ 904 erl_child_setup 65536
           ├─1000 inet_gethost 4
           └─1001 inet_gethost 4

RabbitMQ management

The RabbitMQ management plug-in can provide a web management interface to manage virtual hosts, users, etc., and can also be used to manage queues, switches, binding relationships, strategies, parameters, etc.

It can also be used to monitor the status of the RabbitMQ service and some statistical information. Those who are interested can feel it

Multi-tenancy and permissions

Each RabbitMQ server can create a virtual message server, called a virtual host (Virtual Host), or vhost for short.

Each is essentially an independent small RabbitMQ server, with its own independent queues, switches, and binding relationships, etc., and it has its own independent authority.

Virtual Hosts are absolutely isolated from each other, and it is impossible to bind the switch in vhost1 with the queue in vhost2, which not only ensures security, but also ensures portability

After installing RabbitMQ, there will be a default vhost of /

  • Use the rabbitmqctl add_vhost xxx command to create a new vhost
root@xxx:/# rabbitmqctl add_vhost testvhost
Creating vhost "testvhost"
  • When deleting the vhost command rabbitmqctl delete_vhost xxx
root@xx:/# rabbitmqctl delete_vhost testvhost
Deleting vhost "testvhost"

note

Deleting a vhost will also delete all queues, switches, binding relationships, user permissions, parameters, and policies under it.

  • In RabbitMQ, permission control is based on vhost.

When creating a user, the user is usually assigned to at least one vhost, and can only access the queues, switches, and binding relationships within the assigned vhost.

Therefore, the authorization in RabbitMQ refers to the authorization granted to the user at the vhost level

The relevant authorization commands are:

rabbitmqctl set_permissions [-p vhost] {user} {conf} {write} {read}

  • vhost: The name of the vhost that grants access to the user, which can be set as the default value, that is, the vhost is /
  • user: the user name that can access the specified vhost
  • conf: A regular expression used to match which resources have configurable permissions
  • write: A regular expression used to match which resources have writable permissions
  • read: A regular expression used to match which resources have readable permissions
  • Grant root users to access the virtual host testvhost, and have configurable, writable and readable permissions on all resource providers
root@xxx:/# rabbitmqctl set_permissions -p testvhost root ".*" ".*" ".*"
Setting permissions for user "root" in vhost "testvhost"
  • List authority information

Used to display the permissions on the virtual host: rabbitmqctl list_permissions [-p vhost]

root@xxx:/# rabbitmqctl list_permissions -p testvhost
Listing permissions in vhost "testvhost"
root    .*      .*      .*

Used to display user permissions: rabbitmqctl list_user_permissions {username}

root@983cebfa9073:/# rabbitmqctl list_user_permissions root 
Listing permissions for user "root"
testvhost  .*      .*      .*
/       .*      .*      .*

User Management

In RabbitMQ, users are the basic unit of access control

A single user can authorize across multiple vhosts

For one or more vhosts, users can be given different levels of access rights, and use standard user names and passwords to authenticate users

  • The command to create a user is

rabbitmqctl add_user {username} {password}

root@xx:/# rabbitmqctl add_user root 123456
Creating user "root"
  • Change the password of the specified user

rabbitmqctl change_password {username} {password}

root@xx:/# rabbitmqctl change_password root test001
Changing password for user "root"
  • Set user role

User roles are divided into 5 types

RoleAuthority
administrator highest authority , contains all the permissions of monitoring, and can manage users, virtual hosts, permissions, policies, parameters, etc.
monitoringContains all management permissions, and you can see all connections, channels, and node related information
policymakerContains all management permissions, and can manage policies and parameters
managementCan access the web management interface
noneDefault permissions, no roles, new users default to none

rabbitmqctl set_user_tags {username} {tag …}

root@xx:/# rabbitmqctl set_user_tags root administrator
Setting tags for user "root" to [administrator]
  • Clear password

rabbitmqctl clear_password {username}

root@xx:/# rabbitmqctl clear_password root
Clearing password for user "root"
  • Verify user password

rabbitmqctl authenticate_user {username} {password}

root@xx:/# rabbitmqctl authenticate_user root test001
Authenticating user "root"
Success
root@xx:/# rabbitmqctl authenticate_user root 123456   
Authenticating user "root"
Error: failed to authenticate user "root"
  • View current user list

rabbitmqctl list_users, each user is followed by the user's role

root@xx:/# rabbitmqctl list_users
Listing users
root    [administrator]
  • delete users

    rabbitmqctl delete_use {username}

root@xx:/# rabbitmqctl delete_user root
Deleting user "root"

Web management

Access the web management interface

  • local

http://localhost:15672/

  • Remotely

http://IP:15672/

Listening ports

ProtocolBound toPort
amqp::5672
clustering::25672
http::15672
  • 5672 port

When using amqp protocol

  • 15672

Port required to access the web management page

  • 25672

In a cluster, it is used when multiple rabbitmq-servers communicate with each other

Reference:

RabbitMQ Tutorials

Welcome to like, follow, favorite

Friends, your support and encouragement are my motivation to keep sharing and improve quality

Okay, that's it for this time

Technology is open, and our mindset should be more open. Embrace the change, live toward the sun, and work hard to move forward.

I am Nezha , welcome to like and follow the collection, see you next time~


阿兵云原生
192 声望37 粉丝