记一次修改rabbitmq 3.8版本默认端口号的过程

1、创建配置文件(路径随意。本人是创建在/etc/rabbitmq路径下了)

cd /etc/rabbitmq
vim rabbitmq.conf

配置文件内容如下:(默认的数据管理端口为5672,web页面管理端口为15672。这里我们改为5762和15762)

#数据管理端口(默认端口为5672)
listeners.tcp.default=5762
#界面管理端口(默认端口为15672)
management.tcp.port=15762
management.tcp.ip=0.0.0.0

编辑完成,按esc后,:wq保存并退出。

2、找到rabbitmq默认配置文件

cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.8.1/sbin/
[root@LL-AA-8004376 sbin]# ls
cuttlefish  rabbitmqctl  rabbitmq-defaults  rabbitmq-diagnostics  rabbitmq-env  rabbitmq-plugins  rabbitmq-queues  rabbitmq-server  rabbitmq-upgrade

3、修改rabbitmq-defaults文件(主要是将配置文件的路径给添加进去)

#!/bin/sh -e
##  The contents of this file are subject to the Mozilla Public License
##  Version 1.1 (the "License"); you may not use this file except in
##  compliance with the License. You may obtain a copy of the License
##  at https://www.mozilla.org/MPL/
##
##  Software distributed under the License is distributed on an "AS IS"
##  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
##  the License for the specific language governing rights and
##  limitations under the License.
##
##  The Original Code is RabbitMQ.
##
##  The Initial Developer of the Original Code is GoPivotal, Inc.
##  Copyright (c) 2012-2019 Pivotal Software, Inc.  All rights reserved.
##

### next line potentially updated in package install steps
SYS_PREFIX=

### next line will be updated when generating a standalone release
ERL_DIR=

CLEAN_BOOT_FILE=start_clean
SASL_BOOT_FILE=start_sasl

if [ -f "${RABBITMQ_HOME}/erlang.mk" ]; then
    # RabbitMQ is executed from its source directory. The plugins
    # directory and ERL_LIBS are tuned based on this.
    RABBITMQ_DEV_ENV=1
fi

## Set default values
#listeners.tcp.default= 5762
#management.tcp.port = 15762
BOOT_MODULE="rabbit"

CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq.conf
LOG_BASE=${SYS_PREFIX}/var/log/rabbitmq
MNESIA_BASE=${SYS_PREFIX}/var/lib/rabbitmq/mnesia
ENABLED_PLUGINS_FILE=${SYS_PREFIX}/etc/rabbitmq/enabled_plugins
GENERATED_CONFIG_DIR=${SYS_PREFIX}/var/lib/rabbitmq/config
ADVANCED_CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/advanced.config
SCHEMA_DIR=${SYS_PREFIX}/var/lib/rabbitmq/schema

PLUGINS_DIR="${RABBITMQ_HOME}/plugins"

# RABBIT_HOME can contain a version number, so default plugins
# directory can be hard to find if we want to package some plugin
# separately. When RABBITMQ_HOME points to a standard location where
# it's usually being installed by package managers, we add
# "/usr/lib/rabbitmq/plugins" to plugin search path.
case "$RABBITMQ_HOME" in
    /usr/lib/rabbitmq/*)
        PLUGINS_DIR="/usr/lib/rabbitmq/plugins:$PLUGINS_DIR"
        ;;
esac

CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf

修改CONFIG_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq,将配置文件的路径改为你创建的配置文件的路径。

注意3.8.4版本里面是没有CONFIG_FILE配置的,直接将这句配置加进去即可。

保存并退出后。重启rabbitmq即可。

systemctl restart rabbitmq-server.service

============================通过日志查看是否已有配置文件==========================

如果之前有配置文件,那么就不用创建新的配置文件。可以通过日志查看配置文件路径或查看是否加载生效:

cd /var/log/rabbitmq/
ls

找到rabbit@LL-AA-8004376.log

cat rabbit@LL-AA-8004376.log

没添加配置文件之前:

配置文件添加并重启后:

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值