• rabbitmq一键部署脚本


    1、新建一个名字叫 auto_install_rabbitmq.sh  的文件

    2、将下面脚本拷贝到文件中,具体操作步骤在注释里面

    #环境 linux
    #一键安装rabitmq,在linux环境中使用脚本运行该文件(sh auto_install_rabbitmq.sh)
    #!/bin/bash 
    #功能:rabbitmq自动安装。
    #需要将安装文件put到/opt/tools/ 目录下,
    #然后执行本脚本,安装至/opt/app/目录下。
    #默认管理员账户:账号:admin  密码:admin123456
    
    #查看文件是否有windows的换行符: cat -v auto_install_redis.sh
    #替换windows的换行符:sed 's/
    //' 原始文件名 > 新文件名
    
    rabbitmq_install(){
     
    #设定ERLANG变量
    ERLANG_FILE=otp_src_21.1.tar.gz
    ERLANG_FILE_DIR=otp_src_21.1
    ERLANG_PATH=/opt/app/erlang
     
    #设定rabbitmq环境变量
    RB_FILE=rabbitmq-server-3.6.8
    RB_FILE_DIR=/opt/app/
    RB_PATH=/opt/app/rabbitmq-server-3.6.8
    
    cd /usr/local/src
    #下载安装包
    wget  http://erlang.org/download/$ERLANG_FILE
     
    #yum安装依赖包
    yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC-devel
     
    #解压erlang文件并安装
    tar -zxvf $ERLANG_FILE
    cd $ERLANG_FILE_DIR
    ./configure --with-ssl --prefix=$ERLANG_PATH
    make && make install
    
    #验证erlang是否安装成功
    #./bin/erl
    
    #解压rabbitmq
    #tar -xvJf $RB_FILE -C $RB_FILE_DIR
    wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.8/rabbitmq-server-3.6.8-1.el7.noarch.rpm
    rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
    yum install rabbitmq-server-3.6.8-1.el7.noarch.rpm
    cp /usr/share/doc/rabbitmq-server-3.6.8/rabbitmq.config.example  /etc/rabbitmq
    
    ########写入rabbitmq-env.conf配置文件########
    echo '#!/bin/sh
    RABBITMQ_MNESIA_BASE=/usr/local/rabbitmq-server/data
    RABBITMQ_LOG_BASE=/usr/local/rabbitmq-server/log
    ' > /etc/rabbitmq/rabbitmq-env.conf
    
    cd /usr/local
    mkdir rabbitmq-server
    chmod -R 777 /usr/local/rabbitmq-server
     
    #设定erlang/rabbitmq环境变量 
    #PATH=/opt/app/erlang/bin:$PATH
    echo "###erlang/rabbitmq PATH #####" >>/etc/profile
    echo "PATH=${ERLANG_PATH}/bin:{}/sbin:$PATH" >>/etc/profile
    echo "PATH=${RB_PATH}/sbin:{}/sbin:$PATH" >>/etc/profile
    echo "export PATH " >>/etc/profile
    echo "###erlang PATH END ###   ">>/etc/profile
    
    #刷新配置文件
    source /etc/profile
    
    systemctl start rabbitmq-server.service
    #添加到启动项并设置开机自启
    chkconfig rabbitmq-server on
    systemctl enable rabbitmq-server.service
    #开启管理界面
    rabbitmq-plugins enable rabbitmq_management
    #设置账号
    rabbitmqctl add_user admin admin123456
    rabbitmqctl set_user_tags admin  administrator
    rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
    }
    
    read -p " Do you want to install rabbitmq:Y/N " REDISCONFIRM
    if [ "$REDISCONFIRM" = "Y" ] || [ "$REDISCONFIRM" = "y" ];then
        rabbitmq_install
    else
    echo "=================== install the next thing =============="
    fi
  • 相关阅读:
    java 爬虫 爬取豆瓣 请不要害羞 图片
    Intellij idea 基本配置
    Linux 基本操作
    Java 快速排序
    Codeforces 986D Perfect Encoding FFT
    Codeforces 749E Gosha is hunting 二分+DP
    BZOJ5305 [Haoi2018]苹果树
    Codeforces 666E Forensic Examination SAM+权值线段树
    BZOJ3712[PA2014]Fiolki 建图+倍增lca
    Codeforces 576D Flights for Regular Customers 矩阵快速幂+DP
  • 原文地址:https://www.cnblogs.com/cjyboy/p/11249404.html
Copyright © 2020-2023  润新知