3. 布署和开发银行

[work@www.linuxidc.com ~]$ rabbitmq-server start
/home/work/rabbitmq/lib/rabbitmq_server-3.6.1/sbin/rabbitmq-server: line 49: /var/lib/rabbitmq/mnesia/rabbit@hkg02-mj-data07.pid: Permission denied
Failed to write pid file: /var/lib/rabbitmq/mnesia/rabbit@hkg02-mj-data07.pid

修改一下用户组:

[root@www.linuxidc.com work]# chown -R work:work /var/lib/rabbitmq/

再一次启航:

[work@www.linuxidc.com ~]$ rabbitmq-server start

              RabbitMQ 3.6.1. Copyright (C) 2007-2016 Pivotal Software, Inc.
  ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
  ##  ##
  ##########  Logs: /var/log/rabbitmq/rabbit@hkg02-mj-data07.log
  ######  ##        /var/log/rabbitmq/rabbit@hkg02-mj-data07-sasl.log
  ##########
              Starting broker... completed with 6 plugins.

[work@www.linuxidc.com ~]$ tailf /var/log/rabbitmq/rabbit@hkg02-mj-data07.log
Statistics database started.

=INFO REPORT==== 8-Apr-2016::16:54:51 ===
Server startup complete; 6 plugins started.
 * rabbitmq_management
 * rabbitmq_management_agent
 * rabbitmq_web_dispatch
 * webmachine
 * mochiweb
 * amqp_client

得逞了,肉留满面啊。。

TIPS

  1. 留心到源码安装的RabbitMQ暗中同意安装了6个插件,其实正是下面要介绍的督察和治本插件。
  2. 假定要后台运维: rabbitmq-server -detached
  3. 正在生产条件使用要求配备一下,比方内部存款和储蓄器,文件句柄限制,等。

RabbitMQ是基于Erlang的,所以率先必须配置Erlang际遇。

RabbitMQ安装

1 安装erlang
下载地址:
博主这里运用的是otp_src_19.1.tar.gz (200MB+)

[root@hidden util]# tar zxvf  otp_src_19.1.tar.gz
[root@hidden util]# cd otp_src_19.1 
[root@hidden otp_src_19.1]# ./configure --prefix=/opt/erlang
[root@hidden otp_src_19.1]# make 
[root@hidden otp_src_19.1]# make install

威澳门尼斯人36366com 1

修改/etc/profile文件,增加底下的处境变量:

ERLANG_HOME=/opt/erlang
export PATH=$PATH:$ERLANG_HOME/bin
export ERLANG_HOME

威澳门尼斯人36366com 2

最后试行source /etc/profile让文件生效。

2 安装simpleJson
下载地址:
博主这里运用的是simplejson-3.10.0.tar.gz

[root@hidden util]# tar zxvf simplejson-3.10.0.tar.gz
[root@hidden util]# cd simplejson-3.10.0
[root@hidden simplejson-3.10.0]# python setup.py install

威澳门尼斯人36366com 3

3 安装rabbitmq
下载地址:
博主这里用的版本就有成都百货上千了,比如2.7.0, 3.4.0, 3.4.1, 3.4.2, 3.4.3,
3.5.7,
3.6.0等等,可是都以用的rabbitmq-server-generic-unix-..*.tar.gz的版本。
这里以3.5.7举例:

[root@hidden util]# tar zvxf rabbitmq-server-generic-unix-3.5.7.tar.gz -C /opt
[root@hidden util]# cd /opt
[root@hidden util]# mv rabbitmq_server-3.5.7 rabbitmq

修改/etc/profile文件,增加下边包车型地铁意况变量:

export PATH=$PATH:/opt/rabbitmq/sbin

威澳门尼斯人36366com 4

提起底实施source /etc/profile让文件生效。
运行:rabbitmq-server -detached
随后运转rabbitmqctl status查看rabbitmq是不是通常运维:

