Centos下Rabbitmq安装配置
Centos下Rabbitmq安装配置
因为rabbitmq是利用erlang编程语言开发的,所以首先我们得安装erlang虚拟机的支持,就像Java重新一样,首先得有JDK的支持。
1、Yum方法安装一、安装Erlang
# wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo
# yum -y install erlang
2、源码安装
# yum -y install gcc* make ncurses-devel libxslt xsltproc unzip nc xmlto
# wget http://www.erlang.org/download/otp_src_R16B01.tar.gz
# tar zxvf otp_src_R16B01.tar.gz
# ./configure --prefix=/usr/local/erlang_R16B01 --without-javac --with-ssl
# make && make install
# ln -s /usr/local/erlang/bin/erl /usr/bin/erl
# ln -s /usr/local/erlang/bin/escript /usr/bin/escript
# ln -s /usr/local/erlang/bin/erlc /usr/bin/erlc
1、Yum方法安装二、安装Rabbitmq
# rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
# yum install rabbitmq-server-3.1.5
2、源码安装
***下载免编译安装包,下载解压开封即用,可以下载任意自己想要的版本!
# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.1/rabbitmq-server-generic-unix-3.5.1.tar.gz
# tar zxf rabbitmq-server-generic-unix-3.5.1.tar.gz -C /data/
配置文件和初始化环境脚本配置指定在/data/rabbitmq_server-3.5.1/sbin目录下:三、配置
rabbitmq-env 环境初始化配置
rabbitmq-defaults 默认参数设置
rabbitmqctl 管理工具
rabbitmq-plugins 插件管理工具
rabbitmq-server rabbitmq服务启动脚本
rabbitmq-defaults配置:
SYS_PREFIX=${RABBITMQ_HOME}
ERL_DIR=/usr/bin/ //设置erl命令路径
CLEAN_BOOT_FILE=start_clean
SASL_BOOT_FILE=start_sasl
CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq //设置rabbitmq配置文件路径
LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq
MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia
ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins //允许插件列表配置文件
PLUGINS_DIR="${RABBITMQ_HOME}/plugins"
CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf
主要配置文件介绍: 1、enabled_plugins:设置允许的插件列表,格式如下:
[rabbitmq_jsonrpc_channel,
rabbitmq_management,
rabbitmq_management_visualiser,
rabbitmq_tracing].
2、rabbitmq.config:设置rabbitmq运行参数。结构为hash数组格式,如:
[
{mnesia, [{dump_log_write_threshold, 1000}]},
{rabbit, [{vm_memory_high_watermark, 0.4}]}
{rabbitmq_management,
[{listener, [{port, 55673},
{ip, "0.0.0.0"}
]}
]}
].
其中几个关键参数为:
tcp_listeners 设置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则进行精细化的统计,但会影响性能。
配置实栗如下:
[{auth_backends,[rabbit_auth_backend_internal]},
{auth_mechanisms,['PLAIN','AMQPLAIN']},
{backing_queue_module,rabbit_variable_queue},
{cluster_nodes,},
{collect_statistics,fine},
{collect_statistics_interval,5000},
{default_permissions,[<<".[i]">>,<<".[/i]">>,<<".*">>]},
{default_user,<<"guest">>},
{default_user_tags,[administrator]},
{default_vhost,<<"/">>},
{delegate_count,16},
{error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac.log"}},
{frame_max,131072},
{hipe_compile,false},
{included_applications,},
{msg_store_file_size_limit,16777216},
{msg_store_index_module,rabbit_msg_store_ets_index},
{queue_index_max_journal_entries,262144},
{sasl_error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac-sasl.log"}},
{server_properties,},
{ssl_listeners,},
{ssl_options,},
{tcp_listen_options,
[binary,
{packet,raw},
{reuseaddr,true},
{backlog,128},
{nodelay,true},
{exit_on_close,false}]},
{tcp_listeners,[5672]},
{trace_vhosts,[<<"/">>]},
{vm_memory_high_watermark,0.4}].
3、rabbitmq-env.conf rabbitmq环境参数配置:
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 4、启动
# /usr/local/rabbitmq/sbin/rabbitmq-server -detached
启用rabbitmq web管理插件四、插件管理
# ./rabbitmq-plugins enable rabbitmq_management
web管理端口默认端口是15672,访问地址为http://rabbitmq_host_ip:15672 默认有一个用户名字和密码都是guest [attach]1007[/attach] 列出所有插件
./rabbitmq-plugins list