单节点安装
[root@MiWiFi-R3L-srv ~]# cd /home/ninesun/Documents/ [root@MiWiFi-R3L-srv Documents]# ll total 26340 -rwxrw-rw-. 1 ninesun ninesun 18345424 Mar 5 2020 erlang-18.3-1.el7.centos.x86_64.rpm -rwxrw-rw-. 1 ninesun ninesun 1563272 Mar 5 2020 haproxy-1.6.5.tar.gz -rwxrw-rw-. 1 ninesun ninesun 330361 Mar 5 2020 keepalived-1.2.18.tar.gz -rwxrw-rw-. 1 ninesun ninesun 32019 Mar 5 2020 rabbitmq_delayed_message_exchange-0.0.1.ez -rwxrw-rw-. 1 ninesun ninesun 5520417 Mar 5 2020 rabbitmq-server-3.6.5-1.noarch.rpm -rwxrw-rw-. 1 ninesun ninesun 808698 Mar 5 2020 RabbitMQ消息服务用户手册.docx -rwxrw-rw-. 1 ninesun ninesun 361448 Mar 5 2020 socat-1.7.3.2-1.1.el7.x86_64.rpm [root@MiWiFi-R3L-srv Documents]# rpm -ivh erlang-18.3-1.el7.centos.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:erlang-18.3-1.el7.centos ################################# [100%] [root@MiWiFi-R3L-srv Documents]# rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm warning: rabbitmq-server-3.6.5-1.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY error: Failed dependencies: socat is needed by rabbitmq-server-3.6.5-1.noarch [root@MiWiFi-R3L-srv Documents]# rpm -ivh socat-1.7.3.2-1.1.el7.x86_64.rpm warning: socat-1.7.3.2-1.1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 87e360b8: NOKEY Preparing... ################################# [100%] Updating / installing... 1:socat-1.7.3.2-1.1.el7 ################################# [100%] [root@MiWiFi-R3L-srv Documents]# rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm warning: rabbitmq-server-3.6.5-1.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY Preparing... ################################# [100%] Updating / installing... 1:rabbitmq-server-3.6.5-1 ################################# [100%] [root@MiWiFi-R3L-srv Documents]# pwd /home/ninesun/Documents [root@MiWiFi-R3L-srv ebin]# rabbitmq-server start & [2] 4115 [root@MiWiFi-R3L-srv ebin]# ERROR: node with name "rabbit" already running on "MiWiFi-R3L-srv" ^C [2]+ Exit 1 rabbitmq-server start [root@MiWiFi-R3L-srv ebin]# ps -ef|grep rabbit root 3873 3247 0 08:52 pts/1 00:00:00 /bin/sh /sbin/rabbitmq-server start root 3883 3873 0 08:52 pts/1 00:00:00 su rabbitmq -s /bin/sh -c /usr/lib/rabbitmq/bin/rabbitmq-server 'start' rabbitmq 3884 3883 0 08:52 ? 00:00:00 /bin/sh -e /usr/lib/rabbitmq/bin/rabbitmq-server start rabbitmq 3957 1 0 08:52 ? 00:00:00 /usr/lib64/erlang/erts-7.3/bin/epmd -daemon rabbitmq 3972 3884 1 08:52 ? 00:00:02 /usr/lib64/erlang/erts-7.3/bin/beam -W w -A 64 -P 1048576 -t 5000000 -stbt db -K true -B i -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.5/ebin -noshell -noinput -s rabbit boot -sname rabbit@MiWiFi-R3L-srv -boot start_sasl -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/rabbit@MiWiFi-R3L-srv.log"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/rabbit@MiWiFi-R3L-srv-sasl.log"} -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.5/plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/rabbit@MiWiFi-R3L-srv-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesia/rabbit@MiWiFi-R3L-srv" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672 start rabbitmq 4066 3972 0 08:52 ? 00:00:00 inet_gethost 4 rabbitmq 4067 4066 0 08:53 ? 00:00:00 inet_gethost 4 root 4234 3247 0 08:55 pts/1 00:00:00 grep --color=auto rabbit [root@MiWiFi-R3L-srv ebin]# [root@MiWiFi-R3L-srv ebin]# [root@MiWiFi-R3L-srv ebin]# [root@MiWiFi-R3L-srv ebin]# lsof -i:5672 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME beam 3972 rabbitmq 48u IPv6 60895 0t0 TCP *:amqp (LISTEN) [root@MiWiFi-R3L-srv ebin]# q
rabbmit 的插件,dashboard就属于插件之一
[root@MiWiFi-R3L-srv ebin]# rabbitmq-plugins list Configured: E = explicitly enabled; e = implicitly enabled | Status: * = running on rabbit@MiWiFi-R3L-srv |/ [ ] amqp_client 3.6.5 [ ] cowboy 1.0.3 [ ] cowlib 1.0.1 [ ] mochiweb 2.13.1 [ ] rabbitmq_amqp1_0 3.6.5 [ ] rabbitmq_auth_backend_ldap 3.6.5 [ ] rabbitmq_auth_mechanism_ssl 3.6.5 [ ] rabbitmq_consistent_hash_exchange 3.6.5 [ ] rabbitmq_event_exchange 3.6.5 [ ] rabbitmq_federation 3.6.5 [ ] rabbitmq_federation_management 3.6.5 [ ] rabbitmq_jms_topic_exchange 3.6.5 [ ] rabbitmq_management 3.6.5 [ ] rabbitmq_management_agent 3.6.5 [ ] rabbitmq_management_visualiser 3.6.5 [ ] rabbitmq_mqtt 3.6.5 [ ] rabbitmq_recent_history_exchange 1.2.1 [ ] rabbitmq_sharding 0.1.0 [ ] rabbitmq_shovel 3.6.5 [ ] rabbitmq_shovel_management 3.6.5 [ ] rabbitmq_stomp 3.6.5 [ ] rabbitmq_top 3.6.5 [ ] rabbitmq_tracing 3.6.5 [ ] rabbitmq_trust_store 3.6.5 [ ] rabbitmq_web_dispatch 3.6.5 [ ] rabbitmq_web_stomp 3.6.5 [ ] rabbitmq_web_stomp_examples 3.6.5 [ ] sockjs 0.3.4 [ ] webmachine 1.10.3 [root@MiWiFi-R3L-srv ebin]# 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@MiWiFi-R3L-srv... started 6 plugins.
集群安装
haproxy
参数优化
创建如下配置文件位于:/etc/rabbitmq目录下(这个目录需要自己创建) 环境变量配置文件:rabbitmq-env.conf 配置信息配置文件:rabbitmq.config(可以不创建和配置,修改) rabbitmq-env.conf配置文件: ---------------------------------------关键参数配置------------------------------------------- RABBITMQ_NODE_IP_ADDRESS=本机IP地址 RABBITMQ_NODE_PORT=5672 RABBITMQ_LOG_BASE=/var/lib/rabbitmq/log RABBITMQ_MNESIA_BASE=/var/lib/rabbitmq/mnesia 配置参考参数如下: RABBITMQ_NODENAME=FZTEC-240088 节点名称 RABBITMQ_NODE_IP_ADDRESS=127.0.0.1 监听IP RABBITMQ_NODE_PORT=5672 监听端口 RABBITMQ_LOG_BASE=/data/rabbitmq/log 日志目录 RABBITMQ_PLUGINS_DIR=/data/rabbitmq/plugins 插件目录 RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia 后端存储目录 更详细的配置参见: http://www.rabbitmq.com/configure.html#configuration-file 配置文件信息修改: /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.4/ebin/rabbit.app和rabbitmq.config配置文件配置任意一个即可,我们进行配置如下: vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.4/ebin/rabbit.app -------------------------------------关键参数配置---------------------------------------- tcp_listerners 设置rabbimq的监听端口,默认为[5672]。 disk_free_limit 磁盘低水位线,若磁盘容量低于指定值则停止接收数据,默认值为{mem_relative, 1.0},即与内存相关联1:1,也可定制为多少byte. vm_memory_high_watermark,设置内存低水位线,若低于该水位线,则开启流控机制,默认值是0.4,即内存总量的40%。 hipe_compile 将部分rabbimq代码用High Performance Erlang compiler编译,可提升性能,该参数是实验性,若出现erlang vm segfaults,应关掉。 force_fine_statistics, 该参数属于rabbimq_management,若为true则进行精细化的统计,但会影响性能
集群恢复与故障转移
offline master节点down 无法启动时,推选新的master
极端情况: