建站不啰嗦,上手跟我做(二十九)rabbitMQ 安装

下载安装包

rabbitmq 下载官网地址:http://www.rabbitmq.com/
具体的安装包的下载:https://github.com/rabbitmq/rabbitmq-server/releases

下载依赖 erlang

erlang 的版本会影响到 rabbitmq 的安装,请按照要求安装指定的 erlang 版本
https://www.erlang.org/downloads/21.3

安装

安装 erlang

需要有如下依赖

yum -y install ncurses-devel

yum search libtool

yum search libtool-ltdl-devel

yum install libtool

yum install libtool-ltdl-devel

yum install gcc-c++

yum install erlang-doc

yum install erlang-jinterface

yum install openssl

yum install openssl-devel

[root@localhost mq]# ls
otp_src_21.3.tar.gz  rabbitmq-server-3.7.26-1.el7.noarch.rpm

[root@localhost mq]# tar -zxvf otp_src_21.3.tar.gz
[root@localhost mq]# cd otp_src_21.3/
[root@localhost otp_src_21.3]# ls
AUTHORS                 HOWTO                      Makefile.in            README.md
bin                     Jenkinsfile                otp_build              scripts
bootstrap               Jenkinsfile.benchmark      otp_patch_apply        system
configure               Jenkinsfile.run-otp-tests  OTP_VERSION            TAR.include
configure.src           Jenkinsfile.windows        otp_versions.table     xcomp
CONTRIBUTING.md         lib                        plt
erl-build-tool-vars.sh  LICENSE.txt                prebuilt.files
erts                    make                       proposed_updates.json
[root@localhost otp_src_21.3]# ./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac
[root@localhost otp_src_21.3]# make
[root@localhost otp_src_21.3]# make install
配置 erlang 环境变量
[root@localhost otp_src_21.3]# vim /etc/profile
ERLANG_HOME=/usr/local/erlang
export PATH=$PATH:$ERLANG_HOME/bin
export ERLANG_HOME
[root@localhost otp_src_21.3]# source /etc/profile
测试 erlang 是否安装成功
[root@localhost otp_src_21.3]# erl
Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]

Eshell V10.4  (abort with ^G)
1> ssl:versions() .
[{ssl_app,"9.2"},
 {supported,['tlsv1.2','tlsv1.1',tlsv1]},
 {supported_dtls,['dtlsv1.2',dtlsv1]},
 {available,['tlsv1.2','tlsv1.1',tlsv1,sslv3]},
 {available_dtls,['dtlsv1.2',dtlsv1]}]

2> halt() .

强制安装 rabbitmq

