--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl-opt=enable-weak-ssl-ciphers

http_stub_status_module

location /ngx_status { stub_status on; access_log off; }

下载

wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.3.tar.gz
tar xvf zabbix-5.0.3.tar.gz
cd zabbix-5.0.3/

创建帐号

必须使用zabbix用户, 即使root帐号运行,也会自动切换至zabbix用户

For all of the Zabbix daemon processes, an unprivileged user is required. If a Zabbix daemon is started from an unprivileged user account, it will run as that user.

However, if a daemon is started from a 'root' account, it will switch to a 'zabbix' user account, which must be present. To create such a user account (in its own group, “zabbix”),

on a RedHat-based system, run:

groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

on a Debian-based system, run:

addgroup --system --quiet zabbix
adduser --quiet --system --disabled-login --ingroup zabbix --home /var/lib/zabbix --no-create-home zabbix

简单粗暴的方式是:

groupadd zabbix
useradd -g zabbix zabbix
为什么不给帐号分配文件夹?

Zabbix processes do not need a home directory, which is why we do not recommend creating it. However, if you are using some functionality that requires it (e. g. store MySQL credentials in $HOME/.my.cnf) you are free to create it using the following commands.

zabbix进程不需要home文件夹,如果个别功能需要,比如mysql登录认证配置, 你可以用以下命令创建:

On RedHat-based systems, run:

mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
chown zabbix:zabbix /usr/lib/zabbix

On Debian-based systems, run:

mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
chown zabbix:zabbix /var/lib/zabbix

创建服务端的MySQL数据库

注意编码,必须这个

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
quit;
mysql --database=zabbix -uroot -p < database/mysql/schema.sql
mysql --database=zabbix -uroot -p < database/mysql/images.sql
mysql --database=zabbix -uroot -p < database/mysql/data.sql

# 配置源码项目

分为 server服务,proxy代理,agent客户, 三部分

服务端必须指定唯一一种数据库类型(MySQL, PostgreSQL), 而代理端是否数据库数据库,则视服务端的情况而定

帮助
    ./configure --help

该系统同时是服务端和代理端, 则执行:

To configure the sources for a Zabbix server and agent, you may run something like:

    ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

该系统是服务端且PostgreSQL数据库, 则执行:

To configure the sources for a Zabbix server (with PostgreSQL etc.), you may run:

    ./configure --enable-server --with-postgresql --with-net-snmp

该系统是代理端且SQLite数据库, 则执行:

To configure the sources for a Zabbix proxy (with SQLite etc.), you may run:

    ./configure --prefix=/usr --enable-proxy --with-net-snmp --with-sqlite3 --with-ssh2

该系统是客户端, 则执行:

To configure the sources for a Zabbix agent, you may run:

    ./configure --enable-agent 

该系统是新版Go语言实现的客户端, 则执行: or, Zabbix agent 2:

    ./configure --enable-agent2

其他注意点:

 - Command-line utilities zabbix_get and zabbix_sender are compiled if --enable-agent option is used.
 - 编译参数 --enable-agent 启用命令行工具 zabbix_get 和 zabbix_sender

 - --with-libcurl and --with-libxml2 configuration options are required for virtual machine monitoring; --with-libcurl is also required for SMTP authentication and web.page.* Zabbix agent items. Note that cURL 7.20.0 or higher is required with the --with-libcurl configuration option.
 - 虚拟机监控, 需要编译参数 --with-libcurl 和--with-libxml2
 - SMTP服务认证, 需要编译参数 --with-libcurl 且cURL版本至少7.20.0
 

 -  Zabbix always compiles with the PCRE library (since version 3.4.0); installing it is not optional. --with-libpcre=[DIR] only allows pointing to a specific base install directory, instead of searching through a number of common places for the libpcre files.
 - 编译时总是依赖PCRE正则表达函数库, 默认使用公共的动态库, 可手动配置目录, 编译参数 --with-libpcre=[DIR]

 - You may use the --enable-static flag to statically link libraries. If you plan to distribute compiled binaries among different servers, you must use this flag to make these binaries work without required libraries. Note that --enable-static does not work in Solaris.
 - 编译参数 --enable-static 启用静态编译, 不依赖动态库, 方便克隆部署至其他机器

 - Using --enable-static option is not recommended when building server. In order to build the server statically you must have a static version of every external library needed. There is no strict check for that in configure script.
 - 编译参数 --enable-static 启用静态编译, 不推荐用于编译服务端, 因为依赖检查脚本还不完善

 - Add optional path to the MySQL configuration file --with-mysql=/<path_to_the_file>/mysql_config to select the desired MySQL client library when there is a need to use one that is not located in the default location. It is useful when there are several versions of MySQL installed or MariaDB installed alongside MySQL on the same system.
 - 如果系统安装不同的数据库版本,比如MySQL和MariaDB共存, 编译参数 --with-mysql=/<path_to_the_file>/mysql_config 手动指定mysql客户端程序的目录

 - Use --with-oracle flag to specify location of the OCI API.
 - 编译参数 --with-oracle 启用OCI接口

 - Go version 1.13 or later is required for compiling Zabbix agent 2. See golang.org for installation instructions.
 - 新版Go语言实现的客户端, Go版本至少1.13

