
{"id":4176,"date":"2015-01-10T21:22:01","date_gmt":"2015-01-10T21:22:01","guid":{"rendered":"http:\/\/tapchicntt.com\/?p=4176"},"modified":"2015-01-10T02:33:36","modified_gmt":"2015-01-10T02:33:36","slug":"kiem-tra-luong-ram-da-su-dung-tren-linux","status":"publish","type":"post","link":"https:\/\/tapchicntt.com\/kiem-tra-luong-ram-da-su-dung-tren-linux\/","title":{"rendered":"Ki\u1ec3m tra l\u01b0\u1ee3ng RAM \u0111\u00e3 s\u1eed d\u1ee5ng tr\u00ean Linux"},"content":{"rendered":"<p>Ch\u00e0o c\u00e1c b\u1ea1n, c\u00f3 m\u1ed9t s\u1ed1 b\u1ea1n th\u1eafc m\u1eafc v\u1ec1 v\u1ea5n \u0111\u1ec1 VPS lu\u00f4n s\u1eed d\u1ee5ng full RAM, l\u01b0\u1ee3ng RAM tr\u1ed1ng l\u00fac n\u00e0o c\u0169ng r\u1ea5t \u00edt. Tuy nhi\u00ean, c\u00e1c b\u1ea1n \u0111\u00e3 xem th\u00f4ng tin RAM \u0111\u00fang c\u00e1ch ch\u01b0a? H\u00e3y tham kh\u1ea3o b\u00e0i vi\u1ebft b\u00ean d\u01b0\u1edbi.<br \/>\n<!--more--><br \/>\n\u0110\u1ec3 xem l\u01b0\u1ee3ng RAM \u0111\u00e3 s\u1eed d\u1ee5ng ch\u00fang ta c\u00f3 r\u1ea5t nhi\u1ec1u l\u1ec7nh kh\u00e1c nhau nh\u01b0:<\/p>\n<p><code>free -m<\/code><\/p>\n<p><code>cat \/proc\/meminfo<\/code><\/p>\n<p><code>top<\/code><\/p>\n<p><code>vmstat -s<\/code><\/p>\n<p>Tuy nhi\u00ean, th\u00f4ng s\u1ed1 MemFree tr\u1ea3 v\u1ec1 kh\u00f4ng ph\u1ea3i l\u00e0 l\u01b0\u1ee3ng b\u1ed9 nh\u1edb h\u1ec7 th\u1ed1ng c\u00f2n tr\u1ed1ng.<\/p>\n<p>B\u1edfi v\u00ec Total memory \u1edf Linux \u0111\u01b0\u1ee3c t\u00ednh b\u1eb1ng Active memory + Inactive memory (kh\u00f4ng t\u00ednh Swap). V\u1ea5n \u0111\u1ec1 \u1edf ch\u1ed7 Inactive memory, l\u00e0 v\u00f9ng nh\u1edb khi ta run 1 process v\u00e0 t\u1eaft \u0111i, system s\u1ebd cache l\u1ea1i v\u00f9ng nh\u1edb n\u00e0y \u0111\u1ec3 khi g\u1ecdi l\u1ea1i process n\u00e0y l\u1ea7n n\u1eefa, n\u00f3 s\u1ebd s\u1eed d\u1ee5ng v\u00f9ng nh\u1edb inactive n\u00e0y ngay l\u1eadp t\u1ee9c thay v\u00ec ph\u1ea3i c\u1ea5p ph\u00e1t l\u1ea1i. N\u00ean khi ta m\u1edf c\u00e0ng nhi\u1ec1u process, sau \u0111\u00f3 t\u1eaft \u0111i, inactive memory c\u00e0ng chi\u1ebfm nhi\u1ec1u.<\/p>\n<p>Khi m\u1edf l\u00ean 1 process m\u1edbi, n\u1ebfu h\u1ec7 th\u1ed1ng thi\u1ebfu RAM th\u00ec Linux s\u1ebd t\u1ef1 \u0111\u1ed9ng chuy\u1ec3n v\u00f9ng b\u1ed9 nh\u1edb Inactive v\u00e0o Swap v\u00e0 d\u00e0nh to\u00e0n b\u1ed9 memory cho active process. Nh\u01b0 v\u1eady, h\u1ec7 th\u1ed1ng kh\u00f4ng b\u1ecb qu\u00e1 t\u1ea3i.<\/p>\n<p>K\u1ebft lu\u1eadn, d\u1ea5u hi\u1ec7u \u0111\u1ec3 nh\u1eadn bi\u1ebft h\u1ec7 th\u1ed1ng c\u00f3 \u0111ang thi\u1ebfu RAM hay kh\u00f4ng \u0111\u00f3 l\u00e0 b\u1ea1n h\u00e3y nh\u00ecn v\u00e0o Swap, n\u1ebfu Swap s\u1eed d\u1ee5ng nhi\u1ec1u ch\u1ee9ng t\u1ecf \u0111ang b\u1ecb thi\u1ebfu RAM, l\u00fac n\u00e0y c\u1ea7n n\u00e2ng c\u1ea5p b\u1ed9 nh\u1edb cho VPS\/Server.<\/p>\n<p>Trong tr\u01b0\u1eddng h\u1ee3p kh\u00f4ng c\u00f3 swap, c\u00e1c b\u1ea1n h\u00e3y s\u1eed d\u1ee5ng l\u1ec7nh free -m v\u00e0 nh\u00ecn v\u00e0o d\u00f2ng th\u1ee9 3, -\/+ buffers\/cache \u0111\u1ec3 xem h\u1ec7 th\u1ed1ng \u0111ang th\u1ef1c s\u1ef1 free bao nhi\u00eau memory, ch\u1ee9 \u0111\u1eebng nh\u00ecn v\u00e0o d\u00f2ng s\u1ed1 2.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/3.bp.blogspot.com\/-7Hgzt_styjU\/VLCOJJwG6-I\/AAAAAAAAHqM\/XE_m-9Vj20I\/s1600\/kiem-tra-luong-ram-da-su-dung-tren-linux.png\" alt=\"Ki\u1ec3m tra l\u01b0\u1ee3ng RAM \u0111\u00e3 s\u1eed d\u1ee5ng tr\u00ean Linux\" \/><\/p>\n<p>Nh\u01b0 v\u00ed d\u1ee5 b\u00ean tr\u00ean, h\u1ec7 th\u1ed1ng c\u00f3 Total  2.070.944B RAM, m\u1edbi d\u00f9ng 867.584B v\u00e0 c\u00f2n s\u1eed d\u1ee5ng \u0111\u01b0\u1ee3c 1.203.360B n\u1eefa.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ch\u00e0o c\u00e1c b\u1ea1n, c\u00f3 m\u1ed9t s\u1ed1 b\u1ea1n th\u1eafc m\u1eafc v\u1ec1 v\u1ea5n \u0111\u1ec1 VPS lu\u00f4n s\u1eed d\u1ee5ng full RAM, l\u01b0\u1ee3ng RAM [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[173],"tags":[],"class_list":["post-4176","post","type-post","status-publish","format-standard","hentry","category-vps"],"views":406,"_links":{"self":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/4176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/comments?post=4176"}],"version-history":[{"count":0,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/posts\/4176\/revisions"}],"wp:attachment":[{"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/media?parent=4176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/categories?post=4176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tapchicntt.com\/rest-api\/wp\/v2\/tags?post=4176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}