【问题标题】:ATOP Config file for an AWS Beanstalk deploymentAWS Beanstalk 部署的 ATOP 配置文件
【发布时间】:2018-09-02 15:01:23
【问题描述】:

当机器从 Beanstalk 部署时,我需要 ATOP 在 EC2 上安装实例。 AWS 支持只有下面的链接,但它没有显示如何在 ebextensions 配置文件中进行部署。有人已经这样做并且已经制作了配置文件吗?谢谢! --> https://www.tecmint.com/how-to-install-atop-to-monitor-logging-activity-of-linux-system-processes/ 顺便说一句,使用 Amazon Linux

{{编辑 3/23/18}}

到目前为止,我自己解决了这个问题,这就是我所拥有的。它没有完全工作,但仍在努力。

packages:
  rpm:
    epel: https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

container_commands:
  1_rpm_atop:
    command: "sudo /bin/rpm -i --replacepkgs 
https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm"
  2_add_atop:
    command: "/sbin/chkconfig --add atop"
    leader_only: true
  3_add_atop:
    command: "/sbin/chkconfig atop on --level 235"
    leader_only: true
  4_config_atop:
    command: "/bin/sed 's/600/60/' /usr/share/atop/atop.daily -i"
    leader_only: true
  5_link:
    command: "/bin/ln -sfn /var/log/atop /var/app/current/wp-content/uploads/atop"
    leader_only: true
  6_start:
    command: "/etc/init.d/atop start"
    leader_only: true

【问题讨论】:

    标签: amazon-ec2 amazon-elastic-beanstalk


    【解决方案1】:

    试试这个

    container_commands:
      1_add_epel:
        command:  sudo sed -i "6s,enabled=0,enabled=1,g" /etc/yum.repos.d/epel.repo 
    
      2_install_atop:
        command: sudo yum update && sudo yum install atop -y
    

    【讨论】:

    • 事实证明,epel 与我正在使用的 Amazon Linux 版本中包含的版本冲突,因此没有必要安装它。在亚马逊的支持帮助下,我们能够获得有效的安装。我仍在测试符号链接上的日志记录持久性,但完成后我将分享最终配置。
    【解决方案2】:

    在来自 AWS Beanstalk 技术支持的出色 Yao 的帮助下,我们已经能够创建一个在所有实例上安装 ATOP 的文件。同样,它将单个实例日志写入我已经存在的符号链接 EFS 文件目录,以便日志将通过扩展和机器部署持续存在。这现在在我的开发部署中工作。如果您没有听到其他消息,则意味着它在大约一周内也可以投入生产。这是为我的 Wordpress 部署调整的内容。享受吧!

    container_commands:
      1_install_config_atop:
        command: /tmp/installatop.sh
    
    files:
      "/tmp/installatop.sh":
          mode: "000755"
          content : |
            #!/bin/bash
    
        #############################################
    
    
        ATOPLOGDEST=/var/app/current/wp-content/uploads/atop/   #where to persist the atop log
        LOGFILE=/tmp/atopinstall.log #installaton log
    
        ##############################################
        INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id/)
    
        exec 1>&- # close stdout
        exec 2>&- # close stderr
    
        echo "========" >> $LOGFILE
        date >> $LOGFILE
        echo "starting" >> $LOGFILE
    
        echo "---- Step 1, install atop" >> $LOGFILE
        echo "check if atop is installed" >> $LOGFILE
        rpm -q atop >> $LOGFILE
        if [ $? -ne 0 ]
        then
          echo "atop not installed yet" >> $LOGFILE
          rpm -i https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm
          rpm -q atop >> $LOGFILE
          echo "now installed" >> $LOGFILE
        fi
    
        echo "---- step 2, config atop in chkconfig" >> $LOGFILE
        /sbin/chkconfig --add atop
        /sbin/chkconfig atop on --level 235
        echo "this is the output of chkconfig"  >> $LOGFILE
        /sbin/chkconfig | grep atop >> $LOGFILE
    
        echo "---- setp 3, config atop's schedule to 60 seconds" >> $LOGFILE
        /bin/sed 's/600/60/' /usr/share/atop/atop.daily -i
        cat /usr/share/atop/atop.daily | grep "INTERVAL=" >> $LOGFILE
    
        echo "---- step 4, presistent it in EFS" >> $LOGFILE
        mkdir -p $ATOPLOGDEST$INSTANCEID
        /bin/sed "s|/var/log/atop|$ATOPLOGDEST$INSTANCEID|" /usr/share/atop/atop.daily -i
        cat /usr/share/atop/atop.daily | grep "LOGPATH=" >> $LOGFILE
        stat $ATOPLOGDEST$INSTANCEID >> $LOGFILE
    
        echo "---- step 5, restart atop" >> $LOGFILE
        /etc/init.d/atop restart
        sleep 5
        ps aux | grep atop >> $LOGFILE
    
        echo "---- finished!" >> $LOGFILE
        date >> $LOGFILE
        echo "========" >> $LOGFILE
    

    【讨论】:

    • 额外解释 - (有)...一个 CFN“错误”(eb deploy 将调用 cfn-hup 和 cfn-init 来运行容器命令),如果脚本涉及安装 RPM 包启动服务,cfn-init 将挂起。这是一个已知问题,解决方法是在脚本的开头将 STDOUT 和 STDERR 重定向到无 [1]。 ...这涉及存储在 ec2 实例上的 cfn-init 的 Python 源代码。这是解决方法。 exec 1>&- # 关闭标准输出 exec 2>&- # 关闭标准错误
    猜你喜欢
    • 2020-11-13
    • 2013-04-11
    • 2021-08-20
    • 2013-04-22
    • 2015-09-20
    • 2020-09-08
    • 1970-01-01
    • 2020-08-02
    • 2014-12-25
    相关资源
    最近更新 更多