如果./configure命令因为缺少动态库或其他原因而失败, 请查看错误日志config.log;比如缺少libssl, 则错误信息会是:

If ./configure fails due to missing libraries or some other circumstance, please see the config.log file for more details on the error. For example, if libssl is missing, the immediate error message may be misleading:

checking for main in -lmysqlclient... no
configure: error: Not found mysqlclient library
While config.log has a more detailed description:

/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto

./configure --help
`configure' configures Zabbix 5.0.3 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
-h, --help display this help and exit

  --help=short        display options specific to this package
  --help=recursive    display the short help of all the included packages

-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages

  --cache-file=FILE   cache test results in FILE [disabled]

-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files

  --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX

                      [/usr/local]

--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX

                      [PREFIX]

By default, `make install' will install all the files in
/usr/local/bin', /usr/local/lib' etc. You can specify
an installation prefix other than /usr/local' using --prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/zabbix]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]

Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names

System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]

Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-dependency-tracking

                      do not reject slow dependency extractors

--disable-dependency-tracking

                      speeds up one-time build

--disable-largefile omit support for large files
--enable-static Build statically linked binaries
--enable-static-libs Build statically linked binaries with selected libs from default folders
--enable-server Turn on build of Zabbix server
--enable-proxy Turn on build of Zabbix proxy
--enable-agent Turn on build of Zabbix agent and client utilities
--enable-agent2 Turn on build of Zabbix agent 2
--enable-java Turn on build of Zabbix Java gateway
--enable-ipv6 Turn on support of IPv6

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-mysql[=ARG] use MySQL client library [default=no], optionally

                      specify path to mysql_config

--with-oracle[=ARG] use Oracle OCI API from given Oracle home

                      (ARG=path); use existing ORACLE_HOME (ARG=yes);
                      disable Oracle OCI support (ARG=no)

--with-oracle-include[=DIR]

                      use Oracle OCI API headers from given path

--with-oracle-lib[=DIR] use Oracle OCI API libraries from given path
--with-postgresql[=ARG] use PostgreSQL library [default=no], optionally

                      specify path to pg_config

--with-sqlite3[=ARG] use SQLite 3 library [default=no], optionally

                      specify the prefix for sqlite3 library

If you want to use XML library:
--with-libxml2[=ARG] use libxml2 client library [default=no], see

                      PKG_CONFIG_PATH environment variable to specify .pc
                      file location

If you want to use unixODBC library:
--with-unixodbc[=ARG] use ODBC driver against unixODBC package

                      [default=no], optionally specify full path to
                      odbc_config binary.

If you want to use Net-SNMP library:
--with-net-snmp[=ARG] use Net-SNMP package [default=no], optionally

                      specify path to net-snmp-config

If you want to use SSH2 based checks:
--with-ssh2[=DIR] use SSH2 package [default=no], DIR is the SSH2

                      library install directory.

If you want to use SSH based checks:
--with-ssh[=DIR] use SSH package [default=no], DIR is the SSH library

                      install directory.

If you want to check IPMI devices:
--with-openipmi[=DIR] Include OPENIPMI support [default=no]. DIR is the

                      OPENIPMI base install directory, default is to
                      search through a number of common places for the
                      OPENIPMI files.

