centos7安装erlang和rabbitmq
时间: 2023-05-31 17:01:54 浏览: 259
安装Erlang和RabbitMQ
### 回答1:
1. 安装Erlang
- 首先,需要安装Erlang的依赖库,执行以下命令:
```
sudo yum install epel-release
sudo yum install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf
```
- 下载Erlang安装包,可以从官网下载,也可以使用以下命令下载:
```
wget https://packages.erlang-solutions.com/erlang/rpm/centos/7/x86_64/esl-erlang_23.3.4-1~centos~7_amd64.rpm
```
- 安装Erlang,执行以下命令:
```
sudo rpm -Uvh esl-erlang_23.3.4-1~centos~7_amd64.rpm
```
- 验证Erlang是否安装成功,执行以下命令:
```
erl
```
如果能够进入Erlang的交互式环境,则说明安装成功。
2. 安装RabbitMQ
- 添加RabbitMQ的Yum源,执行以下命令:
```
sudo tee /etc/yum.repos.d/rabbitmq.repo <<EOF
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1
EOF
```
- 安装RabbitMQ,执行以下命令:
```
sudo yum install rabbitmq-server
```
- 启动RabbitMQ服务,执行以下命令:
```
sudo systemctl start rabbitmq-server
```
- 设置RabbitMQ服务开机自启动,执行以下命令:
```
sudo systemctl enable rabbitmq-server
```
- 验证RabbitMQ是否安装成功,执行以下命令:
```
sudo rabbitmqctl status
```
如果能够看到类似以下输出,则说明安装成功:
```
Status of node rabbit@localhost ...
[{pid,xxx},
{running_applications,[{rabbit,"RabbitMQ","3.8.16"},
{rabbit_common,[],"3.8.16"},
{amqp_client,"RabbitMQ AMQP Client","5.11.0"},
{rabbitmq_management,"RabbitMQ Management","3.8.16"},
{rabbitmq_management_agent,"RabbitMQ Management Agent","3.8.16"},
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.8.16"},
{webmachine,"webmachine","1.10.3"},
{mochiweb,"MochiMedia Web Server","2.20.0"},
{jsx,"JSX","2.11.0"},
{rabbitmq_prometheus,"Prometheus metrics exporter for RabbitMQ","3.8.16"},
{prometheus,"Prometheus","4.4.0"},
{prometheus_process_collector,"Prometheus process collector","4.4.0"},
{prometheus_httpd,"Prometheus httpd","4.4.0"},
{os_mon,"CPO CXC 138 46","2.4.7"},
{cowboy,"Small, fast, modular HTTP server.","2.8.0"}]},
{os,{unix,linux}},
{erlang_version,"xxx"},
{memory,[{total,xxx},
{connection_readers,xxx},
{connection_writers,xxx},
{connection_channels,xxx},
{connection_other,xxx},
{queue_procs,xxx},
{queue_slave_procs,xxx},
{plugins,xxx},
{other_proc,xxx},
{mnesia,xxx},
{mgmt_db,xxx},
{msg_index,xxx},
{other_ets,xxx}]},
{alarms,[]},
{listeners,[{clustering,xxx,"::"},{amqp,xxx,"::"}]},
{vm_memory_high_watermark,xxx},
{vm_memory_limit,xxx},
{disk_free_limit,xxx},
{disk_free,xxx},
{file_descriptors,[{total_limit,xxx},
{total_used,xxx},
{sockets_limit,xxx},
{sockets_used,xxx}]},
{processes,[{limit,xxx},{used,xxx}]},
{run_queue,xxx},
{uptime,xxx}]
```
### 回答2:
CentOS 7是一款稳定可靠的操作系统,因为其安全性和稳定性得到广泛认可。为了实现消息队列的功能,我们需要安装Erlang和RabbitMQ。
一、安装Erlang
1. 首先,我们需要在CentOS 7安装Erlang,打开命令行终端窗口,键入以下命令:
sudo yum update
sudo yum -y install epel-release
2. 安装依赖库:
sudo yum -y install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel
3. 下载Erlang软件包:
wget http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_1_general/esl-erlang_24.1-1~centos~7_amd64.rpm
4. 运行以下命令安装Erlang:
sudo rpm -Uvh esl-erlang_24.1-1~centos~7_amd64.rpm
二、安装RabbitMQ
1. 下载RabbitMQ:
sudo wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.4/rabbitmq-server-generic-unix-3.9.4.tar.xz
2. 解压RabbitMQ:
sudo tar -xvf rabbitmq-server-generic-unix-3.9.4.tar.xz
3. 安装RabbitMQ:
sudo mv rabbitmq_server-3.9.4 /usr/lib/rabbitmq
4. 创建RabbitMQ配置文件:
sudo mkdir /etc/rabbitmq
sudo touch /etc/rabbitmq/rabbitmq.conf
sudo chmod 777 /etc/rabbitmq/rabbitmq.conf
sudo nano /etc/rabbitmq/rabbitmq.conf
5. 将以下内容添加到rabbitmq.conf中:
listeners.tcp.default = 5672
6. 创建RabbitMQ环境变量:
sudo nano /etc/profile.d/rabbitmq.sh
7. 将以下内容添加到rabbitmq.sh:
PATH=$PATH:/usr/lib/rabbitmq/sbin
export PATH
8. 创建并启动RabbitMQ服务:
sudo rabbitmq-server -detached
9. 检查RabbitMQ服务是否运行:
sudo rabbitmqctl status
至此,安装Erlang和RabbitMQ的过程已经完成。
### 回答3:
CentOS 7 是一款广受欢迎的 Linux 操作系统,它被广泛用于服务器端应用。Erlang 和 RabbitMQ 是非常强大的开源应用程序,使得在分布式网络环境下构建高性能应用程序变得更加容易。本文将介绍如何在 CentOS 7 上安装 Erlang 和 RabbitMQ。
安装 Erlang
Erlang 是一款强大的编程语言,被广泛应用于实时和高可靠性系统开发。以下是在 CentOS 7 上安装 Erlang 的步骤:
1. 安装 EPEL 和 RHEL 7 的 RPM 存储库,这将提供 erlang 小包和依赖关系。
sudo yum install epel-release
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2. 导入 erlang-solutions rpm 存储库密钥:
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
3. 安装 erlang:
sudo yum install erlang
4. 检查 erlang 是否正确安装:
erl
你将会看到 erlang shell:
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]
Eshell V11.0.2 (abort with ^G)
安装 RabbitMQ
RabbitMQ 是一个功能强大的消息代理,广泛用于分布式应用程序。这里是在 CentOS 7 上安装 RabbitMQ 的步骤:
1. 添加 RabbitMQ 的 RPM 存储库:
sudo yum install https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/noarch/rabbitmq-server-3.8.8-1.el7.noarch.rpm
2. 安装 rabbitmq:
sudo yum install rabbitmq-server
3. 启动和启用 rabbitmq 服务:
sudo systemctl start rabbitmq-server.service
sudo systemctl enable rabbitmq-server.service
4. 检查 rabbitmq 是否正确安装:
sudo systemctl status rabbitmq-server.service
你将会看到:
● rabbitmq-server.service - RabbitMQ Messaging Server
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-10-20 23:55:06 UTC; 3s ago
Main PID: 5845 (beam.smp)
Memory: 104.2M
CGroup: /system.slice/rabbitmq-server.service
├─5845 /usr/lib64/erlang/erts-11.0.2/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -st
├─6027 erl_child_setup 1024
├─6062 inet_gethost 4
└─6063 inet_gethost 4
如果看到 Active: active (running),表明 RabbitMQ 正常工作。
总结
以上就是在 CentOS 7 上安装 Erlang 和 RabbitMQ 的详细步骤。这两个应用程序可以使在分布式网络环境下构建高性能应用程序变得更加容易。如果你的应用程序需要可靠的通信,则 RabbitMQ 是一个理想的选择,同时 Erlang 语言可以帮助你快速构建高性能的分布式应用程序。
阅读全文