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

刚刚在给CentOS(VPS,kloxo,LNMP)安装sendmail组件的时候,遇到了thread.error: can’t start new thread错误,内容如下:

login as: root
Access denied
[email protected]’s password:
Last login: Sun Jan 22 02:10:45 2012 from 111.76.75.59
[root@10_23 ~]# yum install sendmail
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
File “/usr/bin/yum”, line 29, in ?
yummain.user_main(sys.argv[1:], exit_code=True)
File “/usr/share/yum-cli/yummain.py”, line 309, in user_main
errcode = main(args)
File “/usr/share/yum-cli/yummain.py”, line 178, in main
result, resultmsgs = base.doCommands()
File “/usr/share/yum-cli/cli.py”, line 345, in doCommands
self._getTs(needTsRemove)
File “/usr/lib/python2.4/site-packages/yum/depsolve.py”, line 101, in _getTs
self._getTsInfo(remove_only)
File “/usr/lib/python2.4/site-packages/yum/depsolve.py”, line 112, in _getTsInfo
pkgSack = self.pkgSack
File “/usr/lib/python2.4/site-packages/yum/init.py”, line 662, in
pkgSack = property(fget=lambda self: self._getSacks(),
File “/usr/lib/python2.4/site-packages/yum/init.py”, line 502, in _getSacks
self.repos.populateSack(which=repos)
File “/usr/lib/python2.4/site-packages/yum/repos.py”, line 232, in populateSack
self.doSetup()
File “/usr/lib/python2.4/site-packages/yum/repos.py”, line 79, in doSetup
self.ayum.plugins.run(‘postreposetup’)
File “/usr/lib/python2.4/site-packages/yum/plugins.py”, line 179, in run
func(conduitcls(self, self.base, conf, **kwargs))
File “/usr/lib/yum-plugins/fastestmirror.py”, line 181, in postreposetup_hook
all_urls = FastestMirror(all_urls).get_mirrorlist()
File “/usr/lib/yum-plugins/fastestmirror.py”, line 333, in get_mirrorlist
self._poll_mirrors()
File “/usr/lib/yum-plugins/fastestmirror.py”, line 376, in _poll_mirrors
pollThread.start()
File “/usr/lib/python2.4/threading.py”, line 416, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can’t start new thread

[root@10_23 ~]#

在一些廉价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即可。

[main]
enabled=0
verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
maxthreads=15

#exclude=.gov, facebook
再次运行yun install sendmail就可以成功安装了:
[root@10_23 ~]# yum install sendmail
addons | 951 B 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
lxlabslxupdate | 951 B 00:00
lxlabsupdate | 951 B 00:00
lxlabsupdate/primary | 74 kB 00:00
lxlabsupdate 210/210
updates | 1.9 kB 00:00
updates/primary_db | 488 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package sendmail.i386 0:8.13.8-8.1.el5_7 set to be updated
–> Processing Conflict: qmail conflicts sendmail
–> Finished Dependency Resolution
qmail-1.03-1.5.15.i386 from installed has depsolving problems
–> qmail conflicts with sendmail
Error: qmail conflicts with sendmail
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.
[root@10_23 ~]#

至此,成功的解决了thread.error: can’t start new thread错误。(for CentOS,kloxo,当然,也适用于LNMP一键安装包)