rabbitmq 3 安装与配置
2016-04-20 by dongnan
开始之前
rabbitmq 采用 erlang
语言编写,所以需要先准备 erlang
。
环境
CentOS 6.7 amd64
Erlang
Erlang是一个结构化,动态类型编程语言,内建并行计算支持。Erlang运行时环境是一个虚拟机,有点像Java虚拟机,这样代码一经编译,同样可以随处运行。
它的运行时系统甚至允许代码在不被中断 的情况下更新。另外如果你需要更高效的话,字节代码也可以编译成本地代码运行。
详细请参考 erlang 官网
工具
yum -y install make ncurses-devel gcc gcc-c++ unixODBC unixODBC-devel openssl openssl-devel
源码
wget -c http://erlang.org/download/otp_src_18.3.tar.gz tar zxf otp_src_18.3.tar.gz
安装
配置
cd otp_src_18.3
./configure --prefix=/usr/local/erlang \
--enable-smp-support --enable-threads \
--enable-sctp --enable-kernel-poll --enable-hipe --with-ssl
编译安装
make && make install
环境变量
echo -e "export PATH=\$PATH:/usr/local/erlang/bin \n
export ERL_HOME=/usr/local/erlang" >> /etc/profile
source /etc/profile
验证
# 执行命令
erl
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.3 (abort with ^G)
# 退出 ctrl + c 键
Rabbitmq
简介
RabbitMQ 是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现。虽然在同步消息通讯的世界里有很多公开标准(如 COBAR的 IIOP ,或者是 SOAP 等),但是在异步消息处理中却不是这样,只有大企业有一些商业实现(如微软的 MSMQ ,IBM 的 Websphere MQ 等),因此,在 2006 年的 6 月,Cisco 、Redhat、iMatix 等联合制定了 AMQP 的公开标准。
RabbitMQ是由RabbitMQ Technologies Ltd开发并且提供商业支持的。该公司在2010年4月被SpringSource 收购。在2013年5月被并入Pivotal。
详细请参考 RabbitMQ 官网
步骤
源码
# 执行命令
wget -c http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xz
安装
编译
# 执行命令
xz -d rabbitmq-server-generic-unix-3.6.1.tar.xz
tar xvf rabbitmq-server-generic-unix-3.6.1.tar
mv /usr/local/rabbitmq_server-3.6.1/ /usr/local/rabbitmq
环境变量
# 执行命令
echo "export PATH=$PATH:/usr/local/rabbitmq/sbin" >> /etc/profile
source /etc/profile
启动
# 执行命令
/usr/local/rabbitmq/sbin/rabbitmq-server >> /tmp/rabbit.err 2>&1 &
# 开机启动
echo "/usr/local/rabbitmq/sbin/rabbitmq-server >> /tmp/rabbit.err 2>&1 &" >> /etc/rc.local
关闭
# 执行命令
/usr/local/rabbitmq/sbin/rabbitmqctl stop
验证
查看状态
# 执行命令
rabbitmqctl status
Status of node rabbit@localhost ...
[{pid,44015},
{running_applications,[{rabbit,"RabbitMQ","3.6.1"},
{rabbit_common,[],"3.6.1"},
{xmerl,"XML parser","1.3.10"},
{os_mon,"CPO CXC 138 46","2.4"},
{mnesia,"MNESIA CXC 138 12","4.13.3"},
{ranch,"Socket acceptor pool for TCP protocols.",
"1.2.1"},
{sasl,"SASL CXC 138 11","2.7"},
{stdlib,"ERTS CXC 138 10","2.8"},
{kernel,"ERTS CXC 138 10","4.2"}]},
{os,{unix,linux}},
{erlang_version,"Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:64] [hipe] [kernel-poll:true]\n"},
{memory,[{total,46310928},
{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,0},
{queue_procs,2808},
{queue_slave_procs,0},
{plugins,0},
{other_proc,18843520},
{mnesia,60344},
{mgmt_db,0},
{msg_index,47120},
{other_ets,875784},
{binary,20800},
{code,17287059},
{atom,662409},
{other_system,8511084}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,3298554675},
{disk_free_limit,50000000},
{disk_free,21931134976},
{file_descriptors,[{total_limit,924},
{total_used,2},
{sockets_limit,829},
{sockets_used,0}]},
{processes,[{limit,1048576},{used,144}]},
{run_queue,0},
{uptime,1465},
{kernel,{net_ticktime,60}}]