If you want to specify zlib installation directories:
--with-zlib[=DIR] use zlib from given base install directory (DIR),

                      default is to search through a number of common
                      places for the zlib files.

--with-zlib-include=DIR use zlib include headers from given path.
--with-zlib-lib=DIR use zlib libraries from given path.

If you want to specify pthread installation directories:
--with-libpthread[=DIR] use libpthread from given base install directory

                      (DIR), default is to search through a number of
                      common places for the libpthread files.

--with-libpthread-include[=DIR]

                      use libpthread include headers from given path.

--with-libpthread-lib[=DIR]

                      use libpthread libraries from given path.

If you want to specify libevent installation directories:
--with-libevent[=DIR] use libevent from given base install directory

                      (DIR), default is to search through a number of
                      common places for the libevent files.

--with-libevent-include[=DIR]

                      use libevent include headers from given path.

--with-libevent-lib[=DIR]

                      use libevent libraries from given path.

If you want to use encryption provided by GnuTLS library:
--with-gnutls[=DIR] use GnuTLS package [default=no], DIR is the

                      libgnutls install directory.

If you want to use encryption provided by OpenSSL library:
--with-openssl[=DIR] use OpenSSL package [default=no], DIR is the libssl

                      and libcrypto install directory.

If you want to check LDAP servers:
--with-ldap[=DIR] Include LDAP support [default=no]. DIR is the LDAP

                      base install directory, default is to search through
                      a number of common places for the LDAP files.

If you want to use cURL library:
--with-libcurl[=DIR] use cURL package [default=no], optionally specify

                      path to curl-config

If you want to specify libpcre installation directories:
--with-libpcre[=DIR] use libpcre from given base install directory (DIR),

                      default is to search through a number of common
                      places for the libpcre files.

--with-libpcre-include[=DIR]

                      use libpcre include headers from given path.

--with-libpcre-lib[=DIR]

                      use libpcre libraries from given path.

If you want to specify iconv installation directories:
--with-iconv[=DIR] use iconv from given base install directory (DIR),

                      default is to search through a number of common
                      places for the iconv files.

--with-iconv-include[=DIR]

                      use iconv include headers from given path.

--with-iconv-lib[=DIR] use iconv libraries from given path.

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a

          nonstandard directory <lib dir>

LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if

          you have headers in a nonstandard directory <include dir>

CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH

          directories to add to pkg-config's search path

PKG_CONFIG_LIBDIR

          path overriding pkg-config's built-in search path

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.


这里, 我们的服务端配置参数是:

此处不使用SNMP, 且注意mysql_config程序的目录,

./configure --prefix=/usr/local/zabbix5 --enable-server --enable-agent --with-mysql=/usr/local/mariadb/bin/mysql_config --enable-ipv6 --with-libcurl --with-libxml2 --with-libpcre --with-zlib --with-iconv

./configure --prefix=/usr/local/zabbix5 --enable-agent


# 编译

如果源码来自Git仓库, 需要执行命令`make dbschema`

make install


后台二进制程序的默认安装目录:

    服务端(zabbix_server, zabbix_agentd, zabbix_proxy) 在 /usr/local/sbin

    客户端(zabbix_get, zabbix_sender) 在 /usr/local/bin.

编译参数 --prefix=/usr/local/zabbix5 可以指定编译目录, 此时后台程序位于相对目录 <prefix>/sbin, 工具程序位于 <prefix>/bin. 而man页面位于 <prefix>/share

# 编辑配置文件

服务端 /usr/local/etc/zabbix_server.conf
    主要是数据库名和密码

代理端服务 /usr/local/etc/zabbix_agentd.conf
    主要是IP地址白名单, 非白名单IP会被拒绝连接

代理端 /usr/local/etc/zabbix_proxy.conf
    指定代理端服务进程的IP地址和主机名; 如果用到数据库,也要配置数据库名和密码;SQLite只要文件完整路径,不需要账号密码

# 启动程序

分别至少占用共享内存36MB,2MB

10051端口

zabbix_server

10050端口

zabbix_agentd

代理客户端

zabbix_proxy


