【问题标题】:yum lock issue on amazon linux ec2亚马逊 linux ec2 上的 yum 锁定问题
【发布时间】:2021-06-13 07:39:38
【问题描述】:

我在由 aws datapipeline 启动的 amazon linux 服务器 (ami id-ami-0a887e401f7654935) 上使用这个 shell 命令。

#!/bin/bash

sudo yum install -y amazon-linux-extras
sudo amazon-linux-extras enable python3.8
sudo yum install -y python3.8
pip3.8 install --user pipenv
echo "PATH=$HOME/.local/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
aws s3 cp s3://bucketname/datapipeline/scriptfolder/ /home/ec2-user/ --recursive
mkdir -p /home/ec2-user/input
cd /home/ec2-user/
pipenv install --ignore-pipfile
echo "installation done"
pipenv run python3 main.py

每次我在运行几分钟后遇到错误。

errorMsg :    Memory :  46 M RSS (262 MB VSZ)
    Started: Tue Mar 16 01:47:44 2021 - 00:01 ago
    State  : Running, pid: 3746
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory : 139 M RSS (430 MB VSZ)
    Started: Tue Mar 16 01:47:44 2021 - 00:03 ago
    State  : Running, pid: 3746

我尝试在最后一个 echo 命令之后添加此 rm -f /var/run/yum.pid,但它给了我同样的错误。你能帮忙吗?

【问题讨论】:

  • 你还在面对这个问题吗?即使我在我的 ec2 实例上也面临同样的问题。
  • @Dev 我发布了一个不同的答案。我不知道它是否有帮助,但它解决了我所有的问题。

标签: linux amazon-web-services powershell amazon-ec2 yum


【解决方案1】:

我在这个确切的问题上苦苦挣扎:

Existing lock /var/run/yum.pid: another copy is running as pid 3114. Another app is currently holding the yum lock; waiting for it to exit...   The other application is: yum
    Memory :  31 M RSS (247 MB VSZ)
    Started: Thu Sep 23 21:42:19 2021 - 00:02 ago
    State  : Running, pid: 3114

我什至在我的用户数据中添加了调试:

#!/bin/bash
echo "## var run" > /tmp/yum.out 
ls -la /var/run/ >> /tmp/yum.out
echo "## contents of pid file" >> /tmp/yum.out 
cat /var/run/yum.pid >> /tmp/yum.out 
echo "## PS output" >> /tmp/yum.out 
ps -ef >> /tmp/yum.out
...

我通过该输出发现 A> 没有 /var/run/yum.pid 文件,并且 B> ps -ef 的输出中没有 pid 3114。本质上是一个幻像 pid。

经过大量的反复试验,我最终对我的用户数据进行了一次更改,为我完全解决了这个问题。我将 /bin/bash 更改为 /bin/sh。突然间一切都开始正常了。

【讨论】:

    【解决方案2】:

    获取 yum 的运行 PID,如果 PID 正在运行,则终止该 PID;

    ps aux|grep yum

    然后

    杀死 -9 PID

    【讨论】:

    • 如何获取 pid?实际上shell命令正在被DP执行,所以我们无法登录服务器。我需要动态获取PID然后杀死。有可能吗?
    猜你喜欢
    • 2015-10-15
    • 2014-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多