[root@localhost mq]# rpm -ivh --nodeps --force rabbitmq-server-3.7.26-1.el7.noarch.rpm
测试是否安装成功
[root@localhost ~]# rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
[root@localhost ~]# rabbitmqctl status
Status of node rabbit@localhost ...
[{pid,4096},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.7.26"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.7.26"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.7.26"},
      {rabbit,"RabbitMQ","3.7.26"},
      {os_mon,"CPO  CXC 138 46","2.4.7"},
      {amqp_client,"RabbitMQ AMQP Client","3.7.26"},
      {rabbit_common,
          "Modules shared by rabbitmq-server and rabbitmq-erlang-client",
          "3.7.26"},
      {sysmon_handler,"Rate-limiting system_monitor event handler","1.1.0"},
      {stdout_formatter,
          "Tools to format paragraphs, lists and tables as plain text",
          "0.2.2"},
      {cowboy,"Small, fast, modern HTTP server.","2.6.1"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.7.1"},
      {ssl,"Erlang/OTP SSL application","9.2"},
      {public_key,"Public key infrastructure","1.6.5"},
      {asn1,"The Erlang ASN1 compiler version 5.0.8","5.0.8"},
      {observer_cli,"Visualize Erlang Nodes On The Command Line","1.5.2"},
      {recon,"Diagnostic tools for production use","2.5.0"},
      {tools,"DEVTOOLS  CXC 138 16","3.1"},
      {mnesia,"MNESIA  CXC 138 12","4.15.6"},
      {cowlib,"Support library for manipulating Web protocols.","2.7.0"},
      {jsx,"a streaming, evented json parsing toolkit","2.9.0"},
      {credentials_obfuscation,
          "Helper library that obfuscates sensitive values in process state",
          "1.1.0"},
      {crypto,"CRYPTO","4.4.1"},
      {xmerl,"XML parser","1.3.19"},
      {inets,"INETS  CXC 138 49","7.0.6"},
      {lager,"Erlang logging framework","3.8.0"},
      {goldrush,"Erlang event stream processor","0.1.9"},
      {compiler,"ERTS  CXC 138 10","7.3.2"},
      {syntax_tools,"Syntax tools","2.1.7"},
      {sasl,"SASL  CXC 138 11","3.3"},
      {stdlib,"ERTS  CXC 138 10","3.8"},
      {kernel,"ERTS  CXC 138 10","6.3"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:64] [hipe]\n"},
 {memory,
     [{connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,2820},
      {queue_procs,0},
      {queue_slave_procs,0},
      {plugins,436980},
      {other_proc,24709364},
      {metrics,205804},
      {mgmt_db,135816},
      {mnesia,73216},
      {other_ets,2943984},
      {binary,189352},
      {msg_index,28848},
      {code,24495604},
      {atom,1221849},
      {other_system,10486075},
      {allocated_unused,8065104},
      {reserved_unallocated,10502144},
      {strategy,rss},
      {total,[{erlang,64929712},{rss,83496960},{allocated,72994816}]}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{http,15672,"::"}]},
 {vm_memory_calculation_strategy,rss},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1193775923},
 {disk_free_limit,50000000},
 {disk_free,3616657408},
 {file_descriptors,
     [{total_limit,924},{total_used,2},{sockets_limit,829},{sockets_used,0}]},
 {processes,[{limit,1048576},{used,392}]},
 {run_queue,1},
 {uptime,10},
 {kernel,{net_ticktime,60}}]
[root@localhost ~]# rabbitmqctl start_app
Starting node rabbit@localhost ...

开启 web 插件

[root@localhost mq]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@localhost:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@localhost...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.

用户管理

查看用户
[root@localhost rabbitmq]# rabbitmqctl list_users
Listing users ...
user	tags
guest	[administrator]
添加一个用户
[root@localhost rabbitmq]# rabbitmqctl add_user qiankunpingtai QKPT@rabbitmq123456
配置权限
[root@localhost rabbitmq]# rabbitmqctl set_permissions -p "/" qiankunpingtai ".*" ".*" ".*"
Setting permissions for user "qiankunpingtai" in vhost "/" ...

查看用户权限
[root@localhost rabbitmq]# rabbitmqctl list_user_permissions qiankunpingtai
Listing permissions for user "qiankunpingtai" ...
vhost	configure	write	read
/	.*	.*	.*

修改用户密码
[root@localhost rabbitmq]# rabbitmqctl change_password qiankunpingtai QKPT@rabbitmq+
Changing password for user "qiankunpingtai" ...

设置 tag
[root@localhost rabbitmq]# rabbitmqctl set_user_tags qiankunpingtai administrator
Setting tags for user "qiankunpingtai" to [administrator] ...

删除用户(安全起见,删除默认用户)
[root@localhost rabbitmq]# rabbitmqctl delete_user guest
Deleting user "guest" ...

访问

http://192.168.2.121:15672/

图片.png
图片.png

rabbitmq 操作

查看插件列表
[root@localhost rabbitmq]# rabbitmq-plugins list 
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@localhost
 |/
[  ] rabbitmq_amqp1_0                  3.7.26
[  ] rabbitmq_auth_backend_cache       3.7.26
[  ] rabbitmq_auth_backend_http        3.7.26
启用插件
[root@localhost rabbitmq]# rabbitmq-plugins enable XXX   (XXX为插件名)
停用插件
[root@localhost rabbitmq]#  rabbitmq-plugins disable XXX
重启服务
[root@localhost rabbitmq]# service rabbitmq-server restart
Redirecting to /bin/systemctl restart rabbitmq-server.service
停止服务
[root@localhost rabbitmq]# service rabbitmq-server stop
Redirecting to /bin/systemctl stop rabbitmq-server.service

卸载 MQ

yum list|grep rabbitmq

yum -y remove rabbitmq-server.noarch

Kafka、RabbitMQ、RocketMQ 优劣对比
上一篇 建站不啰嗦,上手跟我做(二十八)nacos 注册中心搭建
目录