如果源码来自Git仓库, 需要执行命令`make dbschema`

# 安装web端(报表)

假设网站根目录htdocs位于 /home/wwwroot/

mkdir <htdocs>/zabbix
cd zabbix-5.0.3/ui
cp -a . <htdocs>/zabbix

##### 多语言

如果代码来自Git仓库, 且需要安装英语以外的语言包, 执行命令`locale/make_mo.sh`, 这依赖于gettext包的msgfmt工具

##### 初始化web端

- 给目录 conf/ 写入权限

 - 访问地址 http://<server_ip_or_name>/zabbix 安装网页引导操作即可;

 - 默认帐号Admin 密码是zabbix

依赖:

PHP环境 7.2.0
配置项:
memory_limit = 128M
post_max_size = 16MB
upload_max_filesize = 2MB
max_execution_time = 300
max_input_time = 300
session.auto_start = 0
mbstring.func_overload = 0
其余PHP扩展:
bcmath,mbstring,sockets,libxml,xmlwriter,xmlreader,ctype,session,gettext

gd: PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).

MySQL, Oracle, PostgreSQL.所需扩展三选一:mysql, oci8, pgsql


# 安装Java Gateway网关

JavaGateway用来监控JMX applications, 代理客户端 不需要安装数据库


`./configure --enable-java --prefix=自定义目录/usr/local/javaGateway`

To compile and package Java gateway into a JAR file, run make. Note that for this step you will need `javac` and `jar` executables in your path.

`make`

此时目录 src/zabbix_java/bin 有一个文件 zabbix-java-gateway-$VERSION.jar

确保有权限执行命令`make install`

`make install`

1. 创建直连交换机 : delay_exchange
2. 创建延迟队列: delay_queue, 延迟绑定键: delay_key

作用: 存放延迟消费的消息, 即自动过期但还没过期的消息

自带的x-message-ttl参数,使得整个队列的消息过期时间相同, 但是为了灵活设置, 改用其他参数方式实现:

参数:

{"x-dead-letter-exchange", "delay_exchange"},
{"x-dead-letter-routing-key", "work_key"}

x-dead-letter-exchange 消息过期后,消息要进入的交换机,俗称死信交换机,

Optional name of an exchange to which messages will be republished if they are rejected or expire.

x-dead-letter-routing-key 消息过期后,进入死信交换机的routing-key, 再根据这个key将消息放入不同的队列

Optional replacement routing key to use when a message is dead-lettered. If this is not set, the message's original routing key will be used.
3. 绑定 直连交换机delay_exchange 与 延迟队列delay_queue 与 延迟delay_key

把新消息都投入到延迟队列内, 消息一过期就自动按照 消息参数 转发到下一流程

4. 创建 临时工作队列: next_queue队列名随机, 工作绑定键: work_key

存放要立即消费执行的任务

5. 绑定 直连交换机delay_exchange 与 临时工作队列next_queue 与 工作绑定键work_key

把过期的消息, 即延迟任务 都存入工作队列

6. 消费掉 临时工作队列 next_queue


投递任务

<?php
require_once __DIR__ . '/vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

// 发送
$config = [
    'host' => '',
    'port' => 5672,
    'user' => '',
    'password' => '',
    'vhost' => '/',

    'locale' => 'en_US',
];
$connection = new AMQPStreamConnection($config['host'], $config['port'], $config['user'], $config['password'], $config['vhost'],
    false, 'AMQPLAIN', null, $config['locale'], 3.0, 3.0, null,
    true, 60, 0, null);
$channel = $connection->channel();

$exchange = 'delay_exchange';
$sourceRoutingKey = 'delay_key';


// 直连交换机(direct):  对路由绑定键routing key进行精确匹配,从而确定消息该分发到哪个队列
// 创建 持久化的交换机
$channel->exchange_declare($exchange, 'direct', false, true, false);

$msg = new AMQPMessage(igbinary_serialize(microtime(true)), [
    'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT,  // 消息持久化2, 默认不持久化1
    'expiration' => 3000 // 3秒后触发
]);
$channel->basic_publish($msg, $exchange, $sourceRoutingKey); // 消息发给交换机, 此时交换机缓存中 有大量消息没有被转发给 队列

