CentOS7 安装 RabbitMQ

RabbitMQ是流行的开源消息队列系统,是AMQP(Advanced Message Queuing Protocol高级消息队列协议)的标准实现,用erlang语言开发。RabbitMQ据说具有良好的性能和时效性,同时还能够非常好的支持集群和负载部署,非常适合在较大规模的分布式系统中使用,具体特性还在验证中,待检验。由于项目需要,安装并配置了RabbitMQ,服务器操作系统是CentOS7。具体步骤如下:

安装依赖文件:

yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto

1.Erlang安装配置

下载安装包,地址http://www.erlang.org/downloads,我选择的是otp_src_20.2.tar.gz。

然后解压文件:

 tar -xzvf otp_src_20.2.tar.gz
 cd otp_src_20.2/

配置安装路径编译代码:

 ./configure --prefix=/mlr/resources/erlang

执行编译结果:

 make && make install

完成后进入/mlr/resources/erlang查看执行结果

 cd /mlr/resources/erlang/bin
 ./erl

Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.2 (abort with ^G)
1>

当出现以上信息时表示安装完成。然后输入’halt().’退出即可。

然后在配置Erlang环境变量,vi /etc/profile文件,增加下面的环境变量:

#set erlang environment
export PATH=$PATH:/mlr/resources/erlang/bin
source  /etc/profile  使得文件生效

在安装Erlang过程中,可能会遇到以下问题,一般都是因为系统中缺少相应的包引起的,缺少什么包直接yum安装即可。

2.下载安装RabbitMq

下载地址: http://www.rabbitmq.com/
我下载的是rabbitmq-server-generic-unix-3.7.2.tar.xz

解压文件

 xz -d rabbitmq-server-generic-unix-3.7.2.tar.xz
 tar -xvf rabbitmq-server-generic-unix-3.7.2.tar

解压后进入文件夹/mlr/resources发现多了个文件夹rabbitmq-server-3.7.2
  然后在配置rabbitmq环境变量,vi /etc/profile文件,增加下面的环境变量:

#set rabbitmq environment
export PATH=$PATH:/mlr/resources/rabbitmq-server-3.7.2/sbin
source  /etc/profile  使得文件生效

3.RabbitMQ服务启动关闭
  以上就已经完成了RabbitMq的安装,怎么启动服务呢?
  启动服务:

cd sbin/
./rabbitmq-server -detached

查看服务状态:

 ./rabbitmqctl status

Status of node rabbit@iZwz9ikfzd0p623rtyt3npZ …
[{pid,6226},
{running_applications,
[{rabbit,“RabbitMQ”,“3.7.2”},
{mnesia,“MNESIA CXC 138 12”,“4.15.2”},
{inets,“INETS CXC 138 49”,“6.4.5”},
{rabbit_common,
“Modules shared by rabbitmq-server and rabbitmq-erlang-client”,
“3.7.2”},
{ranch_proxy_protocol,“Ranch Proxy Protocol Transport”,“1.4.4”},
{ranch,“Socket acceptor pool for TCP protocols.”,“1.4.0”},
{ssl,“Erlang/OTP SSL application”,“8.2.3”},
{public_key,“Public key infrastructure”,“1.5.2”},
{asn1,“The Erlang ASN1 compiler version 5.0.4”,“5.0.4”},
{jsx,“a streaming, evented json parsing toolkit”,“2.8.2”},
{os_mon,“CPO CXC 138 46”,“2.4.4”},
{crypto,“CRYPTO”,“4.2”},
{recon,“Diagnostic tools for production use”,“2.3.2”},
{xmerl,“XML parser”,“1.3.16”},
{lager,“Erlang logging framework”,“3.5.1”},
{goldrush,“Erlang event stream processor”,“0.1.9”},
{compiler,“ERTS CXC 138 10”,“7.1.4”},
{syntax_tools,“Syntax tools”,“2.1.4”},
{sasl,“SASL CXC 138 11”,“3.1.1”},
{stdlib,“ERTS CXC 138 10”,“3.4.3”},
{kernel,“ERTS CXC 138 10”,“5.4.1”}]},
{os,{unix,linux}},
{erlang_version,
“Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:64] [hipe] [kernel-poll:true]\n”},
{memory,
[{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,0},
{queue_procs,0},
{queue_slave_procs,0},
{plugins,5864},
{other_proc,25637392},
{metrics,184432},
{mgmt_db,0},
{mnesia,74152},
{other_ets,1965568},
{binary,136168},
{msg_index,32112},
{code,24920077},
{atom,1041593},
{other_system,9145810},
{allocated_unused,12886784},
{reserved_unallocated,0},
{strategy,rss},
{total,[{erlang,63143168},{rss,73658368},{allocated,76029952}]}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_calculation_strategy,rss},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,416322355},
{disk_free_limit,50000000},
{disk_free,35786248192},
{file_descriptors,
[{total_limit,65435},
{total_used,2},
{sockets_limit,58889},
{sockets_used,0}]},
{processes,[{limit,1048576},{used,200}]},
{run_queue,0},
{uptime,84},
{kernel,{net_ticktime,60}}]
  关闭服务:

 ./rabbitmqctl stop

4. 配置网页插件
  首先创建目录,否则可能报错:

mkdir /etc/rabbitmq

然后启用插件:

./rabbitmq-plugins enable rabbitmq_management

配置linux 端口 15672 网页管理 5672 AMQP端口
  然后访问http://localhost:15672即可
  
  5. 远程访问配置

默认网页是不允许访问的,需要增加一个用户修改一下权限,进入sbin代码如下:

添加用户: ./rabbitmqctl add_user mlr mlr
添加权限: ./rabbitmqctl set_permissions -p "/" mlr ".*" ".*" ".*"
修改用户角色: ./rabbitmqctl set_user_tags hxb administrator

然后就可以远程访问了,然后可直接配置用户权限等信息。
  6. rabbitmq常用命令

add_user

delete_user

change_password

list_users

add_vhost

delete_vhost

list_vhostsset_permissions [-p ]

clear_permissions [-p ]

list_permissions [-p ]

list_user_permissions

list_queues [-p ] [ …]

list_exchanges [-p ] [ …]

list_bindings [-p ]

list_connections [ …]

最近在整理一些资源工具,放在网站分享 http://tools.maqway.com
欢迎关注公众号:麻雀唯伊 , 不定时更新资源文章,生活优惠,或许有你想看的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值