目录
1、安装erlang的依赖包
2、上传erlang的压缩包至/usr/local/,并解压缩,再新建erlang目录
3、编译安装,在/usr/local/otp_src_21.3目录下执行
?4、添加erlang到环境变量vi /etc/profile在最后一行添加
重新加载环境变量source /etc/profile?5、测试erl
6、下载RabbitMQ安装包至/usr/local/,并解压
7、添加RabbitMQ到环境变量
8、RabbitMQ启动测试
9、添加web管理插件
?10、?添加用户
11.添加开机启动
?12.服务命令打开或关闭服务
1、安装erlang的依赖包
yum install -y make gcc gcc-c++ m4 perl openssl openssl-devel ncurses-devel unixODBC unixODBC-devel
2、上传erlang的压缩包至/usr/local/,并解压缩,再新建erlang目录
这是下载链接:https://share.weiyun.com/DKkAONgO 密码:nwun6z
tar -zxvf otp_src_21.3.tar.gz
mkdir /usr/local/erlang
3、编译安装,在/usr/local/otp_src_21.3目录下执行
./configure --prefix=/usr/local/erlang
报错:configure: error: Perl version 5 is required! 安装Perl:yum install perl 重新编译:./configure --prefix=/usr/local/erlang
安装:
make && make install
4、添加erlang到环境变量 vi /etc/profile 在最后一行添加
PATH=$PATH:/usr/local/erlang/bin
重新加载环境变量 source /etc/profile ? 5、测试erl
6、下载RabbitMQ安装包至/usr/local/,并解压
tar -vxf rabbitmq-server-generic-unix-3.7.14.tar.xz?
mv rabbitmq_server-3.7.14/ /usr/local/rabbitmq_server-3.7.14
7、添加RabbitMQ到环境变量
vi /etc/profile
在最后一行添加
PATH=$PATH:/usr/local/rabbitmq_server-3.7.14/sbin
重新加载环境变量
source /etc/profile
8、RabbitMQ启动测试
rabbitmq-server
?关掉SELINUX: 输入命令:vi ?/etc/selinux/config?
?把主机名字改了 不是数字就行
?再次启动
9、添加web管理插件
rabbitmq-plugins enable rabbitmq_management
?访问web 页面??
?10、?添加用户
RabbitMQ的Username 和 Password 默认为guest/guest? 只能本地登录
添加用户
rabbitmqctl add_user admin mq.admin
配置权限
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
查看用户权限
rabbitmqctl list_user_permissions admin
设置tag
rabbitmqctl set_user_tags admin administrator
这样就可以用 admin 密码mq.admin登录了
11.添加开机启动
cd /etc/init.d
vi?rabbitmq
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides: rabbitmq-server
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Description: RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
# Source function library.
. /etc/init.d/functions
export HOME=/root
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/erlang/bin
NAME=rabbitmq-server
DAEMON=/usr/local/rabbitmq_server-3.7.14/sbin/${NAME}
CONTROL=/usr/local/rabbitmq_server-3.7.14/sbin/rabbitmqctl
DESC=rabbitmq-server
USER=root
ROTATE_SUFFIX=
INIT_LOG_DIR=/usr/local/rabbitmq_server-3.7.14/var/log/rabbitmq
PID_FILE=/var/run/rabbitmq/pid
START_PROG="daemon"
LOCK_FILE=/var/lock/subsys/$NAME
test -x $DAEMON || exit 0
test -x $CONTROL || exit 0
RETVAL=0
set -e
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
ensure_pid_dir () {
PID_DIR=`dirname ${PID_FILE}`
if [ ! -d ${PID_DIR} ] ; then
mkdir -p ${PID_DIR}
chown -R ${USER}:${USER} ${PID_DIR}
chmod 755 ${PID_DIR}
fi
}
remove_pid () {
rm -f ${PID_FILE}
rmdir `dirname ${PID_FILE}` || :
}
start_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
echo RabbitMQ is currently running
else
RETVAL=0
ensure_pid_dir
set +e
RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \
> "${INIT_LOG_DIR}/startup_log" \
2> "${INIT_LOG_DIR}/startup_err" \
0<&- &
$CONTROL wait $PID_FILE >/dev/null 2>&1
RETVAL=$?
set -e
case "$RETVAL" in
0)
echo SUCCESS
if [ -n "$LOCK_FILE" ] ; then
touch $LOCK_FILE
fi
;;
*)
remove_pid
echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
RETVAL=1
;;
esac
fi
}
stop_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
set +e
$CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
RETVAL=$?
set -e
if [ $RETVAL = 0 ] ; then
remove_pid
if [ -n "$LOCK_FILE" ] ; then
rm -f $LOCK_FILE
fi
else
echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
fi
else
echo RabbitMQ is not running
RETVAL=0
fi
}
status_rabbitmq() {
set +e
if [ "$1" != "quiet" ] ; then
$CONTROL status 2>&1
else
$CONTROL status > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
RETVAL=3
fi
set -e
}
rotate_logs_rabbitmq() {
set +e
$CONTROL rotate_logs ${ROTATE_SUFFIX}
if [ $? != 0 ] ; then
RETVAL=1
fi
set -e
}
restart_running_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
restart_rabbitmq
else
echo RabbitMQ is not runnning
RETVAL=0
fi
}
restart_rabbitmq() {
stop_rabbitmq
start_rabbitmq
}
case "$1" in
start)
echo -n "Starting $DESC: "
start_rabbitmq
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
stop_rabbitmq
echo "$NAME."
;;
status)
status_rabbitmq
;;
rotate-logs)
echo -n "Rotating log files for $DESC: "
rotate_logs_rabbitmq
;;
force-reload|reload|restart)
echo -n "Restarting $DESC: "
restart_rabbitmq
echo "$NAME."
;;
try-restart)
echo -n "Restarting $DESC: "
restart_running_rabbitmq
echo "$NAME."
;;
*)
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
RETVAL=1
;;
esac
exit $RETVAL
授权 添加开机启动
chmod +x rabbitmq
chkconfig --add rabbitmq
chkconfig rabbitmq on
?12.服务命令打开或关闭服务
?service rabbitmq start service rabbitmq status service rabbitmq stop
|