echo " [x] Sent 'Hello World!'\n";

$channel->close();
$connection->close();

延迟消费任务

<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

// 接收
$config = [
    'host' => '',
    'port' => 5672,
    'user' => '',
    'password'=> '',
    'vhost' => '/',
    'locale' => 'en_US',
];
$connection = new AMQPStreamConnection($config['host'], $config['port'], $config['user'],  $config['password'], $config['vhost'],
    false, 'AMQPLAIN', null, $config['locale'], 3.0, 3.0, null,
    true, 60, 0, null);

$channel = $connection->channel();

$exchange = 'delay_exchange';

$sourceQueue = 'delay_queue';
$sourceRoutingKey = 'delay_key';

$nextRoutingKey = 'work_key';
$nextQueue = 'tmpQueue';

$channel->exchange_declare($exchange, 'direct', false, true, false);

// 延迟队列
$arguments = new \PhpAmqpLib\Wire\AMQPTable();
$arguments->set("x-dead-letter-exchange", $exchange);
$arguments->set("x-dead-letter-routing-key", $nextRoutingKey);
$channel->queue_declare($sourceQueue, false, true, false, false, false, $arguments);
$channel->queue_bind($sourceQueue, $exchange, $sourceRoutingKey); // 把交换机的一手数据传到该延迟队列

// 工作队列
list($nextQueue, ,) = $channel->queue_declare("", false, true, false, false);
$channel->queue_bind($nextQueue, $exchange, $nextRoutingKey); // 把交换机的过期数据传到该临时工作队列,消费之



echo " [*] Waiting for messages. To exit press CTRL+C\n";
$callback = function (AMQPMessage $msg) {
    $tmp = json_encode(igbinary_unserialize($msg->body),JSON_UNESCAPED_UNICODE);
    echo 'time:', microtime(true);
    echo ' [x] Received ', $tmp,
    ', json size:', strlen($tmp),
    ', igbianry size:',$msg->body_size, "\n";

    //因为消息是持久化的,所以要求确认消息,消费者发回ack
    // 如果不ack,则该socket连接永远也不会接收到新的msg!!服务端误以为你挂起了 Ready->Unacked->[Ready或acked]
    echo 'delivery_tag:', $msg->delivery_info['delivery_tag'],PHP_EOL;
    $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
};

$channel->basic_qos(null, 1, null); // 基础流量控制, 公平调度, 默认不控制

// 消费端的 no_ack权限 改为 必须false才能使用ACk机制!!!
$channel->basic_consume($nextQueue, '', false, false, false, false, $callback);

while ($channel->is_consuming()) {
    $channel->wait();
}

$channel->close();
$connection->close();

yum -y install gcc glibc-devel make ncurses-devel openssl-devel autoconf unixODBC unixODBC-devel socat

wget http://erlang.org/download/otp_src_23.0.tar.gz

tar xvf otp_src_23.0.tar.gz

cd otp_src_23.0/

禁用java编译器,用C编译器来编译erlang

./configure --prefix=/usr/local/erlang_23.0 --without-javac

其他编译选项,未尝试
--with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe

make

make install

安装rabbitmq

wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.7/rabbitmq-server-generic-unix-3.8.7.tar.xz

tar xvJf rabbitmq-server-generic-unix-3.8.7.tar.xz

mv rabbitmq_server-3.8.7/ /usr/local/rabbitmq_server-3.8.7

vi /etc/profile.d/rabbitmq.sh

# erlang安装目录
export ERLANG_PATH=$PATH:/usr/local/erlang_23.0/bin

# rabbitmq安装目录
export RABBITMQ_PATH=$PATH:/usr/local/rabbitmq_server-3.8.7/sbin

export PATH=$PATH:$ERLANG_PATH:$RABBITMQ_PATH

source /etc/profile

配置文件

man rabbitmq-server

vi /usr/local/rabbitmq_server-3.8.7/etc/rabbitmq/rabbitmq-env.conf

RABBITMQ_LOG_BASE=/rabbitmqData/log
RABBITMQ_MNESIA_BASE=/rabbitmqData/mnesia
RABBITMQ_NODENAME=ZDB
RABBITMQ_NODE_IP_ADDRESS=0.0.0.0
RABBITMQ_NODE_PORT=5672

