系统准备
centos6.5 与 centos7 都可以
###安装依赖文件
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget
安装 erlang 语言环境
下载编译安装
wget http://www.erlang.org/download/otp_src_20.2.tar.gz //下载erlang包
tar zxvf otp_src_20.2.tar.gz
cd otp_src_20.2
./configure --prefix=/usr/local/erlang
make && make install
配置环境变量
vi /etc/profile
添加
#set erlang environment
ERL_HOME=/usr/local/erlang
export ERL_HOME
PATH=$ERL_HOME/bin:$PATH
export PATH
加载环境变量
. /etc/profile
测试一下是否安装成功,在控制台输入命令erl
[root@iZ23tvs45ppZ ~]# erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V9.2 (abort with ^G)
1>
退出即可
安装rabbitmq
下载安装
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-generic-unix-3.6.15.tar.xz
xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz
tar -xvf rabbitmq-server-generic-unix-3.6.15.tar
mv rabbitmq_server-3.6.15 /mnt/rabbitmq
配置环境变量 vi /etc/profile
添加
#set rabbitmq environment
export PATH=$PATH:/mnt/rabbitmq/sbin
加载环境变量
. /etc/profile
启动服务
[root@iZ23tvs45ppZ rabbitmq]# rabbitmq-server -detached //启动rabbitmq,-detached代表后台守护进程方式启动。
Warning: PID file not written; -detached was passed.
查看状态
[root@iZ23tvs45ppZ rabbitmq]# rabbitmqctl status
Status of node rabbit@iZ23tvs45ppZ
[{pid,28318},
{running_applications,
[{rabbit,"RabbitMQ","3.6.15"},
{mnesia,"MNESIA CXC 138 12","4.15.2"},
{ranch,"Socket acceptor pool for TCP protocols.","1.3.2"},
{ssl,"Erlang/OTP SSL application","8.2.3"},
{public_key,"Public key infrastructure","1.5.2"},
{asn1,"The Erlang ASN1 compiler version 5.0.4","5.0.4"},
{os_mon,"CPO CXC 138 46","2.4.4"},
{rabbit_common,
...
相关命令
启动服务:rabbitmq-server -detached【 /usr/local/rabbitmq/sbin/rabbitmq-server -detached 】
查看状态:rabbitmqctl status【 /usr/local/rabbitmq/sbin/rabbitmqctl status 】
关闭服务:rabbitmqctl stop【 /usr/local/rabbitmq/sbin/rabbitmqctl stop 】
列出角色:rabbitmqctl list_users
设置最高内存占用:rabbitmqctl set_vm_memory_high_watermark 0.25 # 0.25表示25%,默认0.4
设置硬盘最小剩余:rabbitmqctl set_disk_free_limit 15G
配置网页插件
首先创建目录,否则可能报错:
[root@iZ23tvs45ppZ rabbitmq]# mkdir /etc/rabbitmq
然后启用插件:
[root@iZ23tvs45ppZ rabbitmq]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to rabbit@iZ23tvs45ppZ... started 6 plugins.
现在你在浏览器中输入服务器IP:15672 就可以看到RabbitMQ的WEB管理页面了,可是你没有账号密码,别急,继续下面的步骤。
配置访问账号密码和权限
默认网页是不允许访问的,需要增加一个用户修改一下权限,代码如下:
rabbitmqctl add_user test test //添加用户,后面两个参数分别是用户名和密码,我这都用superrd了。
rabbitmqctl set_permissions -p / test ".*" ".*" ".*" //添加权限
rabbitmqctl set_user_tags test administrator //修改用户角色
然后就可以远程访问了,然后可直接配置用户权限等信息。 登录:http://ip:15672 登录之后在admin里面把guest删除。 生成者和消费者访问端口:5672
至此,rabbitmq安装完成