Therefore, we should avoid to reboot the server or reduce the number of times of reboot except planned shutdowns. But the question is, how to refresh the server to close to a newly startup one?
First of all, we should identify and know how to deal with the high-consuming services of memory in a web server.
- Restart httpd service.
- Restart mysqld service.
- Restart rsyslog service.
- Clear SWAP space.
[root@test ~]# free
total used free shared buffers cached
Mem: 2009040 1984816 24224 0 5136 349888
-/+ buffers/cache: 1629792 379248
Swap: 1048568 15032 1033536
Do the following actions:
[root@test ~]# service rsyslog restart; service httpd restart; service mysqld restart; swapoff -a; swapon -a
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
Let's see the memory after refreshing.
[root@test ~]# free
total used free shared buffers cached
Mem: 2009040 665392 1343648 0 12528 235104
-/+ buffers/cache: 417760 1591280
Swap: 1048568 0 1048568
This takes less than 5 seconds to complete. It's pretty fast.