[root@zhuzhonghua2-fqawb rabbitmq]# rabbitmqctl status
Status of node 'rabbit@zhuzhonghua2-fqawb' ...
[{pid,25020},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.5.7"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.5.7"},
      {rabbit,"RabbitMQ","3.5.7"},
      {mnesia,"MNESIA  CXC 138 12","4.14.1"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.7"},
      {webmachine,"webmachine","1.10.3-rmq3.5.7-gite9359c7"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.7-git680dba8"},
      {os_mon,"CPO  CXC 138 46","2.4.1"},
      {amqp_client,"RabbitMQ AMQP Client","3.5.7"},
      {inets,"INETS  CXC 138 49","6.3.3"},
      {xmerl,"XML parser","1.3.12"},
      {sasl,"SASL  CXC 138 11","3.0.1"},
      {stdlib,"ERTS  CXC 138 10","3.1"},
      {kernel,"ERTS  CXC 138 10","5.1"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:64] [hipe] [kernel-poll:true]\n"},
 {memory,
     [{total,60110136},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,5664},
      {queue_procs,1028160},
      {queue_slave_procs,1576056},
      {plugins,8008840},
      {other_proc,6115560},
      {mnesia,197760},
      {mgmt_db,14219256},
      {msg_index,58288},
      {other_ets,1181200},
      {binary,633896},
      {code,17650127},
      {atom,711593},
      {other_system,8723736}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,3301929779},
 {disk_free_limit,50000000},
 {disk_free,35754786816},
 {file_descriptors,
     [{total_limit,924},{total_used,6},{sockets_limit,829},{sockets_used,1}]},
 {processes,[{limit,1048576},{used,195}]},
 {run_queue,0},
 {uptime,139660}]

威澳门尼斯人36366com 1

2. 安装rabbitmq

一齐初图方便,想间接使用yum恐怕rpm包安装,结果开掘难题一大堆。。。:

[root@www.linuxidc.com downloads]# rpm -Uvh rabbitmq-server-3.6.1-1.noarch.rpm
error: Failed dependencies:
    erlang >= R16B-03 is needed by rabbitmq-server-3.6.1-1.noarch

会报未有找到erlang信赖,然则其实大家曾经由此kerl脚本安装过了,所以能够直接忽略(Install
RabbitMQ on CentOS 6):

[root@www.linuxidc.com downloads]# rpm --nodeps -Uvh rabbitmq-server-3.6.1-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:rabbitmq-server        ########################################### [100%]

果不其然很简单,可是开选用root安装会促成种种离奇的标题:

[root@www.linuxidc.com ~]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
[root@www.linuxidc.com rabbitmq]# tailf startup_err
mkdir: cannot create directory `/var/run/rabbitmq': Permission denied

最后照旧调控利用源码安装。。首先卸载掉原本的设置:

[root@www.linuxidc.com ~]# yum remove rabbitmq-server
Loaded plugins: aliases, downloadonly, fastestmirror, priorities, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package rabbitmq-server.noarch 0:3.6.1-1 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                                 Arch                           Version                         Repository                         Size
================================================================================================================================================
Removing:
 rabbitmq-server                         noarch                         3.6.1-1                         installed                         5.5 M

Transaction Summary
================================================================================================================================================
Remove        1 Package(s)

Installed size: 5.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Erasing    : rabbitmq-server-3.6.1-1.noarch                                                                                               1/1
Stopping rabbitmq-server: RabbitMQ is not running
rabbitmq-server.
  Verifying  : rabbitmq-server-3.6.1-1.noarch                                                                                               1/1

Removed:
  rabbitmq-server.noarch 0:3.6.1-1

Complete!

再源码安装:building RabbitMQ server from
source。

不过私下认可会安装到/usr/local目录,然后又是root运行。。所以大家要修改他的默许安装地点,但是文书档案并未证实怎么钦点,查看Makefile发掘如下变量:

DESTDIR ?=

PREFIX ?= /usr/local
WINDOWS_PREFIX ?= rabbitmq-server-windows-$(VERSION)

MANDIR ?= $(PREFIX)/share/man
RMQ_ROOTDIR ?= $(PREFIX)/lib/erlang
RMQ_BINDIR ?= $(RMQ_ROOTDIR)/bin
RMQ_LIBDIR ?= $(RMQ_ROOTDIR)/lib
RMQ_ERLAPP_DIR ?= $(RMQ_LIBDIR)/rabbitmq_server-$(VERSION)

就此大家得以那样子编写翻译:

[work@www.linuxidc.com downloads]$ cd rabbitmq-server-3.6.1
[work@www.linuxidc.com rabbitmq-server-3.6.1]$ make
[work@www.linuxidc.com rabbitmq-server-3.6.1]$ make install PREFIX=/home/work/rabbitmq RMQ_ROOTDIR=/home/work/rabbitmq RMQ_ERLAPP_DIR=
/usr/bin/make64 MAC=64 install PREFIX=/home/work/rabbitmq RMQ_ROOTDIR=/home/work/rabbitmq

[work@www.linuxidc.com ~]$ vim .bashrc

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

ERL_HOME=/home/work/erlang/18.3
export PATH=$PATH:$ERL_HOME/bin

RABBITMQ_HOME=/home/work/rabbitmq/lib/rabbitmq_server-3.6.1
export PATH=$PATH:$RABBITMQ_HOME/sbin

[work@www.linuxidc.com ~]$ source .bashrc

RabbitMq的安装:

RabbitMQ集群搭建方法

那边呈现的是多机集群的安排,假设机器受限,可以挑选单机集群安顿,详细能够参照《RabbitMQ单机多实例配置》。
此地选拔三台主机,主机名分别是hidden1, hidden2, hidden3
1 在那三台机械中安装rabbitmq-server, 参照他事他说加以考察上面。

2 读取在那之中一个节点的cookie,
并复制到其余节点(节点之间通过cookie明确互相是或不是可通讯)。
cookie存放在/var/lib/rabbitmq/.erlang.cookie或者$HOME/.erlang.cookie中。

3 各个运行节点 rabbitmq-server -detached

4 查看各节点的气象: rabbitmqctl status, rabbitmqctl cluster_status

5 配置各节点的hosts文件( vim /etc/hosts)
xxx.xxx.xxx.xxx hidden1
xxx.xxx.xxx.xxx hidden2
xxx.xxx.xxx.xxx hidden3

6 成立集群
以hidden1为主节点,在hidden2上:
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@hidden1
rabbitmqctl start_app
hidden3上的操作与hidden2的大同小异。
最后通过rabbitmqctl cluster_status查看集群的动静消息:

[{nodes,[{disc,[rabbit@hidden1,'rabbit@hidden2','rabbit@hidden3']}]},
 {running_nodes,[rabbit@hidden1,'rabbit@hidden2','rabbit@hidden3']},
 {cluster_name,<<"rabbit@hidden1">>},
 {partitions,[]}]

7 在访问web(,
假若在Overview中的Nodes部分来看“Node statistics not
available”的新闻,表达在该节点上web管理插件还未启用。直接运维rabbitmq-plugins
enable rabbitmq_management即可。

CentOS 7.2 下 RabbitMQ
集群搭建
http://www.linuxidc.com/Linux/2016-12/137812.htm

CentOS7条件设置使用专门的学业的新闻队列产品RabbitMQ
http://www.linuxidc.com/Linux/2016-11/13673.htm

RabbitMQ入门教程 
http://www.linuxidc.com/Linux/2015-02/113983.htm

在CentOS7上安装RabbitMQ 详解 
http://www.linuxidc.com/Linux/2017-05/143765.htm

NServiceBus 结合 RabbitMQ 使用教程 
http://www.linuxidc.com/Linux/2017-05/143787.htm

CentOS 7下RabbitMQ集群安装配置 
http://www.linuxidc.com/Linux/2017-10/147707.htm

RabbitMQ实战:高效配置布满式音信队列 中文PDF扫描版 
http://www.linuxidc.com/Linux/2017-10/147592.htm

RabbitMQ
的事无巨细介绍
:请点这里
RabbitMQ
的下载地址
:请点这里

本文恒久更新链接地址:http://www.linuxidc.com/Linux/2017-10/147723.htm

威澳门尼斯人36366com 6

4. 管理和监察和控制

Management Plugin

倘尽管源码安装,这一步能够忽略:

[work@www.linuxidc.com ~]$ rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@hkg02-mj-data07... started 6 plugins.

接下来重启服务。

治本插件私下认可是监听15672端口,大家能够修改这么些布局项:

[work@www.linuxidc.com ~]$ vim /etc/rabbitmq/rabbitmq.config
{rabbitmq_management,
  [ {http_log_dir,  "/tmp/rabbit-mgmt"},
    {rates_mode,    basic},
    {listener, [{port,     8345}]}
]},

前几日大家得以在浏览器直接访问了:

=WARNING REPORT==== 8-Apr-2016::17:05:33 ===
HTTP access denied: user '' - invalid credentials

=ERROR REPORT==== 8-Apr-2016::17:05:33 ===
webmachine error: path="/api/whoami"
"Unauthorized"

=INFO REPORT==== 8-Apr-2016::17:05:33 ===
webmachine_log_handler: closing log file: "/tmp/rabbit-mgmt/access.log"

=INFO REPORT==== 8-Apr-2016::17:05:33 ===
opening log file: "/tmp/rabbit-mgmt/access.log.2016_04_08_09"
^@
=WARNING REPORT==== 8-Apr-2016::17:06:03 ===
HTTP access denied: user 'guest' - User can only log in via localhost

guest只好经过本机访谈。查看文书档案必要动用rabbitmqctl add_user来创制三个non-administrator
user 和 rabbitmqctl set_user_tags来提高一个普通用户为大班:

[work@www.linuxidc.com ~]$ rabbitmqctl add_user argan xxxx
Creating user "argan" ...
[work@www.linuxidc.com ~]$ rabbitmqctl list_users
Listing users ...
argan   []
guest   [administrator]
[work@www.linuxidc.com ~]$ rabbitmqctl set_user_tags argan administrator
Setting tags for user "argan" to [administrator] ...
[work@www.linuxidc.com ~]$ rabbitmqctl list_users
Listing users ...
argan   [administrator]
guest   [administrator]

果不其然能够登录成功了,管理节目仍然很清爽的~��

还是能通过管住插件查看API:

不过开掘用管理节目创立二个行列平昔未有反应,Console彰显为 PUT
401
(Unauthorized)。日志展现:

=ERROR REPORT==== 8-Apr-2016::17:43:45 ===
webmachine error: path="/api/queues/%2F/91-order-wq"
"Unauthorized"
^@^@^@^@
=WARNING REPORT==== 8-Apr-2016::17:48:10 ===
HTTP access denied: user 'argan' - User not authorised to access virtual host

=ERROR REPORT==== 8-Apr-2016::17:48:10 ===
webmachine error: path="/api/queues/%2F/91-order-wq"
"Unauthorized"

是未曾权限,原本 administrator 还不是全能的。。好啊。。

[work@www.linuxidc.com ~]$ rabbitmqctl add_vhost /mobopay
Creating vhost "/mobopay" ...
[work@www.linuxidc.com ~]$ rabbitmqctl set_user_tags argan  administrator management
Setting tags for user "argan" to [administrator,management] ...
[work@www.linuxidc.com ~]$ rabbitmqctl set_permissions -p /mobopay argan '.*' '.*' '.*'
Setting permissions for user "argan" in vhost "/mobopay" ... 

果不其然能够了。

rabbitmq安装

  1. tar zxvfrabbitmq-server-3.3.4.tar.gz /opt解压到钦点的公文夹下
  2. 修改/etc/profile,加多情状变量:#set rabbitmq environment  export PATH=$PATH:/opt/rabbitmq/sbin
  3. source profile使得文件生效 

启用监察和控制管理格局(用网页方式管理MQ)

  1. 执行./rabbitmq-plugin enable rabbitmq-management
  2. 重新启航rabbitmq
  3. 私下认可配置,就可以登陆

设若/etc/rabbitmq官样文章会报如下错误:
Error:
{cannot_write_enabled_plugins_file,”/etc/rabbitmq/enabled_plugins”,
enoent}

解决方法

mkdir /etc/rabbitmq

——————————————————————————————————————

动用验证如下:

在利用进程中的难点:使用暗中认可的账号guest登入管控台,却提醒登录失利。是因为出于安全因素的考虑,guest用户只可以通过localhost登入使用。所以一旦在别的电话上登陆远端的rabbitmq服务器要求新建二个用户,况且新用户需求给予顶级管理员(administrator)权限

 

有的常用的rabbitmq/sbin/下的通令

启动RabbitMQ            ./rabbitmq-server -detached

停止RabbitMQ            ./rabbitmqctl stop

翻开已经安装的插件    ./rabbitmq-plugins list

启用监控插件
              ./rabbitmq-plugins enable rabbitmq_management

关门监察和控制插件
       ./rabbitmq-plugins disable rabbitmq_management

增加产量三个用户
              rabbitmqctl  add_user  Username  Password

删去一个用户
              rabbitmqctl  delete_user  Username

修改用户的密码
           rabbitmqctl  change_password  Username  Newpassword

查看当前用户列表
        rabbitmqctl  list_users

授予一流管理员权限
     ./rabbitmqctl set_user_tags newuser administrator

CentOS 5.6 安装RabbitMQ
http://www.linuxidc.com/Linux/2013-02/79508.htm

RabbitMQ客户端C++安装详细记录
http://www.linuxidc.com/Linux/2012-02/53521.htm

用Python尝试RabbitMQ
http://www.linuxidc.com/Linux/2011-12/50653.htm

RabbitMQ集群情状生产实例陈设
http://www.linuxidc.com/Linux/2012-10/72720.htm

Ubuntu下PHP +
RabbitMQ使用
http://www.linuxidc.com/Linux/2010-07/27309.htm

在CentOS上安装RabbitMQ流程
http://www.linuxidc.com/Linux/2011-12/49610.htm

RabbitMQ概念及蒙受搭建 http://www.linuxidc.com/Linux/2014-12/110449.htm

RabbitMQ入门教程 
http://www.linuxidc.com/Linux/2015-02/113983.htm

RabbitMQ
的详尽介绍
:请点这里
RabbitMQ
的下载地址
:请点这里

本文永远更新链接地址:http://www.linuxidc.com/Linux/2015-10/124457.htm

威澳门尼斯人36366com 7

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注