相信很多人遇到用top看明明就沒有程式用記憶體很兇,但是記憶體還是被用光了
怎麼辦呢?
http://blog.chinaunix.net/u/27173/showart_467689.html
http://blog.yesican.tw/?p=912
其實就是linux為了提高disk IO的存取效率,所以有cache pagecache, dentries and inodes
怎麼free呢
#free
#sync
#echo 3 > /proc/sys/vm/drop_caches
#echo 0 > /proc/sys/vm/drop_caches
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
-----------------------------------------------------------------
Update
http://ssorc.tw/rewrite.php/read-599.html
這篇對於linux memory usage有更詳細的說明
節錄buffer and cache的說明~~~^^
Free中的buffer和cache︰(它們都是佔用內存)︰
buffer : 作為buffer cache的內存,是塊設備的讀寫緩沖區
cache: 作為page cache的內存, 文件系統的cache
如果 cache 的值很大,說明cache住的文件數很多。如果頻繁訪問到的文件都能被cache住,那麼磁盤的讀IO bi會非常小。
Read more: http://ssorc.tw/rewrite.php/read-599.html#ixzz0gbxRjPrV
------------------------------------------------------------------------
[Update]
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
但這一篇就在說明ps很不準,別看ps的memory usage
星期二, 12月 29, 2009
星期一, 12月 21, 2009
[Linux] logrotate setup and test
如果要利用logrotate幫你rotate log,請在加入一個file在/etc/logrotate.d/下面
# vim /etc/logrotate.d/aaa
content:
/var/log/aaa {
daily
ifempty
rotate 7
}
# service syslog restart
如何知道設定對不對,請打
# logrotate /etc/logrotate.conf
至於有那些可以設定,請man logrotate嚕
# vim /etc/logrotate.d/aaa
content:
/var/log/aaa {
daily
ifempty
rotate 7
}
# service syslog restart
如何知道設定對不對,請打
# logrotate /etc/logrotate.conf
至於有那些可以設定,請man logrotate嚕
[linux] Too many open files
想知道自己某個程式的開啟檔案數,可以用以下的指令察看:
lsof -p [pid of your process] | wc -l
如果想調大檔案開啟數,可以調整fs.file-max這個核心參數。如果memory夠大,可以將此值加大到65536,或是更大:調整的方式:
在/etc/rc.local中加入echo 65536 > /proc/sys/fs/file-max
或是
在sysctl.conf中加入fs.file-max=65536
不過單修改核心參數只能加大系統核心的上限,Linux本身還有針對每個user的每個程式本身的限制,因此還需要編輯/etc/security/limits.conf,並加入
* soft nofile 4096
* hard nofile 4096
修改完畢之後,重新開機即可!
lsof -p [pid of your process] | wc -l
如果想調大檔案開啟數,可以調整fs.file-max這個核心參數。如果memory夠大,可以將此值加大到65536,或是更大:調整的方式:
在/etc/rc.local中加入echo 65536 > /proc/sys/fs/file-max
或是
在sysctl.conf中加入fs.file-max=65536
不過單修改核心參數只能加大系統核心的上限,Linux本身還有針對每個user的每個程式本身的限制,因此還需要編輯/etc/security/limits.conf,並加入
* soft nofile 4096
* hard nofile 4096
修改完畢之後,重新開機即可!
星期五, 12月 11, 2009
[Linux] How to setup reposity on Centos and RHEL.
http://doc.linuxpk.com/58088.html
我寫下簡單的command
1. mkdir /centos.source/5.3/
mkdir /RHEL.source/5.2/
2. centos
15 5 * * * rsync -aqzH --delete msync.centos.org::CentOS/5.3 /cent.source/
RHEL
cp RHEL_source /RHEL.source/5.2/
3. centos
vim /etc/httpd/conf.d/cent.mirror.conf
content:
Alias /CentOS "/cent.source/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
RHEL
vim /etc/httpd/conf.d/RHEL.mirror.conf
content:
Alias /RHEL "/RHEL.source/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
4. RHEL
mv /RHEL.source/5.2/Server/repodata /RHEL.source/5.2/Server/backup_repodata
yum install createrepo 或 rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
mkdir /RHEL.source/5.2/Server/repodata
cd /RHEL.source/5.2/Server/repodata
createrepo -g /RHEL.source/5.2/Server/backup_repodata/comps-rhel5-server-core.xml /RHEL.source/5.2/Server
5. centos
cd /etc/yum.repos.d/
vim CentOS-Base.repo
content:
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://xxxxxxx/CentOS/5.3/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
RHEL
cd /etc/yum.repos.d/
vim rhel-5.2.repo
content:
[rhel-5.2]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=http://xxxxxxx/RHEL/5.2/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
6. wget http://xxxxxxx/CentOS/5.3/os/$basearch/
wget http://xxxxxxx/RHEL/5.2/Server
Done
我寫下簡單的command
1. mkdir /centos.source/5.3/
mkdir /RHEL.source/5.2/
2. centos
15 5 * * * rsync -aqzH --delete msync.centos.org::CentOS/5.3 /cent.source/
RHEL
cp RHEL_source /RHEL.source/5.2/
3. centos
vim /etc/httpd/conf.d/cent.mirror.conf
content:
Alias /CentOS "/cent.source/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
RHEL
vim /etc/httpd/conf.d/RHEL.mirror.conf
content:
Alias /RHEL "/RHEL.source/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
4. RHEL
mv /RHEL.source/5.2/Server/repodata /RHEL.source/5.2/Server/backup_repodata
yum install createrepo 或 rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
mkdir /RHEL.source/5.2/Server/repodata
cd /RHEL.source/5.2/Server/repodata
createrepo -g /RHEL.source/5.2/Server/backup_repodata/comps-rhel5-server-core.xml /RHEL.source/5.2/Server
5. centos
cd /etc/yum.repos.d/
vim CentOS-Base.repo
content:
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://xxxxxxx/CentOS/5.3/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
RHEL
cd /etc/yum.repos.d/
vim rhel-5.2.repo
content:
[rhel-5.2]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=http://xxxxxxx/RHEL/5.2/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
6. wget http://xxxxxxx/CentOS/5.3/os/$basearch/
wget http://xxxxxxx/RHEL/5.2/Server
Done
訂閱:
文章 (Atom)