-
上官网copy一下安装脚本,执行就好了。如果你跟我一样是ubuntu,那就用这个吧:
#!/bin/sh ## If sudo is not available on the system, ## uncomment the line below to install it # apt-get install -y sudo sudo apt-get update -y ## Install prerequisites sudo apt-get install curl gnupg -y ## Install RabbitMQ signing key curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add - ## Install apt HTTPS transport sudo apt-get install apt-transport-https ## Add Bintray repositories that provision latest RabbitMQ and Erlang 21.x releases sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF ## Installs the latest Erlang 21.x release. ## Change component to "erlang" to install the latest version (22.x or later). deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang-21.x deb https://dl.bintray.com/rabbitmq/debian bionic main EOF ## Update package indices sudo apt-get update -y ## Install rabbitmq-server and its dependencies sudo apt-get install rabbitmq-server -y --fix-missing
脚本上的注意点(坑):
- 脚本需要获取权限,命令:
chmod a+x 你的脚本
否则会出现‘command not found’错误
- 如果你不是ubuntu,注意根据你的linux版本修改脚本,主要是deb那两行——去翻官网吧 o(╯□╰)o
-
安装好后还有坑吗?
Of course!安装好以后可能会无法启动o(╯□╰)o。
表面原因是主机ip不对——这话什么意思我也不清楚o(╯□╰)o。反正解决办法就是打开编辑/etc/hosts文件:
sudo vim /etc/hosts
在文件头部加上一句:
127.0.0.1 你的主机名
如图:
127.0.0.1 brain
就是我加上的到这儿就能正常启动了!!!
-
如何远程访问?
远程访问很简单:
-
创建用户:
sudo rabbitmqctl add_user Username Password
例:
sudo rabbitmqctl add_user admin admin
-
分配角色:
sudo rabbitmqctl set_user_tags Username Tag
tag可选项:administrator,monitoring,policymaker,management。可多选,以空格隔开)
例:
sudo rabbitmqctl set_user_tags admin administrator
-
设置权限:
sudo rabbitmqctl set_permissions -p VHostPath Username ConfP WriteP ReadP
例:
sudo rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
-
rabbitmq服务器开放端口5672:
sudo iptables -A INPUT -ptcp --dport 5672 -j ACCEPT
完成!
如果要开启远程web管理服务,则需要开启rabbitmq-management,同时开放15672端口:
sudo rabbitmq-plugins enable rabbitmq_management sudo iptables -A INPUT -ptcp --dport 15672 -j ACCEPT
之后登录serverIp(RabbitMQ服务器ip):15672,即可管理RabbitMQ
-
Ubuntu环境下RabbitMQ安装
最新推荐文章于 2024-07-05 02:24:24 发布