# 可选,使用旧版本的配置文件格式, 这里使用新版的
# RABBITMQ_CONFIG_FILE=/rabbitmqData/rabbitmq.oldFormat.config

新版本的配置文件, 应该保存于 /usr/local/rabbitmq_server-3.8.7/etc/rabbitmq/rabbitmq.conf

新版配置文件的模板来源于 https://github.com/rabbitmq/rabbitmq-server/edit/master/docs/rabbitmq.conf.example

mkdir -p /rabbitmqData/
chmod -R 0777 /rabbitmqData/

启动一下:

# 前台启动服务
rabbitmq-server
# 后台启动服务
rabbitmq-server -detached

#开启面板,默认帐号密码 guest guest, disable为关闭
rabbitmq-plugins enable rabbitmq_management

面板所需的防火墙,打开15672端口

firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --reload #重启防火墙
RabbitMQ 默认端口号
netstat -natp | grep epmd
netstat -natp | grep beam.smp

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)
添加用户
 rabbitmqctl add_user zhuangdebiao 123456
分配角色
 rabbitmqctl set_user_tags zhuangdebiao administrator 
设置用户权限
rabbitmqctl set_permissions -p "/" zhuangdebiao ".*" ".*" ".*"
查看用户角色和权限
rabbitmqctl list_users
删除一个用户
rabbitmqctl delete_user Username
修改用户的密码
rabbitmqctl change_password Username Newpassword
命令在/usrlocal/rabbitmq/sbin下

启动: rabbitmq-server -detached

停止: rabbitmqctl stop

查看状态: rabbitmqctl status

插件管理:

插件列表: rabbitmq-plugins list

启动插件: rabbitmq-plugins enable XXX (XXX为插件名)

停用插件: rabbitmq-plugins disable XXX

用户管理:

添加用户: rabbitmqctl add_user username password

删除用户: rabbitmqctl delete_user username

修改密码: rabbitmqctl change_password username newpassword

设置用户角色: rabbitmqctl set_user_tags username tag

列出用户: rabbitmqctl list_users

权限管理:

列出所有用户权限: rabbitmqctl list_permissions

查看制定用户权限: rabbitmqctl list_user_permissions username

清除用户权限: rabbitmqctl clear_permissions [-p vhostpath] username

设置用户权限: rabbitmqctl set_permissions [-p vhostpath] username conf write read

                      conf: 一个正则匹配哪些资源能被该用户访问

                      write:一个正则匹配哪些资源能被该用户写入

                      read:一个正则匹配哪些资源能被该用户读取
列出网络连接
rabbitmqctl list_connections
列出通道
rabbitmqctl list_channels
列出交换机
rabbitmqctl list_exchanges
交换机与队列的绑定关系
rabbitmqctl list_bindings
列出所有的队列
rabbitmqctl list_queues
配置文件目录, 通过env可以修改
Platform    Default Configuration File Directory    Example Configuration File Paths

Generic binary package    $RABBITMQ_HOME/etc/rabbitmq/    $RABBITMQ_HOME/etc/rabbitmq/rabbitmq.conf, $RABBITMQ_HOME/etc/rabbitmq/advanced.config

Debian and Ubuntu    /etc/rabbitmq/    /etc/rabbitmq/rabbitmq.conf, /etc/rabbitmq/advanced.config

RPM-based Linux    /etc/rabbitmq/    /etc/rabbitmq/rabbitmq.conf, /etc/rabbitmq/advanced.config

Windows    %APPDATA%\RabbitMQ\    %APPDATA%\RabbitMQ\rabbitmq.conf, %APPDATA%\RabbitMQ\advanced.config

MacOS Homebrew Formula    ${install_prefix}/etc/rabbitmq/, and the Homebrew cellar prefix is usually /usr/local    ${install_prefix}/etc/rabbitmq/rabbitmq.conf, ${install_prefix}/etc/rabbitmq/advanced.config

vi/etc/profile.d/java.sh

JAVA_HOME=/root/jdk1.8.0_251
PATH=$JAVA_HOME/bin:/root/apache-maven-3.6.3/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

source /etc/profile