首页 > 代码库 > RabbitMQ概念及环境搭建(一)单节点安装与配置

RabbitMQ概念及环境搭建(一)单节点安装与配置

###############################################
#异步、分布式消息处理模型
###############################################

                                                    binding  +----------+    +----------------+
                                                 /------------+ queue +---+ consumer +
+---------------+   +----------------+   |            +-----------+   +----------------+
+ publisher +---+ exchange +---|
+---------------+   +----------------+   \           +-----------+   +----------------+
                                                      -----------+ queue +---+ consumer +
                                                   binding  +-----------+   +----------------+

################################################
RabbitMQ Server安装
################################################
1.安装Erlang
sudo yum install erlang

2.安装RabbitMQ Server
需要先导入key
sudo rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
可先将内容保存至文本文件,如,rabbitmq-signing-key-public.asc.txt
sudo rpm --import rabbitmq-signing-key-public.asc.txt 

3.安装rabbitmq-server-3.4.1-1.noarch.rpm
sudo yum install rabbitmq-server-3.4.1-1.noarch.rpm

4.启动RabbitMQ Server
注册为系统服务
sudo chkconfig rabbitmq-server on
启动RabbitMQ Server
sudo /etc/init.d rabbitmq-server stop/start/etc
sudo service rabbitmq-server stop/start/etc

5.若启动失败检测端口是否被占用
4369 (epmd), 25672 (Erlang distribution)
5672, 5671 (AMQP 0-9-1 without and with TLS)
15672 (if management plugin is enabled)
61613, 61614 (if STOMP is enabled)
1883, 8883 (if MQTT is enabled)

参考:
http://www.rabbitmq.com/install-rpm.html

##################################################
RabbitMQ Server 配置
##################################################
1.通过环境变量进行配置
可直接在Shell中进行配置
或在rabbitmq-env.conf中配置

2.通过配置文件进行配置
sudo cp /usr/share/doc/rabbitmq-server-3.4.1/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
sudo vim /etc/rabbitmq/rabbitmq.config

相关文件位置 
对于RPM为/etc/rabbitmq/,如/etc/rabbitmq/rabbitmq.config、/etc/rabbitmq/rabbitmq-env.conf

3.运行时配置

参考:
http://www.rabbitmq.com/configure.html

#################################################
#RabbitMQ 日志、用户、client
#################################################
1.日志
ls -l /var/log/rabbitmq

2.默认virtual host与默认user
virtual host: /
user:guest
passwd:guest
注:默认用户只可在localhost上连至/且有全部权限

3.RabbitMQ Client
python client
pika-0.9.14.tar.gz
tar -xzvf pika-0.9.14.tar.gz
cd pika-0.9.14
sudo python27 setup.py install

JS client
amqp.node

RabbitMQ概念及环境搭建(一)单节点安装与配置