RabbitMQ简介
RabbitMQ 是由 LShift 提供的一个 Advanced Message Queuing Protocol (AMQP) 的开源实现,由以高性能、健壮以及可伸缩性出名的 Erlang 写成,因此也是继承了这些优点。消息中间件主要用于组件之间的解耦,消息的发送者无需知道消息使用者的存在,反之亦然。AMQP的主要特征是面向消息、队列、路由(包括点对点和发布/订阅)、可靠性、安全。RabbitMQ支持多种客户端,如:Python、Ruby、.NET、Java、JMS、C、PHP、ActionScript、XMPP、STOMP等,支持AJAX。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。RabbitMQ解决了应用程序之间的互联(connect)和规模(scale)的问题,消息发送和接收是隔离,发送方不知道消息最终由谁接收,接收方也不必关心消息是谁步发出的;发送和接收是隔离的,消息本质上就是异步的.这种隔离也就解耦了应用程序之间的依赖。RabbitMQ的角色就是应用程序中间的路由器。
规模(scale),应用程序解除了相互依赖之后从业务层面更容易做扩展,而Erlang的先天优势让代码层面的开发也更容易
安装erlang,执行命令`yum install -y erlang
出现下面图片则erlang安装成功。
下载RabbitMQ 执行命令wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.4.2/rabbitmq-server-3.4.2-1.noarch.rpm
安装RabbitMQ
执行rpm -ivh rabbitmq-server-3.4.2-1.noarch.rpm
命令
第一次安装的时候出现了错误 ,##error: unpacking of archive failed on file /usr/lib/rabbitmq/lib/rabbitmq_server-3.4.2/ebin/dtree.beam;564c8512: cpio: read failed - Bad file descriptor##,截图如下
看到网上说重试几次可以,我将原来的rpm文件删除掉,重新下载安装成功。
执行rabbitmqctl status
命令,得到如下的信息
Status of node rabbit@localhost ...
Error: unable to connect to node rabbit@localhost: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@localhost]
rabbit@localhost:
* connected to epmd (port 4369) on localhost
* epmd reports: node 'rabbit' not running at all
no other nodes on localhost
* suggestion: start the node
current node details:
- node name: 'rabbitmqctl-6310@localhost'
- home dir: /var/lib/rabbitmq
- cookie hash: ybKnLWdtnBMcXHwE5BIbig==
执行/etc/init.d/rabbitmq-server restart
命令,rabbitmq-server启动。
再次执行 rabbitmqctl status
命令
Status of node rabbit@localhost ...
[{pid,6475},
{running_applications,[{rabbit,"RabbitMQ","3.4.2"},
{mnesia,"MNESIA CXC 138 12","4.5"},
{os_mon,"CPO CXC 138 46","2.2.7"},
{xmerl,"XML parser","1.2.10"},
{sasl,"SASL CXC 138 11","2.1.10"},
{stdlib,"ERTS CXC 138 10","1.17.5"},
{kernel,"ERTS CXC 138 10","2.14.5"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:30] [kernel-poll:true]
"},
{memory,[{total,27093832},
{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,2648},
{queue_procs,2648},
{queue_slave_procs,0},
{plugins,0},
{other_proc,9081872},
{mnesia,57424},
{mgmt_db,0},
{msg_index,35520},
{other_ets,758616},
{binary,8144},
{code,14503690},
{atom,1352841},
{other_system,1290429}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,411407155},
{disk_free_limit,50000000},
{disk_free,12885368832},
{file_descriptors,[{total_limit,924},
{total_used,3},
{sockets_limit,829},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,121}]},
{run_queue,0},
{uptime,104}]
接下来安装mercurial git,执行yum install -y mercurial git
命令
继续安装 rabbitmq-public-umbrella
cd /var/lib/rabbitmq && hg clone http://hg.rabbitmq.com/rabbitmq-public-umbrella
cd /var/lib/rabbitmq/rabbitmq-public-umbrella && make co
继续安装
cd /var/lib/rabbitmq/rabbitmq-public-umbrella/rabbitmq-management && make
cd /var/lib/rabbitmq/rabbitmq-public-umbrella/ && git clone
https://github.com/rabbitmq/rabbitmq-priority-queue
cd /var/lib/rabbitmq/rabbitmq-public-umbrella/rabbitmq-priority-queue && make
cp /var/lib/rabbitmq/rabbitmq-public-umbrella/rabbitmq-priority-queue/dist/rabbitmq_priority_queue-0.0.0.ez
/usr/lib/rabbitmq/lib/rabbitmq_server-3.4.2/plugins/
rabbitmq-plugins enable --offline rabbitmq_priority_queue
rabbitmq-plugins enable --offline rabbitmq_management
/etc/init.d/rabbitmq-server restart
rabbitmqctl status