• rabbitmq安装


    下载rabbitmq软件包

    rabbitmq官网地址:http://www.rabbitmq.com/

    本次安装3.8.1版本的,版本仓库地址:https://github.com/rabbitmq/rabbitmq-server/releases

    安装包下载地址:https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.1/rabbitmq-server-generic-unix-3.8.1.tar.xz,

    GitHub的软件版本页面会提示需要Erlang的版本,点击链接下载即可

    另外,官网也给出了不同版本rabbitmq需要的Erlang版本,https://www.rabbitmq.com/which-erlang.html ,Erlang的下载地址:https://www.erlang.org/downloads/21.3

    安装依赖

    # yum -y install perl perl-devel ncurses-devel libtool libtool-ltdl-devel gcc-c++ erlang-doc erlang-jinterface unixODBC-devel mesa-libGLU-devel unixODBC-bin gtk2 fop libxml2-utils libxml2 libxslt

     

    安装openssl

    备份旧版本openssl

    # which openssl
    /usr/bin/openssl
    # mv  /usr/bin/openssl{,.old}
    # mv /etc/ssl{,.bak} #删除配置文件

    安装新版本openssl

    # wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz --no-check-certificate
    # tar -xzf openssl-1.1.1c.tar.gz -C ../softwares/
    
    # cd ../softwares/openssl-1.1.1c/
    
    # ./Configure shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl

    报错

    NOTE: If in doubt, on Unix-ish systems use './config'.

    需要使用config安装

    # ./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
    
    # make && make install

    修改动态库配置

    # vim /etc/ld.so.conf
    
    include ld.so.conf.d/*.conf
    /usr/local/openssl/lib

    配置生效
    # ldconfig -v

    设置openssl命令的软链接,并验证

    # ln -s /usr/local/openssl/bin/openssl  /usr/local/bin/openssl
    
    [root@localhost openssl-1.1.1c]# openssl version -a
    OpenSSL 1.1.1c  28 May 2019
    built on: Fri May 28 05:38:57 2021 UTC
    platform: linux-x86_64
    options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) 
    compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG
    OPENSSLDIR: "/usr/local/openssl"
    ENGINESDIR: "/usr/local/openssl/lib/engines-1.1"
    Seeding source: os-specific

    安装jdk

    # tar xfz  jdk-8u191-linux-x64.tar.gz -C ../softwares/
    
    # cd ../softwares/
    
    # ln -sv jdk1.8.0_191 jdk
    
    # sed -i.ori '$a export JAVA_HOME=/opt/softwares/jdk
    export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
    export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
    
    # . /etc/profile
    
    [root@localhost softwares]# java -version
    java version "1.8.0_191"
    Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

    安装wxWidgets-3.0.3

    # wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.5/wxWidgets-3.0.5.tar.bz2
    
    # tar -xjf wxWidgets-3.0.5.tar.bz2  -C ../softwares/

    安装

    # cd ../softwares/wxWidgets-3.0.5/
    
    # ./configure --with-opengl -enable-unicode -enable-debug
    
    # make && make install

    安装Erlang

    [root@localhost packages]# ll
    total 84844
    -rw-r--r-- 1 root root 85547038 May 27 22:16 otp_src_21.3.tar.gz
    -rw-r--r-- 1 root root  1327914 May 27 22:13 rabbitmq-server-generic-unix-3.8.1.tar.xz
    
    # tar xfz otp_src_21.3.tar.gz -C ../softwares/
    
    # cd ../softwares/otp_src_21.3/
    
    # ./configure --prefix=/opt/softwares/erlang --enable-shared-zlib --with-ssl=/usr/local/openssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --with-javac
    
    # make && make install

    配置环境变量

    # sed -ri -e '/JAVA_HOME=/a ERLANG_HOME=/opt/softwares/erlang' -e 's#(export PATH=.*)#1:$ERLANG_HOME/bin#' /etc/profile
    
    # . /etc/profile

    验证erlang

    [root@localhost otp_src_21.3]# erl
    Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
    
    Eshell V10.3  (abort with ^G)
    1> ssl:versions().
    [{ssl_app,"9.2"},
     {supported,['tlsv1.2','tlsv1.1',tlsv1]},
     {supported_dtls,['dtlsv1.2',dtlsv1]},
     {available,['tlsv1.2','tlsv1.1',tlsv1,sslv3]},
     {available_dtls,['dtlsv1.2',dtlsv1]}]

    安装rabbitmq

    # xz -d rabbitmq-server-generic-unix-3.8.1.tar.xz
    
    # tar xf rabbitmq-server-generic-unix-3.8.1.tar -C ../softwares/
    
    # cd ../softwares/
    
    # ln -sv rabbitmq_server-3.8.1 rabbitmq
    
    [root@localhost softwares]# ll
    total 8
    drwxr-xr-x  4 root root    28 May 28 01:04 erlang
    drwxr-xr-x 12 2004 wheel 4096 May 28 01:03 otp_src_21.3
    lrwxrwxrwx  1 root root    22 May 28 01:19 rabbitmq -> rabbitmq_server-3.8.1/
    drwxr-xr-x 10 root root  4096 Oct 31  2019 rabbitmq_server-3.8.1

    添加环境变量

    # sed -ri 's#(export PATH=.*)#1:/opt/softwares/rabbitmq/sbin#' /etc/profile
    # . /etc/profile

    启动rabbitmq的方式

    1、以守护进程启动

    # rabbitmq-server -detached
    Warning: PID file not written; -detached was passed.

    2、nohup rabbitmq-server start &

    服务运行状态及端口

    [root@localhost softwares]# rabbitmqctl status
    Status of node rabbit@localhost ...
    Runtime

    端口

    [root@localhost softwares]# ss -lntp
    State       Recv-Q Send-Q                                      Local Address:Port                                                     Peer Address:Port              
    LISTEN      0      128                                                     *:4369                                                                *:*                   users:(("epmd",pid=35113,fd=3))
    LISTEN      0      128                                                     *:22                                                                  *:*                   users:(("sshd",pid=11363,fd=3))
    LISTEN      0      100                                             127.0.0.1:25                                                                  *:*                   users:(("master",pid=826,fd=13))
    LISTEN      0      128                                                     *:25672                                                               *:*                   users:(("beam.smp",pid=35155,fd=77))
    LISTEN      0      128                                                    :::4369                                                               :::*                   users:(("epmd",pid=35113,fd=4))
    LISTEN      0      128                                                    :::22                                                                 :::*                   users:(("sshd",pid=11363,fd=4))
    LISTEN      0      100                                                   ::1:25                                                                 :::*                   users:(("master",pid=826,fd=14))
    LISTEN      0      128                                                    :::5672                                                               :::*                   users:(("beam.smp",pid=35155,fd=90))

    设置开机启动(两种)

    1、脚本

    [root@localhost softwares]# cat /etc/init.d/rabbitmq-server
    #!/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
    # Default-Start:     3 5
    # Default-Stop:      0 1 2 6
    # Description:       RabbitMQ broker
    # Short-Description: Enable AMQP service provided by RabbitMQ broker
    ### END INIT INFO
     
    # Source function library.
    . /etc/init.d/functions
     
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    export HOME=/root
    NAME=rabbitmq-server
    DAEMON=/opt/softwares/rabbitmq/sbin/${NAME}
    CONTROL=/opt/softwares/rabbitmq/sbin/rabbitmqctl
    DESC=rabbitmq-server
    USER=root
    PID_FILE=/var/run/rabbitmq/pid
    #RABBITMQ_ENV=/usr/lib/rabbitmq/bin/rabbitmq-env
    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}
     
    #RABBITMQ_SCRIPTS_DIR=$(dirname "$RABBITMQ_ENV")
    #. "$RABBITMQ_ENV"
     
    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 
                > "${RABBITMQ_LOG_BASE}/startup_log" 
                2> "${RABBITMQ_LOG_BASE}/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 ${RABBITMQ_LOG_BASE}/startup_{log, _err}
                    RETVAL=1
                    ;;
            esac
        fi
    }
     
    stop_rabbitmq () {
        status_rabbitmq quiet
        if [ $RETVAL = 0 ] ; then
            set +e
            $CONTROL stop ${PID_FILE} 
                > ${RABBITMQ_LOG_BASE}/shutdown_log 
                2> ${RABBITMQ_LOG_BASE}/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 ${RABBITMQ_LOG_BASE}/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
        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 /etc/init.d/rabbitmq-server
    chkconfig rabbitmq-server on

    2、unit文件

    # vim /usr/lib/systemd/system/rabbitmq-server.service
    
    [unit]
    Description=RabbitMQ broker
    After=syslog.target network.target
    [Service]
    Type=notify
    User=root
    Group=root
    WorkingDirectory=/opt/softwares/rabbitmq
    ExecStart=/opt/softwares/rabbitmq/bin/rabbitmq-server
    ExecStop=/opt/softwares/rabbitmq/bin/rabbitmqctl stop
    [Install]
    WantedBy=multi-user.target

    开启rabbitmq的web插件

    1、开启rabbitmq

    # rabbitmqctl start_app
    Starting node rabbit@localhost ...

    2、开启管理插件

    [root@localhost softwares]# rabbitmq-plugins enable rabbitmq_management
    Enabling plugins on node rabbit@localhost:
    rabbitmq_management
    The following plugins have been configured:
      rabbitmq_management
      rabbitmq_management_agent
      rabbitmq_web_dispatch
    Applying plugin configuration to rabbit@localhost...
    The following plugins have been enabled:
      rabbitmq_management
      rabbitmq_management_agent
      rabbitmq_web_dispatch
    
    started 3 plugins.

    3、查看插件集合

    [root@localhost softwares]# rabbitmq-plugins list
    Listing plugins with pattern ".*" ...
     Configured: E = explicitly enabled; e = implicitly enabled
     | Status: * = running on rabbit@localhost
     |/
    [  ] rabbitmq_amqp1_0                  3.8.1
    [  ] rabbitmq_auth_backend_cache       3.8.1
    [  ] rabbitmq_auth_backend_http        3.8.1
    [  ] rabbitmq_auth_backend_ldap        3.8.1
    [  ] rabbitmq_auth_backend_oauth2      3.8.1
    [  ] rabbitmq_auth_mechanism_ssl       3.8.1
    [  ] rabbitmq_consistent_hash_exchange 3.8.1
    [  ] rabbitmq_event_exchange           3.8.1
    [  ] rabbitmq_federation               3.8.1
    [  ] rabbitmq_federation_management    3.8.1
    [  ] rabbitmq_jms_topic_exchange       3.8.1
    [E*] rabbitmq_management               3.8.1
    [e*] rabbitmq_management_agent         3.8.1
    [  ] rabbitmq_mqtt                     3.8.1
    [  ] rabbitmq_peer_discovery_aws       3.8.1
    [  ] rabbitmq_peer_discovery_common    3.8.1
    [  ] rabbitmq_peer_discovery_consul    3.8.1
    [  ] rabbitmq_peer_discovery_etcd      3.8.1
    [  ] rabbitmq_peer_discovery_k8s       3.8.1
    [  ] rabbitmq_prometheus               3.8.1
    [  ] rabbitmq_random_exchange          3.8.1
    [  ] rabbitmq_recent_history_exchange  3.8.1
    [  ] rabbitmq_sharding                 3.8.1
    [  ] rabbitmq_shovel                   3.8.1
    [  ] rabbitmq_shovel_management        3.8.1
    [  ] rabbitmq_stomp                    3.8.1
    [  ] rabbitmq_top                      3.8.1
    [  ] rabbitmq_tracing                  3.8.1
    [  ] rabbitmq_trust_store              3.8.1
    [e*] rabbitmq_web_dispatch             3.8.1
    [  ] rabbitmq_web_mqtt                 3.8.1
    [  ] rabbitmq_web_mqtt_examples        3.8.1
    [  ] rabbitmq_web_stomp                3.8.1
    [  ] rabbitmq_web_stomp_examples       3.8.1

    web页面访问

    关闭rabbitmq 

    # rabbitmqctl stop_app
    Stopping rabbit application on node rabbit@localhost ...
  • 相关阅读:
    automatic preferred max layout width
    UIActivityIndicatorView
    collectionview不能拖动
    消除找不到文件路径的警告
    保存图片到本地和相册
    svn上传.a文件
    UILabel copyWithZone:]: unrecognized selector sent to instance 0x7fd662d8f9b0
    NSString NSURL
    iOS 定位功能
    前端实现左右翻页功能Demo
  • 原文地址:https://www.cnblogs.com/zh-dream/p/14823610.html
Copyright © 2020-2023  润新知