原文链接:http://blog.csdn.net/yunfeng482/article/details/72853983
一、编译安装方式
1.依赖环境的安装-如果需要用编译安装erlang语言环境,需要安装C++编译。
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC unixODBC-devel httpd python-simplejson
2.erlang语言环境的安装(rabbitMq是用erlang分布式语言开发的)
安装文件获取
wget http://erlang.org/download/otp_src_19.2.tar.gz
解压erlang安装包
tar -xzvf otp_src_19.2.tar.gz
进入erlang目录
cd otp_src_19.2
编译安装erlang语言环境 prefix=/usr/local/erlang 为安装目录
./configure --prefix=/usr/local/erlang --enable-smp-support --enable-threads --enable-sctp --enable-kernel-poll --enable-hipe --with-ssl --without-javac
erlang语言编译配置选项:
–prefix 指定安装目录
–enable-smp-support启用对称多处理支持(Symmetric Multi-Processing对称多处理结构的简称)–enable-threads启用异步线程支持
–enable-sctp启用流控制协议支持(Stream Control Transmission Protocol,流控制传输协议)
–enable-kernel-poll启用Linux内核poll
–enable-hipe启用高性能Erlang –with-ssl 启用ssl包 –without-javac
不用java编译
开始安装编译:
make && make install
配置erlang环境变量
vim /etc/profile
export PATH=$PATH:/usr/local/erlang/bin
source /etc/profil
测试erlang安装是否成功
erl Erlang/OTP 17 [erts-6.2] [source] [smp:2:2] [async-threads:10] [kernel-poll:false]
Eshell V6.2 (abort with ^G)
会输出 erlang安装版本号
二、yum安装方式
root权限安装erlang
yum install erlang
rpm -ivh rabbitmq-server-3.6.6-1.el6.noarch.rpm
安装会报错 有依赖关系解决方法不安装依赖关系
warning: rabbitmq-server-3.6.6-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
erlang >= R16B-03 is needed by rabbitmq-server-3.6.6-1.el6.noarch
socat is needed by rabbitmq-server-3.6.6-1.el6.noarch
解决方法:
yum -y install socat
此时会报错没有socat包或是找不到socat包,解决方法安装centos的epel的扩展源
yum -y install epel-release
之后执行yum -y install socat
重新 安装socat
接着安装rpm -ivh rabbitmq-server-3.6.6-1.el6.noarch.rpm 安装会报错 有依赖关系解决方法不安装依赖关系
rpm -i –nodeps rabbitmq-server-3.6.6-1.el6.noarch.rpm
生成配置文件
cp /usr/share/doc/rabbitmq-server-3.6.6/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
启动rabbitmq
service rabbitmq-server start
报错如下:
Starting rabbitmq-server: rmdir: failed to remove `/var/run/rabbitmq’: Directory not empty
FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
解决方法:
ln -s /usr/local/erlang/bin/erl /usr/bin/erl
如果已经存在 /usr/bin/erl
则查看/var/log/rabbitmq/startup_err文件查看报错日志
ERROR: epmd error for host controller: timeout (timed out)
或者
ERROR: epmd error for host bogon: address (cannot connect to host/port)
rabbitmq默认用户是bogon
于是,
vi /etc/hosts 加入一行 127.0.0.1 bogon
之后再次 service rabbitmq-server start 启动正常
sh-4.1# /sbin/service rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
常用rabbitMq启动命令:
service rabbitmq-server start
service rabbitmq-server stop
service rabbitmq-server status
service rabbitmq-server rotate-logs|
service rabbitmq-server restart
service rabbitmq-server condrestart
service rabbitmq-server try-restart
service rabbitmq-server reload
service rabbitmq-server force-reload
ps -ef | grep rabbitmq 查看rabbitMq进程
netstat -anplt | grep LISTEN rabbitmq默认监听端口15672/5672
然后开启管理页面插件
rabbitmq-plugins enable rabbitmq_management
添加管理员账号
rabbitmqctl add_user rabbitadmin 123456
[yf482@bogon rabbitmq]$ sudo rabbitmqctl add_user rabbitadmin 123456
Creating user "rabbitadmin"
分配用户标签
rabbitmqctl set_user_tags rabbitadmin administrator
[yf482@bogon rabbitmq]$ sudo rabbitmqctl set_user_tags rabbitadmin administrator
Setting tags for user "rabbitadmin" to [administrator]
创建和赋角色完成后查看并确认
rabbitmqctl list_users
[yf482@bogon rabbitmq]$ sudo rabbitmqctl list_users
Listing users
rabbitadmin [administrator]
guest [administrator]
登录rabbitmq管理界面
浏览器输入地址:http://服务器IP地址:15672/
用户名密码:rabbitadmin/123456