RabbitMQ学习笔记:安装环境
环境window10java8+虚拟机:centos7,下载erlang下载地址:http://erlang.org/download/我选的是otp_src_23.0.tar.gz:erlang安装步骤步骤一 解压# 步骤一[yutao@localhost ~] tar -xvf otp_src_23.0.tar.gz步骤二 配置和检查# 步骤二[yutao@localhost ~] cd ot
环境
window10
java8+
虚拟机:centos7,
下载erlang
下载地址:http://erlang.org/download/
我选的是otp_src_23.0.tar.gz
:
erlang安装步骤
步骤一 解压
# 步骤一
[yutao@localhost ~] tar -xvf otp_src_23.0.tar.gz
步骤二 配置和检查
# 步骤二
[yutao@localhost ~] cd otp_src_23.0
## 这里通过--prefix指定了安装目录
[yutao@localhost otp_src_23.0] ./configure --prefix=/home/yutao/programe/erlang
这里重点说明下,很多教程是教你配置–prefix=/opt/erlang这个目录下,但是/opt
这个目录的权限是root
权限。但是我们一般使用的权限是普通权限,所以当你用普通账号去安装时,会报没权限,虽然可以使用sudo
命令来规避,但是产生的文件名和文件所属组,都变成了root
,在后续临时文件和日志文件生成时,依然是没有权限,所以不建议安装到/opt
目录下。
这个时候不出意外,会提示 No curses library functions found.错误
说明需要安装ncurses
[yutao@localhost otp_src_23.0] sudo yum install ncurses-devel
如果yum
提示没有找到ncurses
,说明该更新yum
源了。
更新yum源
# 进入目录
[yutao@localhost ~] cd /etc/yum.repos.d/
# 创建目录
[yutao@localhost yum.repos.d] mkdir backup
# 默认源配备份
[yutao@localhost yum.repos.d] mv C* backup/
# 下载阿里云yum源
[yutao@localhost yum.repos.d] wget -O /etc/yum.repos.d/CenOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 清除旧缓存
[yutao@localhost yum.repos.d] yum clean all
# 创建新缓存
[yutao@localhost yum.repos.d] yum makecache
# 更新yum
[yutao@localhost yum.repos.d] yum update -y
再次执行后,发现报:
./configure: line 4659: wx-config: command not found
configure: WARNING:
wxWidgets must be installed on your system.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed (returned by
'wx-config --libs' or 'wx-config --static --libs' command)
is in LD_LIBRARY_PATH or equivalent variable and
wxWidgets version is 2.8.4 or above.
*********************************************************************
********************** APPLICATIONS DISABLED **********************
*********************************************************************
crypto : No usable OpenSSL found
odbc : ODBC library - link check failed
ssh : No usable OpenSSL found
ssl : No usable OpenSSL found
*********************************************************************
*********************************************************************
********************** APPLICATIONS INFORMATION *******************
*********************************************************************
wx : wxWidgets not found, wx will NOT be usable
*********************************************************************
*********************************************************************
********************** DOCUMENTATION INFORMATION ******************
*********************************************************************
documentation :
fop is missing.
Using fakefop to generate placeholder PDF files.
*********************************************************************
我们接下来依次安装:
安装wxWidgets
wx-config: command not found
当执行:yum install –y wxWidgets-devel
时,会报没有可用软件包 wxWidgets-devel
这个时候执行:
# 更新epel第三方软件库
yum install -y epel-release
# 再次执行,就可以安装了
yum install –y wxWidgets-devel
yum install wxBase #for /usr/bin/wx-config-3.0
cd /usr/bin
# 创建软连接
ln -s wx-config-3.0 wx-config
这个软连接时一定得创建的;
安装 openssl
[yutao@localhost otp_src_23.0]$ sudo yum install openssl-devel
安装unixODBC
[yutao@localhost otp_src_23.0]$ yum install unixODBC-devel
安装flex
[yutao@localhost otp_src_23.0]$ sudo yum -y install flex
安装gcc
这个是unixODBC
需要用上的;
[yutao@localhost otp_src_23.0]$ sudo yum install gcc
我的最终提示:
*********************************************************************
********************** DOCUMENTATION INFORMATION ******************
*********************************************************************
documentation :
fop is missing.
Using fakefop to generate placeholder PDF files.
可以看出警告
和APPLICATIONS DISABLED
都已经没有了;
说明检查通过了,接着我们需要执行编译
和安装
;
Erlang编译
# 执行编译,保证没有错误
[yutao@localhost otp_src_23.0] make
# 执行安装,只有在编译没有错误时,才能安装成功
[yutao@localhost otp_src_23.0] make install
配置环境变量
[yutao@localhost ~]$ sudo vim /etc/profile
验证安装是否成功
出现如下提示,就表示安装成功。
[yutao@localhost ~]$ erl
Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Eshell V11.0 (abort with ^G)
1>
退出erlang
有几种退出Erlang Shell
的方法
1、命令方式1:执行init:stop()
.
2、命令方式2:执行halt().
3、快捷键方式1:Control+C 然后选a
4、快捷键方式2:Control+G 然后按q
我用的方式时3.
安装rabbitmq
下载
下载地址:https://www.rabbitmq.com/releases/rabbitmq-server
这个下载地址最新只到3.6+
最新版:https://github.com/rabbitmq/rabbitmq-server/releases/
我选择的是rabbitmq-server-generic-unix-3.8.7.tar.xz
安装
# 这里通过-C 指定了安装目录,即和erlang在同一个目录下
[yutao@localhost downloads]$ sudo tar -xvf rabbitmq-server-generic-unix-3.6.15.tar.xz -C /home/yutao/programe/rabbitmq
配置环境变量
[yutao@localhost ~]$ sudo vim /etc/profile
# 添加如下:
ERLANG_HOME=/home/yutao/programe/erlang
RABITMQ_HOME=/home/yutao/programe/rabbitmq
export PATH=$PATH:$ERLANG_HOME/bin:$RABITMQ_HOME/sbin
export ERLANG_HOME
export RABITMQ_HOME
启动rabbitmq
命令:
[yutao@localhost programe]$ rabbitmq-server start
[yutao@localhost programe]$ rabbitmq-server stop
# 守护进程的方式启动
[yutao@localhost programe]$ rabbitmq-server -detached
启动日志:
[yutao@localhost programe]$ rabbitmq-server start
Configuring logger redirection
## ## RabbitMQ 3.8.7
## ##
########## Copyright (c) 2007-2020 VMware, Inc. or its affiliates.
###### ##
########## Licensed under the MPL 2.0. Website: https://rabbitmq.com
Doc guides: https://rabbitmq.com/documentation.html
Support: https://rabbitmq.com/contact.html
Tutorials: https://rabbitmq.com/getstarted.html
Monitoring: https://rabbitmq.com/monitoring.html
Logs: /home/yutao/programe/rabbitmq/var/log/rabbitmq/rabbit@localhost.log
/home/yutao/programe/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log
Config file(s): (none)
Starting broker... completed with 0 plugins.
通过
rabbitmqctl status
命令查看运行状态
[yutao@localhost ~]$ rabbitmqctl status
Status of node rabbit@localhost ...
Runtime
OS PID: 38383
OS: Linux
Uptime (seconds): 102
RabbitMQ version: 3.8.7
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:64] [hipe]
Erlang processes: 279 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60
Plugins
Enabled plugin file: /home/yutao/programe/rabbitmq/etc/rabbitmq/enabled_plugins
Enabled plugins:
Data directory
Node data directory: /home/yutao/programe/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /home/yutao/programe/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost
Config files
Log file(s)
* /home/yutao/programe/rabbitmq/var/log/rabbitmq/rabbit@localhost.log
* /home/yutao/programe/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log
Alarms
(none)
Memory
Total memory used: 0.0867 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 1.5833 gb
other_proc: 0.029 gb (33.45 %)
code: 0.0247 gb (28.53 %)
other_system: 0.0137 gb (15.76 %)
allocated_unused: 0.012 gb (13.85 %)
other_ets: 0.003 gb (3.43 %)
reserved_unallocated: 0.002 gb (2.31 %)
atom: 0.0013 gb (1.54 %)
plugins: 0.0004 gb (0.51 %)
metrics: 0.0002 gb (0.23 %)
binary: 0.0002 gb (0.21 %)
mnesia: 0.0001 gb (0.09 %)
quorum_ets: 0.0 gb (0.05 %)
msg_index: 0.0 gb (0.04 %)
connection_channels: 0.0 gb (0.0 %)
connection_other: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
mgmt_db: 0.0 gb (0.0 %)
queue_procs: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)
File Descriptors
Total: 2, limit: 65439
Sockets: 0, limit: 58893
Free Disk Space
Low free disk space watermark: 0.05 gb
Free disk space: 8.8752 gb
Totals
Connection count: 0
Queue count: 0
Virtual host count: 1
Listeners
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
也可以通过
rabbitmqctl cluster_status
查看集群状态,目前只有一个RabbitMQ
服务节点,可以看作单节点集群:
[yutao@localhost erlang]$ rabbitmqctl cluster_status
Cluster status of node rabbit@localhost ...
Basics
Cluster name: rabbit@localhost
Disk Nodes
rabbit@localhost
Running Nodes
rabbit@localhost
Versions
rabbit@localhost: RabbitMQ 3.8.7 on Erlang 23.0
Alarms
(none)
Network Partitions
(none)
Listeners
Node: rabbit@localhost, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@localhost, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Feature flags
Flag: implicit_default_bindings, state: enabled
Flag: quorum_queue, state: enabled
Flag: virtual_host_metadata, state: enabled
至此环境搭建完毕;
创建root账号
RabbitMQ默认服务的用户名和密码都是guest
,但是这个账户有限制,默认只能通过本地网络访问,远处网络访问受限;所以在实现生产和消费消息之前,需要另外添加一个用户,并设置相应的权限。
# 添加root用户
[yutao@localhost ~]$ rabbitmqctl add_user root root
Adding user "root" ...
# 设置所有权限
[yutao@localhost ~]$ rabbitmqctl set_permissions -p / root ".*" ".*" ".*"
Setting permissions for user "root" in vhost "/" ...
# 设置为管理员角色
[yutao@localhost ~]$ rabbitmqctl set_user_tags root administrator
Setting tags for user "root" to [administrator] ...
[yutao@localhost ~]$
开放端口
因为我是在window中的虚拟机里安装的,所以需要开放端口方便本地程序链接;
# centos7 默认是安装了firewalld防火墙的
# 永久开放端口
[yutao@localhost erlang]$ sudo firewall-cmd --permanent --add-port=5672/tcp
# 重启防火墙
[yutao@localhost erlang]$ sudo firewall-cmd --reload
# 查看防火墙状态
[yutao@localhost erlang]$ sudo firewall-cmd --state
# 显示目前的设定
[yutao@localhost erlang]$ sudo firewall-cmd --list-all
总结
1、Erlang环境一定得安装好,而且Erlang和Rabbitmq的版本是有对应关系的:
官方地址:https://www.rabbitmq.com/which-erlang.html
我一开始,因为两个的版本没有对上,导致启动rabbitmq报错;起不来;
2、安装Erlang时,严格讲是执行./configure 命令进行检查时,会提示很多No *** found
和APPLICATIONS DISABLED
,这些都得想办法干掉;
3、通常我们安装软件不会使用root
用户,自然root用户下的文件夹,尽量少用,比如/opt
,不然会有权限问题;
4、我是在window上使用虚拟机centos7来安装的,为了能与本地程序链接,我还需要开放防火墙的端口5672
来进行通讯;
参考地址:
wx-config: command not found或wxWidgets must be installed on your system.
更多推荐
所有评论(0)