Centos7 64 系统 Linux
将下载的包放到
/opt/rabbitmq-server
中
编译安装Erlang的前提,需要编译安装wxwidgets
# [下载wxwidgets](http://www.wxwidgets.org/downloads/)
# 解压
bzip2 -dkv wxWidgets-3.2.1.tar.bz2
tar -xvf wxWidgets-3.2.1.tar
# unzip wxWidgets-3.2.1.zip # 或者
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC unixODBC-devel java-devel
# Erlang: No OpenGL headers found, wx will NOT be usable
yum install mesa* --skip-broken
yum install freeglut*
# 需要安装GTK+: yum install *gtk*或 yum install *gtk* --skip-broken
yum install *gtk*
# 配置
cd /opt/rabbitmq-server/wxWidgets-3.2.1
./configure --with-gtk=3 --with-opengl --enable-debug --enable-unicode
# 编译&安装(时间有点长)
make && make install
# install path: /usr/local/include/wx-3.2
# 测试
wx-config
# 解压
tar -zxvf otp_src_25.2.tar.gz
cd /opt/rabbitmq-server/otp_src_25.2
# 配置
./configure --prefix=/usr/local/erlang
# 出现如下信息,即说明配置成功
#*********************************************************************
#********************** APPLICATIONS INFORMATION *******************
#*********************************************************************
#
#erts :
# JIT disabled due to lack of compiler with C++17 support
#
#*********************************************************************
#*********************************************************************
#********************** DOCUMENTATION INFORMATION ******************
#*********************************************************************
#
#documentation :
# fop is missing.
# Using fakefop to generate placeholder PDF files.
# 编译&安装
make -j && make install
# install path: /usr/local/erlang/bin
安装位置: /usr/local/rabbitmq
日志位置: /usr/local/rabbitmq/var/log
yum install libtool libtool-ltdl-devel libevent-devel lua ncurses-devel openssl-devel flex
xz -d rabbitmq-server-generic-unix-3.11.5.tar.xz
tar xf rabbitmq-server-generic-unix-3.11.5.tar
mv rabbitmq_server-3.11.5 /usr/local/rabbitmq
# 配置环境变量
vim /etc/profile
PATH=$PATH:/usr/local/erlang/bin
PATH=$PATH:/usr/local/rabbitmq/sbin
source /etc/profile
下载 https://github.com/openssl/openssl/tags
选择 OpenSSL_1_1_1q
将下载的 openssl-OpenSSL_1_1_1j.tar.gz
tar -xzvf openssl-OpenSSL_1_1_1j.tar.gz
cd /opt/rabbitmq-server/openssl-OpenSSL_1_1_1j
# 配置
./config shared
# 编译安装
make && make install
# ----------------------- Erlang Rebuild -----------------------
cd /opt/rabbitmq-server/otp_src_25.2
make clean
# 配置
./configure --prefix=/usr/local/erlang
# 编译安装
make -j && make install
# 测试
elr
> crypto:start()
vim /etc/profile
# 末尾添加
export LC_ALL=en_US.UTF-8
source /etc/profile
vim /etc/hosts
# IP 本机名称
xxx.xxx.xxx.xxx HOST-NAME
# 前台启动
rabbitmq-server
# 后台启动
rabbitmq-server -detached
# 查看服务状态
rabbitmqctl status
rabbitmqctl stop
# 开启web管理界面
rabbitmq-plugins enable rabbitmq_management
# 检查所有插件的启用和禁用状态
# rabbitmq-plugins list
rabbitmqctl add_user admin '123456'
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
# 重启
rabbitmqctl stop
rabbitmq-server -detached
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --reload
curl http://127.0.0.1:15672
curl http://IP:15672
/usr/local/rabbitmq/sbin/rabbitmq-server
、/usr/local/rabbitmq/sbin/rabbitmq-env
备份rabbitmq-server、rabbitmq-env
拷贝到对应的服务器上
ERLANG_HOME=/usr/local/erlang/bin
;将erl
修改成$ERLANG_HOME/erl
cd /usr/lib/systemd/system
systemctl daemon-reload
systemctl enable rabbitmq.service
systemctl is-enabled rabbitmq.service
systemctl status rabbitmq.service
systemctl enable rabbitmq.service
systemctl start rabbitmq.service
systemctl stop rabbitmq.service
#
# /usr/lib/systemd/system
# systemd service file for RabbitMQ Server forking server
#
[Unit]
Description=Rabbitmq Server
Documentation=Rabbitmq Server 3.11.5 Rabbitmq Server Generic Unix 3.11.5
Documentation=https://github.com/rabbitmq/rabbitmq-server
Documentation=https://github.com/rabbitmq/rabbitmq-server/releases
Documentation=https://rabbitmq.com/install-generic-unix.html
Documentation=https://rabbitmq.com/which-erlang.html
After=network.target
[Service]
Type=forking
User=root
# Group=root
WorkingDirectory=/usr/local/rabbitmq
ExecStart=/usr/local/rabbitmq/sbin/rabbitmq-server -detached
ExecReload=/usr/local/rabbitmq/sbin/rabbitmqctl stop
ExecStop=/usr/local/rabbitmq/sbin/rabbitmqctl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
xxx.xxx.xxx.xxx springcloud
#!/bin/sh -e
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
##
ERLANG_HOME=/usr/local/erlang/bin
if [ "$RABBITMQ_ENV_LOADED" = 1 ]; then
return 0;
fi
if [ -z "$RABBITMQ_SCRIPTS_DIR" ]; then
# We set +e here since since our test for "readlink -f" below needs to
# be able to fail.
set +e
# Determine where this script is really located (if this script is
# invoked from another script, this is the location of the caller)
SCRIPT_PATH="$0"
while [ -h "$SCRIPT_PATH" ] ; do
# Determine if readlink -f is supported at all. TODO clean this up.
FULL_PATH=`readlink -f $SCRIPT_PATH 2>/dev/null`
if [ "$?" != "0" ]; then
REL_PATH=`readlink $SCRIPT_PATH`
if expr "$REL_PATH" : '/.*' > /dev/null; then
SCRIPT_PATH="$REL_PATH"
else
SCRIPT_PATH="`dirname "$SCRIPT_PATH"`/$REL_PATH"
fi
else
SCRIPT_PATH=$FULL_PATH
fi
done
set -e
RABBITMQ_SCRIPTS_DIR=`dirname $SCRIPT_PATH`
fi
_rmq_env_now()
{
date '+%Y-%m-%d %H:%M:%S'
}
_rmq_env_print()
{
_rmq_env_tmp="$1"
_rmq_env_tmp_len="${#_rmq_env_tmp}"
shift
printf '%s %s %s\n' "$(_rmq_env_now)" "$_rmq_env_tmp" "$1" 1>&2
shift
_rmq_env_print_line=''
_rmq_env_indent="$((_rmq_env_tmp_len + 21))"
for _rmq_env_print_line in "$@"
do
printf "%${_rmq_env_indent}s%s\n" ' ' "$_rmq_env_print_line" 1>&2
done
unset _rmq_env_print_line
unset _rmq_env_indent
unset _rmq_env_tmp_len
unset _rmq_env_tmp
}
_rmq_env_perr()
{
_rmq_env_print '[error]' "$@"
}
_rmq_env_pwarn()
{
_rmq_env_print '[warning]' "$@"
}
rmq_realpath() {
local path=$1
if [ -d "$path" ]; then
cd "$path" && pwd
elif [ -f "$path" ]; then
cd "$(dirname "$path")" && echo $(pwd)/$(basename "$path")
else
echo "$path"
fi
}
RABBITMQ_HOME="$(rmq_realpath "${RABBITMQ_SCRIPTS_DIR}/..")"
ESCRIPT_DIR="${RABBITMQ_HOME}/escript"
## Set defaults
. ${RABBITMQ_SCRIPTS_DIR}/rabbitmq-defaults
# We save the current value of $RABBITMQ_PID_FILE in case it was set by
# an init script. If $CONF_ENV_FILE overrides it again, we must ignore
# it and warn the user.
saved_RABBITMQ_PID_FILE="$RABBITMQ_PID_FILE"
## Get configuration variables from the configure environment file
[ "x" = "x$RABBITMQ_CONF_ENV_FILE" ] && RABBITMQ_CONF_ENV_FILE="$CONF_ENV_FILE"
if [ -f "$RABBITMQ_CONF_ENV_FILE" ]; then
CONF_ENV_FILE_PHASE=rabbitmq-env
. "$RABBITMQ_CONF_ENV_FILE" || true
fi
# Bump ETS table limit to 50000
if [ -z "$ERL_MAX_ETS_TABLES" ]; then
export ERL_MAX_ETS_TABLES=50000
fi
# Default is defined here:
# https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_port.h
if [ -z "$ERL_MAX_PORTS" ]; then
export ERL_MAX_PORTS=65536
fi
[ -n "$ERL_EPMD_PORT" ] && export ERL_EPMD_PORT
[ -n "$ERL_EPMD_ADDRESS" ] && export ERL_EPMD_ADDRESS
DEFAULT_SCHEDULER_BIND_TYPE="db"
[ -n "$SCHEDULER_BIND_TYPE" ] || SCHEDULER_BIND_TYPE="$DEFAULT_SCHEDULER_BIND_TYPE"
[ -n "$RABBITMQ_SCHEDULER_BIND_TYPE" ] || RABBITMQ_SCHEDULER_BIND_TYPE="$SCHEDULER_BIND_TYPE"
DEFAULT_DISTRIBUTION_BUFFER_SIZE=128000
[ -n "$DISTRIBUTION_BUFFER_SIZE" ] || DISTRIBUTION_BUFFER_SIZE="$DEFAULT_DISTRIBUTION_BUFFER_SIZE"
[ -n "$RABBITMQ_DISTRIBUTION_BUFFER_SIZE" ] || RABBITMQ_DISTRIBUTION_BUFFER_SIZE="$DISTRIBUTION_BUFFER_SIZE"
DEFAULT_MAX_NUMBER_OF_PROCESSES=1048576
[ -n "$MAX_NUMBER_OF_PROCESSES" ] || MAX_NUMBER_OF_PROCESSES="$DEFAULT_MAX_NUMBER_OF_PROCESSES"
[ -n "$RABBITMQ_MAX_NUMBER_OF_PROCESSES" ] || RABBITMQ_MAX_NUMBER_OF_PROCESSES="$MAX_NUMBER_OF_PROCESSES"
DEFAULT_MAX_NUMBER_OF_ATOMS=5000000
[ -n "$MAX_NUMBER_OF_ATOMS" ] || MAX_NUMBER_OF_ATOMS="$DEFAULT_MAX_NUMBER_OF_ATOMS"
[ -n "$RABBITMQ_MAX_NUMBER_OF_ATOMS" ] || RABBITMQ_MAX_NUMBER_OF_ATOMS="$MAX_NUMBER_OF_ATOMS"
DEFAULT_SCHEDULER_BUSY_WAIT_THRESHOLD=none
[ -n "$SCHEDULER_BUSY_WAIT_THRESHOLD" ] || SCHEDULER_BUSY_WAIT_THRESHOLD="$DEFAULT_SCHEDULER_BUSY_WAIT_THRESHOLD"
[ -n "$RABBITMQ_SCHEDULER_BUSY_WAIT_THRESHOLD" ] || RABBITMQ_SCHEDULER_BUSY_WAIT_THRESHOLD="$SCHEDULER_BUSY_WAIT_THRESHOLD"
## Common server defaults
SERVER_ERL_ARGS=" +P $RABBITMQ_MAX_NUMBER_OF_PROCESSES +t $RABBITMQ_MAX_NUMBER_OF_ATOMS +stbt $RABBITMQ_SCHEDULER_BIND_TYPE +zdbbl $RABBITMQ_DISTRIBUTION_BUFFER_SIZE +sbwt $RABBITMQ_SCHEDULER_BUSY_WAIT_THRESHOLD +sbwtdcpu $RABBITMQ_SCHEDULER_BUSY_WAIT_THRESHOLD +sbwtdio $RABBITMQ_SCHEDULER_BUSY_WAIT_THRESHOLD "
##--- Set environment vars RABBITMQ_ to defaults if not set
[ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS="$CTL_ERL_ARGS"
[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MIN" ] && RABBITMQ_CTL_DIST_PORT_MIN="$CTL_DIST_PORT_MIN"
[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MAX" ] && RABBITMQ_CTL_DIST_PORT_MAX="$CTL_DIST_PORT_MAX"
[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MIN" ] && RABBITMQ_CTL_DIST_PORT_MIN='35672'
[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MAX" ] && RABBITMQ_CTL_DIST_PORT_MAX="$(($RABBITMQ_CTL_DIST_PORT_MIN + 10))"
[ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS}
[ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS}
[ "x" = "x$RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS" ] && RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=${SERVER_ADDITIONAL_ERL_ARGS}
[ "x" = "x$RABBITMQ_SERVER_CODE_PATH" ] && RABBITMQ_SERVER_CODE_PATH=${SERVER_CODE_PATH}
[ "x" = "x$RABBITMQ_IGNORE_SIGINT" ] && RABBITMQ_IGNORE_SIGINT="true"
[ "xtrue" = "x$RABBITMQ_IGNORE_SIGINT" ] && RABBITMQ_IGNORE_SIGINT_FLAG="+B i"
if [ -n "$saved_RABBITMQ_PID_FILE" ] && \
[ "$saved_RABBITMQ_PID_FILE" != "$RABBITMQ_PID_FILE" ]
then
_rmq_env_pwarn 'RABBITMQ_PID_FILE was already set by the init script to:' \
"$saved_RABBITMQ_PID_FILE" \
'The value set in rabbitmq-env.conf is ignored because it would break the init script.'
RABBITMQ_PID_FILE="$saved_RABBITMQ_PID_FILE"
fi
[ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE}
##--- End of overridden variables
_rmq_env_set_erl_libs()
{
if [ -n "$ERL_LIBS" ]
then
export ERL_LIBS="$RABBITMQ_HOME/plugins:$ERL_LIBS"
else
export ERL_LIBS="$RABBITMQ_HOME/plugins"
fi
}
run_escript()
{
escript_main="${1:?escript_main must be defined}"
shift
escript="${1:?escript must be defined}"
shift
_rmq_env_set_erl_libs
# Important: do not quote RABBITMQ_CTL_ERL_ARGS as they must be
# word-split
# shellcheck disable=SC2086
exec $ERLANG_HOME/erl +B \
-boot "$CLEAN_BOOT_FILE" \
-noinput -noshell -hidden -smp enable \
$RABBITMQ_CTL_ERL_ARGS \
-kernel inet_dist_listen_min "$RABBITMQ_CTL_DIST_PORT_MIN" \
-kernel inet_dist_listen_max "$RABBITMQ_CTL_DIST_PORT_MAX" \
-run escript start \
-escript main "$escript_main" \
-extra "$escript" "$@"
}
RABBITMQ_ENV_LOADED=1
# Since we source this elsewhere, don't accidentally stop execution
true
#!/bin/sh
# vim:sw=4:et:
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
##
ERLANG_HOME=/usr/local/erlang/bin
set -e
# Get default settings with user overrides for (RABBITMQ_)
# Non-empty defaults should be set in rabbitmq-env
SCRIPTS_DIR=$(dirname "$0")
. "$SCRIPTS_DIR/rabbitmq-env"
[ "$NOTIFY_SOCKET" ] && RUNNING_UNDER_SYSTEMD=true
RABBITMQ_DEFAULT_ALLOC_ARGS="+MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30"
check_start_params() {
check_not_empty RABBITMQ_BOOT_MODULE
check_not_empty SASL_BOOT_FILE
}
check_not_empty() {
local name="${1:?}"
local value
eval value=\$$name
if [ -z "$value" ]; then
echo "Error: ENV variable should be defined: $1.
Please check rabbitmq-env, rabbitmq-defaults, and ${RABBITMQ_CONF_ENV_FILE} script files"
exit 78
fi
}
start_rabbitmq_server() {
set -e
_rmq_env_set_erl_libs
RABBITMQ_START_RABBIT=
[ "x" = "x$RABBITMQ_ALLOW_INPUT" ] && RABBITMQ_START_RABBIT=" -noinput"
if test -z "$RABBITMQ_NODE_ONLY"; then
if test "$USE_RABBIT_BOOT_SCRIPT"; then
# TODO: This is experimental and undocumented at this point.
# It is here just to do simple checks while playing with how
# RabbitMQ is started.
"$SCRIPTS_DIR/rabbitmq-rel" gen-boot
SASL_BOOT_FILE=rabbit
test -f "$SASL_BOOT_FILE.boot"
RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -init_debug"
else
RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s $RABBITMQ_BOOT_MODULE boot"
fi
fi
# We need to turn off path expansion because some of the vars,
# notably RABBITMQ_SERVER_ERL_ARGS, contain terms that look like
# globs and there is no other way of preventing their expansion.
set -f
export ERL_MAX_ETS_TABLES \
SYS_PREFIX
check_start_params
exec $ERLANG_HOME/erl \
-pa "$RABBITMQ_SERVER_CODE_PATH" \
${RABBITMQ_START_RABBIT} \
-boot "${SASL_BOOT_FILE}" \
+W w \
${RABBITMQ_DEFAULT_ALLOC_ARGS} \
${RABBITMQ_SERVER_ERL_ARGS} \
${RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS} \
${RABBITMQ_SERVER_START_ARGS} \
-syslog logger '[]' \
-syslog syslog_error_logger false \
-kernel prevent_overlapping_partitions false \
"$@"
}
stop_rabbitmq_server() {
if test "$rabbitmq_server_pid"; then
kill -TERM "$rabbitmq_server_pid"
wait "$rabbitmq_server_pid" || true
fi
}
if [ "$RABBITMQ_ALLOW_INPUT" -o "$RUNNING_UNDER_SYSTEMD" -o "$detached" ]; then
# Run erlang VM directly, completely replacing current shell
# process - so the pid file written in the code above will be
# valid (unless detached, which is also handled in the code
# above).
#
# And also this is the correct mode to run the broker under
# systemd - there is no need in a proxy process that converts
# signals to graceful shutdown command, the unit file should already
# contain instructions for graceful shutdown. Also by removing
# this additional process we could simply use value returned by
# `os:getpid/0` for a systemd ready notification.
start_rabbitmq_server "$@"
else
# When RabbitMQ runs in the foreground but the Erlang shell is
# disabled, we setup signal handlers to stop RabbitMQ properly. This
# is at least useful in the case of Docker.
# The Erlang VM should ignore SIGINT.
RABBITMQ_SERVER_START_ARGS="${RABBITMQ_SERVER_START_ARGS} ${RABBITMQ_IGNORE_SIGINT_FLAG}"
# Signal handlers. They all stop RabbitMQ properly, using
# rabbitmqctl stop. This script will exit with different exit codes:
# SIGHUP, SIGTSTP + SIGCONT
# Ignored until we implement a useful behavior.
# SIGTERM
# Exits 0 since this is considered a normal process termination.
# SIGINT
# Exits 128 + $signal_number where $signal_number is 2 for SIGINT (see
# https://pubs.opengroup.org/onlinepubs/009695399/utilities/kill.html).
# This is considered an abnormal process termination. Normally, we
# don't need to specify this exit code because the shell propagates it.
# Unfortunately, the signal handler doesn't work as expected in Dash,
# thus we need to explicitly restate the exit code.
#
# The behaviors below should remain consistent with the
# equivalent signal handlers in the Erlang code
# (see apps/rabbitmq_prelaunch/src/rabbit_prelaunch_sighandler.erl).
trap '' HUP TSTP CONT
trap "stop_rabbitmq_server; exit 0" TERM
trap "stop_rabbitmq_server; exit 130" INT
start_rabbitmq_server "$@" &
export rabbitmq_server_pid=$!
# Block until RabbitMQ exits or a signal is caught.
# Waits for last command (which is start_rabbitmq_server)
#
# The "|| true" is here to work around an issue with Dash. Normally
# in a Bourne shell, if `wait` is interrupted by a signal, the
# signal handlers defined above are executed and the script
# terminates with the exit code of `wait` (unless the signal handler
# overrides that).
# In the case of Dash, it looks like `set -e` (set at the beginning
# of this script) gets precedence over signal handling. Therefore,
# when `wait` is interrupted, its exit code is non-zero and because
# of `set -e`, the script terminates immediately without running the
# signal handler. To work around this issue, we use "|| true" to
# force that statement to succeed and the signal handler to properly
# execute. Because the statement below has an exit code of 0, the
# signal handler has to restate the expected exit code.
wait "$rabbitmq_server_pid" || true
fi