Rabbitmq之修改日志和数据存放路径

1.linux版rabbitmq修改日志和数据存放路径

示例:

      rpm包安装日志和数据存放都在 /var下

(1)先创建数据文件和日志文件存放位置的目录并给权限

#mkdir -pv /usr/local/rabbitmq/mnesia
#mkdir -pv /usr/local/rabbitmq/log
#chmod -R 777 /usr/local/rabbitmq
#chown -R rabbitmq:rabbitmq /usr/local/rabbitmq/mnesia
#chown -R rabbitmq:rabbitmq /usr/local/rabbitmq/log

(2)创建或新增环境参数配置文件
#vim /etc/rabbitmq/rabbitmq-env.conf
增加如下两行内容
RABBITMQ_MNESIA_BASE=/usr/local/rabbitmq/mnesia
RABBITMQ_LOG_BASE=/usr/local/rabbitmq/log
保存,重启rabbitmq服务,修改数据文件和日志文件存放位置,相当于重置rabbitmq;

#rabbitmqctl stop
#rabbitmq-server -detached

(3)重新启用插件及添加用户 

#rabbitmq-plugins enable rabbitmq_management
#rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
#rabbitmqctl add_user rabbitmq rabbitmq
#rabbitmqctl set_user_tags rabbitmq administrator
#rabbitmqctl set_permissions -p / rabbitmq ".*" ".*" ".*"

2.windows版rabbitmq修改日志和数据存放路径

     注意:  erlang和rabbitmq不要安装在C盘

示例:

(1)修改sbin/rabbitmq-env.bat使得用户目录为rabbitmq安装目录下的user目录

        在以下行
if not defined ERLANG_HOME (
for /f "delims=" %%F in ('where.exe erl.exe') do @set ERL_PATH=%%F
if exist "!ERL_PATH!" (
for /f "delims=" %%F in ("!ERL_PATH!") do set ERL_DIRNAME=%%~dpF
for /f "delims=" %%F in ("!ERL_DIRNAME!\..") do @set ERLANG_HOME=%%~dpsF%%~nF%%~xF
)
set ERL_PATH=
set ERL_DIRNAME=
)

      后面添加如下:
set RABBITMQ_BASE=!RABBITMQ_HOME!/user

 

(2)在sbin目录下运行

禁止系统注册的rabbitmq服务,只使用命令启动
#rabbitmqctl.bat stop
#rabbitmq-service.bat -detached
#rabbitmq-service.bat install

(3)重新启用插件及添加用户 

#rabbitmq-plugins.bat enable rabbitmq_management
#rabbitmq-plugins.bat enable rabbitmq_consistent_hash_exchange
#rabbitmqctl.bat add_user rabbitmq rabbitmq
#rabbitmqctl.bat set_user_tags rabbitmq administrator
#rabbitmqctl.bat set_permissions -p / rabbitmq ".*" ".*" ".*"

 

posted @ 2020-03-07 19:24  非然踏古忘今焉  阅读(3585)  评论(0编辑  收藏  举报