了解消息中间件 — RabbitMQ
中间件嘛,加一层呐
1、安装 rabbitMQ前先安装Erlang,先查看 对应适配版本
https://www.rabbitmq.com/which-erlang.html
去Erlang官网顺下来
https://www.erlang.org/downloads
# tar -zxvf otp_src_25.1.2.tar.gz //解压Erlang
# xz -d rabbitmq-server-generic-unix-3.11.2.tar.xz //解压RabbitMQ
# tar -xvf rabbitmq-server-generic-unix-3.11.2.tar
[root@iZwz99vgpeg038we3lyfj7Z csnz]# mkdir -p /usr/local/software/rabittmq
[root@iZwz99vgpeg038we3lyfj7Z csnz]# mv otp_src_25.1.2 /usr/local/software/rabittmq/
[root@iZwz99vgpeg038we3lyfj7Z csnz]# mv rabbitmq_server-3.11.2/ /usr/local/software/rabittmq/
yum install make gcc gcc-c++ build-essential openssl openssl-devel unixODBC unixODBC-devel kernel-devel m4 ncurses-devel
[root@iZwz99vgpeg038we3lyfj7Z rabittmq]# mkdir -p /usr/local/software/erlang
[root@iZwz99vgpeg038we3lyfj7Z otp_src_25.1.2]# ./configure --prefix=/usr/local/software/erlang/ --without-javac
make && make install
下面开始 配置Erlang环境变量
export ERLANG_HOME=/usr/local/software/erlang
export PATH=${ERLANG_HOME}/bin:${PATH}
source /etc/profile //重新读取配置文件
假如你遇到这个错误
接下来创建软连接
[root@iZwz99vgpeg038we3lyfj7Z otp_src_25.1.2]# ln -s /usr/local/software/erlang/bin/erl /usr/local/bin/erl
# RabbitMQ Environment
export RABBITMQ_HOME=/usr/local/software/rabbitmq/rabbitmq_server-3.11.2
export PATH=${RABBITMQ_HOME}/sbin:${PATH}
source /etc/profile //重新读取配置文件
# 设置RabbitMQ开机启动
source /etc/profile
/usr/local/software/rabbitmq/rabbitmq_server-3.11.2/sbin/rabbitmq-server -detached
后台启动RabbitMQ服务
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ./rabbitmq-server -detached
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ln -s /usr/local/software/rabittmq/rabbitmq_server-3.11.2/sbin/rabbitmqctl /usr/local/bin/rabbitmqctl
source /etc/profile //重新读取配置文件
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ./rabbitmqctl add_user csnz password
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ./rabbitmqctl set_user_tags csnz administrator
语法:
rabbitmqctl [--node
] [--longnames] [--quiet] set_permissions [--vhost ] 用户 csnz 具有 /vhost 这个 virtual host中所有资源的配置、写、读权限
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ./rabbitmqctl set_permissions -p "/" csnz ".*" ".*" ".*"
[root@iZwz99vgpeg038we3lyfj7Z sbin]# ./rabbitmqctl list_users