Installation and configuration of RabbitMQ service under CentOS7

RabbitMQ is a popular open source message queuing system, a standard implementation of AMQP (Advanced Message Queuing Protocol), developed in erlang language. RabbitMQ is said to have good performance and timeliness, and it can also support cluster and load deployment very well. It is very suitable for use in large-scale distributed systems. The specific characteristics are still being verified and to be tested. Due to the needs of the project, RabbitMQ is installed and configured, and the server operating system is CentOS 7. Specific steps are as follows:

  Install dependencies:

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

  1.Erlang installation configuration

  Download the installation package at http://www.erlang.org/downloads, I chose otp_src_18.3.tar.gz.

  Then unzip the file:

[root@iZ25e3bt9a6Z rabbitmq]# tar -xzvf otp_src_18.3.tar.gz
[root@iZ25e3bt9a6Z rabbitmq]# cd otp_src_18.3/

  Configure the installation path to compile the code:

[root@iZ25e3bt9a6Z otp_src_18.3]# ./configure --prefix=/opt/erlang

  Execute the compilation result:

[root@iZ25e3bt9a6Z otp_src_18.3]# make && make install

  After completion, enter /opt/erlang to view the execution result

[root@iZ25e3bt9a6Z rabbitmq]# cd /opt/erlang/
[root@iZ25e3bt9a6Z erlang]# 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)
1>

  The installation is complete when the above message appears. Then enter 'halt().' to exit.

  Then configure the Erlang environment variables, vi /etc/profile file, and add the following environment variables:

#set erlang environment
export PATH=$PATH:/opt/erlang/bin


  source /etc/profile makes the file take effect

  In the process of installing Erlang, you may encounter the following problems, which are generally caused by the lack of corresponding packages in the system. The missing packages can be installed directly with yum.

  2. Download and install RabbitMq

[root@iZ25e3bt9a6Z rabbitmq]# weget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xz

  unzip files

[root@iZ25e3bt9a6Z rabbitmq]# xz -d rabbitmq-server-generic-unix-3.6.1.tar.xz
[root@iZ25e3bt9a6Z rabbitmq]# tar -xvf rabbitmq-server-generic-unix-3.6.1.tar  -C /opt

  After decompression, enter the folder /opt and find that there is an additional folder rabbitmq-server-generic-unix-3.6.1, renamed rabbitmq for memory.

  Then configure the rabbitmq environment variables, vi /etc/profile file, and add the following environment variables:

#set rabbitmq environment
export PATH=$PATH:/opt/rabbitmq/sbin

  source /etc/profile makes the file take effect

  3. The RabbitMQ service starts and shuts down

  The above has completed the installation of RabbitMq, how to start the service?

  Start the service:

[root@iZ25e3bt9a6Z rabbitmq]# cd sbin/
[root@iZ25e3bt9a6Z sbin]# ./rabbitmq-server -detached

  Check service status:

[root@iZ25e3bt9a6Z sbin]# ./rabbitmqctl status
Status of node rabbit@iZ25e3bt9a6Z ...
[{pid,11849},
 {running_applications,
    [{rabbitmq_management,"RabbitMQ Management Console","3.6.1"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.6.1"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.1"},
      {webmachine,"webmachine","1.10.3"},
      {amqp_client,"RabbitMQ AMQP Client","3.6.1"},
      {mochiweb,"MochiMedia Web Server","2.13.0"},
      {syntax_tools,"Syntax tools","1.7"},
      {ssl,"Erlang/OTP SSL application","7.3"},
      {public_key,"Public key infrastructure","1.1.1"},
      {asn1,"The Erlang ASN1 compiler version 4.0.2","4.0.2"},
      {crypto,"CRYPTO","3.6.3"},
      {compiler,"ERTS  CXC 138 10","6.0.3"},
      {inets,"INETS  CXC 138 49","6.2"},
      {rabbit,"RabbitMQ","3.6.1"},
      {mnesia,"MNESIA  CXC 138 12","4.13.3"},
      {rabbit_common,[],"3.6.1"},
      {xmerl,"XML parser","1.3.10"},
      {os_mon,"CPO  CXC 138 46","2.4"},
      {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,64111264},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,2808},
      {queue_procs,2808},
      {queue_slave_procs,0},
      {plugins,367288},
      {other_proc,19041296},
      {mnesia,61720},
      {mgmt_db,158696},
      {msg_index,47120},
      {other_ets,1372440},
      {binary,128216},
      {code,27368230},
      {atom,992409},
      {other_system,14568233}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,6556241100},
 {disk_free_limit,50000000},
 {disk_free,37431123968},
 {file_descriptors,
    [{total_limit,65435},
      {total_used,2},
      {sockets_limit,58889},
      {sockets_used,0}]},
 {processes,[{limit,1048576},{used,204}]},
 {run_queue,0},
 {uptime,412681},
 {kernel,{net_ticktime,60}}]

  关闭服务:

[root@iZ25e3bt9a6Z sbin]# ./rabbitmqctl stop
Stopping and halting node rabbit@iZ25e3bt9a6Z ...

  4. 配置网页插件

  首先创建目录,否则可能报错:

mkdir /etc/rabbitmq


  然后启用插件:

./rabbitmq-plugins enable rabbitmq_management

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

  默认用户guest 密码guest

  5. 远程访问配置

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

  添加用户:rabbitmqctl add_user hxb hxb

  添加权限:rabbitmqctl set_permissions -p "/" hxb ".*" ".*" ".*"

      修改用户角色rabbitmqctl set_user_tags hxb administrator

  然后就可以远程访问了,然后可直接配置用户权限等信息。

  

  6. rabbitmq常用命令

  add_user        <UserName> <Password>

  delete_user    <UserName>

  change_password <UserName> <NewPassword>

  list_users

  add_vhost    <VHostPath>

  delete_vhost <VHostPath>

  list_vhostsset_permissions  [-p <VHostPath>] <UserName> <Regexp> <Regexp> <Regexp>

  clear_permissions [-p <VHostPath>] <UserName>

  list_permissions  [-p <VHostPath>]

  list_user_permissions <UserName>

  list_queues    [-p <VHostPath>] [<QueueInfoItem> ...]

  list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...]

  list_bindings  [-p <VHostPath>]

  list_connections [<ConnectionInfoItem> ...]

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326896025&siteId=291194637