如果有人能提供反馈或指出我正确的方向,我将不胜感激。当三个django站点以守护进程模式运行时,我无法在远程服务器上执行任何终端命令。我在一个或两个站点上使用嵌入模式时没有问题。当我输入命令时,我只得到“-bash:fork:无法分配内存”。
系统: Ubuntu 8:04 LTS远程虚拟云, 没有SWAP文件但是512 RAM(free,top和pc aux表示只使用了20%的内存), 用Putty访问, FTP与WINSCP, UFW防火墙设置, Apache 2.2.8,预分叉, mod-wsgi 2.3, sqlite db,
.conf文件,截至目前,守护进程已注释掉;
NameVirtualHost *:80
<VirtualHost *>
ServerAdmin webmaster@facts.com
ServerName helme.h1.net
DocumentRoot /home/helme/django/facts/apache/
DirectoryIndex index.html index.htm
ServerAlias helme.h1.net www.helme.h1.net
<Directory /home/helme/django/facts/apache/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/helme/django/facts/log/error.log
LogLevel info
CustomLog /home/helme/django/facts/log/access.log common
#WSGIDaemonProcess helme.h1.net user=www-data group=www-data processes=5 threads=1
#WSGIProcessGroup helme.h1.net
WSGIScriptAlias / /home/helme/django/facts/apache/django.wsgi
<Directory /home/helme/django/facts/apache/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@facts-pte.com
ServerName facts-pte.h1.net
DocumentRoot /home/pte/django/facts/apache/
DirectoryIndex index.html index.htm
ServerAlias facts-pte.h1.net www.facts-pte.h1.net
<Directory /home/pte/django/facts/apache/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/pte/django/facts/log/error.log
LogLevel info
CustomLog /home/pte/django/facts/log/access.log common
#WSGIDaemonProcess facts-pte.h1.net user=www-data group=www-data processes=5 threads=1
#WSGIProcessGroup facts-pte.h1.net
WSGIScriptAlias / /home/pte/django/facts/apache/django.wsgi
<Directory /home/pte/django/facts/apache/apache/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@facts.com
ServerName wuest.h1.net
DocumentRoot /home/wuest/django/wuest/apache/
DirectoryIndex index.html index.htm
ServerAlias wuest.h1.net www.wuest.h1.net
<Directory /home/wuest/django/wuest/apache/>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/wuest/django/wuest/log/error.log
LogLevel info
CustomLog /home/wuest/django/wuest/log/access.log common
WSGIDaemonProcess wuest.h1.net user=www-data group=www-data processes=5 threads=1
WSGIProcessGroup wuest.h1.net
WSGIScriptAlias / /home/wuest/django/wuest/apache/django.wsgi
<Directory /home/wuest/django/wuest/apache/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
哪个内存已满? 如果Apaceh作为'工人'加载mpm我会遇到同样的问题吗? 它是否像添加SWAP文件一样简单? 安装postgresql时,我会有更多的内存问题吗?
请注意我不是高级程序员或管理员,只管理正在处理Django项目的freind的远程服务器。
任何帮助将不胜感激。 亲切的问候 迈克尔
答案 0 :(得分:1)
好吧,运行没有交换空间的服务器(交换通常不是文件,而是Linux上的硬盘分区)是灾难的一个方法。添加一个几乎肯定会解决您的问题。
基本上,您在服务器上运行以分配所有可用RAM的情况并不少见。为了让您的服务器尽可能快地运行,我们希望获得服务器在RAM中可用的所有或尽可能多的信息。
为了解释虚拟内存的概念,只有512 MB RAM的服务器可能很容易将其RAM用完,但操作系统的内核需要有某种保留,因此总会有可用于分配的内存,例如(在您的情况下)登录的新用户需要启动像bash
这样的shell。
因此,如果服务器具有可用交换,即使所有物理内存都已使用,您也可以分配内存。通常,这会导致内核将一些很少访问的信息从RAM移动到交换,从而为您的新进程提供一些真实的物理内存。
但是如果内核没有可用的虚拟内存(RAM已满并且交换已满或缺失),则除了拒绝分配内存的请求之外没有其他选项。这将导致您无法登录的情况。
为了防止这种情况发生,目前的建议是创建一个比物理内存大两倍的交换空间(在这种情况下为1 GB),尽管在大多数情况下可能不需要超过4 GB。