centos install rabbitmq
安装rabbitmq 需要环境上有erlang,没有安装的可以参照下面的内容进行安装:
https://www.erlang-solutions.com/resources/download.html
installation using repository
1. adding repository entry
to add erlang solutions repository (including our public key for verifying signed package) to your system, call the following commands:
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm rpm -uvh erlang-solutions-1.0-1.noarch.rpm
alternatively: adding the repository entry manually
rpm packages are signed. to add erlang solutions key, execute command:
rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
add the following lines to some file in /etc/yum.repos.d/
:
[erlang-solutions] name=centos $releasever - $basearch - erlang solutions baseurl=https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch gpgcheck=1 gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc enabled=1
note that rpm forge and epel must be also added to repos.
我使用的是第一种方式:
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm rpm -uvh erlang-solutions-1.0-1.noarch.rpm
我是最小安装centos,安装erlang 时遇到了依赖包,通过下面命令解决:
首先为yum添加epel源:
yum install epel-release
再安装wxpyrhon:
yum install wxpython
安装完依赖库以后,安装erlang
安装完erlang后就可以安装rabbitmq,先下载rpm:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
下载完成后安装:
yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm
设置rabbitmq服务自启动
chkconfig rabbitmq-server on
启动rabbbitmq服务
service rabbitmq-server start
查看rabbbitmq服务状态
service rabbitmq-server status
启用rabbitmq监控插件
rabbitmq-plugins enable rabbitmq_management
rabbitmq用户管理
添加用户(用户名root,密码admin)
rabbitmqctl add_user admin admin
设置用户角色(设置admin用户为管理员角色)
rabbitmqctl set_user_tags admin administrator
设置用户权限(设置admin用户配置、写、读的权限)
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
删除用户(删除guest用户)
rabbitmqctl delete_user guest
注意:rabbitmq从3.3.0开始禁止使用guest/guest权限通过除localhost外的访问。
如果想使用guest/guest通过远程机器访问,需要在rabbitmq配置文件中(/etc/rabbitmq/rabbitmq.config)中设置loopback_users为[],按照下面步骤操作。
cd /var/log/rabbitmq/
vi rabbit@localhost.log
这里显示的是没有找到配置文件,我们可以自己创建这个文件
vi /etc/rabbitmq/rabbitmq.config
编辑内容如下:
[{rabbit, [{loopback_users, []}]}].
rabbitmq默认创建的用户guest,密码也是guest,这个用户默认只能是本机访问,localhost或者127.0.0.1,从外部访问需要添加上面的配置。
保存配置后重启服务:
service rabbitmq-server stop service rabbitmq-server start
从宿主机访问虚拟机中的rabbitmq: http://192.168.203.128:15672
注:实际使用当中遇到内存过高,造成系统coredump,找到了下面这篇文章
http://ju.outofmemory.cn/entry/186612