解决thread.error: can’t start new thread错误

林继 VPS 知识 6,101 共写了482个字 (2012-07-16 16:49:24) 没有评论 打印 扫描二维码 百度未收录

最近偶然弄了一下VPS,在使用yum时出现一个错误,错误的详情如下:

  1. [dong@vm lnmp]# yum install system-config-date
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Traceback (most recent call last):
  5.   File "/usr/bin/yum", line 29, in ?
  6.     yummain.user_main(sys.argv[1:], exit_code=True)
  7.   File "/usr/share/yum-cli/yummain.py", line 309, in user_main
  8.     errcode = main(args)
  9.   File "/usr/share/yum-cli/yummain.py", line 178, in main
  10.     result, resultmsgs = base.doCommands()
  11.   File "/usr/share/yum-cli/cli.py", line 345, in doCommands
  12.     self._getTs(needTsRemove)
  13.   File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 101, in _getTs
  14.     self._getTsInfo(remove_only)
  15.   File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 112, in _getTsInfo
  16.     pkgSack = self.pkgSack
  17.   File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 662, in <lambda>
  18.     pkgSack = property(fget=lambda self: self._getSacks(),
  19.   File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 502, in _getSacks
  20.     self.repos.populateSack(which=repos)
  21.   File "/usr/lib/python2.4/site-packages/yum/repos.py", line 232, in populateSack
  22.     self.doSetup()
  23.   File "/usr/lib/python2.4/site-packages/yum/repos.py", line 79, in doSetup
  24.     self.ayum.plugins.run('postreposetup')
  25.   File "/usr/lib/python2.4/site-packages/yum/plugins.py", line 179, in run
  26.     func(conduitcls(self, self.base, conf, **kwargs))
  27.   File "/usr/lib/yum-plugins/fastestmirror.py", line 181, in postreposetup_hook
  28.     all_urls = FastestMirror(all_urls).get_mirrorlist()
  29.   File "/usr/lib/yum-plugins/fastestmirror.py", line 333, in get_mirrorlist
  30.     self._poll_mirrors()
  31.   File "/usr/lib/yum-plugins/fastestmirror.py", line 376, in _poll_mirrors
  32.     pollThread.start()
  33.   File "/usr/lib/python2.4/threading.py", line 416, in start
  34.     _start_new_thread(self.__bootstrap, ())
  35. thread.error: can't start new thread

出现这个错误的结果就是无法使用yum安装程序。在网络上找了一下,找到一个解决方法。(原文点击进入)
在一些廉价VPS上运行Yum时可能会出 现:”thread.error: can’t start new thread”的错误, 原因就是因为内存太小了,以至于导致在寻找最快镜像的时候内存不足。
发生的原因在于fastestmirror,而禁用fastestmirror就可以解决这个问题,具体的解决办法是将fastestmirror.conf中的enabled=1改成enabled=0。
在登录SSH之后,编辑/etc/yum/pluginconf.d/fastestmirror.conf文件:

vi /etc/yum/pluginconf.d/fastestmirror.conf

把把enabled从其中的把enabled=1改为enabled=0即可。
即修改为:

  1. [main]
  2. enabled=0
  3. verbose=0
  4. socket_timeout=3
  5. hostfilepath=/var/cache/yum/timedhosts.txt
  6. maxhostfileage=10
  7. maxthreads=15
  8. #exclude=.gov, facebook

再次使用yum时就正常了。

历史上的今天

7月
16

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

< >