服务器的一点小Tweak
自己的土豆服务器本来配置就不怎么样(4C+2G),装了一堆乱七八糟的东西之后卡的飞起...(Jenkins/Nginx/iRedMail/Typecho...)
逼着我要优化一下了...
[email protected]:~# free -m
total used free shared buff/cache available
Mem: 1994 1709 94 17 190 126
Swap: 2047 283 1764
除了Nginx/iRedMail/MySQL其他也没跑什么东西...看了下内存占用
[email protected]:~# ps aux | head -1;ps aux |grep -v PID |sort -rn -k +4 | head -20
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
clamav 525 11.9 41.9 1187216 857852 ? Ssl 16:15 0:23 /usr/sbin/clamd --foreground=true
amavis 2464 0.2 4.8 167476 99752 ? S 16:15 0:00 /usr/sbin/amavisd-new (ch1-avail)
amavis 2463 0.2 4.8 167476 99768 ? S 16:15 0:00 /usr/sbin/amavisd-new (ch1-avail)
amavis 1785 1.3 3.7 167476 77476 ? Ss 16:15 0:02 /usr/sbin/amavisd-new (master)
mysql 630 0.3 3.2 2700112 67172 ? Ssl 16:15 0:00 /usr/sbin/mysqld
12000 2710 0.9 2.4 64516 49272 ? Sl 16:15 0:01 /usr/local/bin/python /usr/local/bin/gunicorn oj.wsgi --user server --group spj --bind 127.0.0.1:8080 --workers 4 --threatter 10000 --max-requests 1000000 --keep-alive 32
12000 2709 0.4 1.8 49108 38628 ? S 16:15 0:00 /usr/local/bin/python /usr/local/bin/gunicorn oj.wsgi --user server --group spj --bind 127.0.0.1:8080 --workers 4 --threatter 10000 --max-requests 1000000 --keep-alive 32
12000 2708 0.5 1.8 49112 38668 ? S 16:15 0:00 /usr/local/bin/python /usr/local/bin/gunicorn oj.wsgi --user server --group spj --bind 127.0.0.1:8080 --workers 4 --threatter 10000 --max-requests 1000000 --keep-alive 32
12000 2699 0.5 1.8 49100 38700 ? S 16:15 0:00 /usr/local/bin/python /usr/local/bin/gunicorn oj.wsgi --user server --group spj --bind 127.0.0.1:8080 --workers 4 --threatter 10000 --max-requests 1000000 --keep-alive 32
root 515 1.1 1.5 1972748 31084 ? Ssl 16:15 0:02 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
nobody 2819 0.6 1.5 48360 31632 ? Sl 16:15 0:01 /usr/local/bin/python /usr/local/bin/dramatiq --path . --processes 4 --threads 4 django_dramatiq.setup django_dramatiq.tas.tasks judge.tasks
nobody 2818 0.7 1.5 48292 31624 ? Sl 16:15 0:01 /usr/local/bin/python /usr/local/bin/dramatiq --path . --processes 4 --threads 4 django_dramatiq.setup django_dramatiq.tas.tasks judge.tasks
nobody 2817 0.7 1.5 48420 31616 ? Sl 16:15 0:01 /usr/local/bin/python /usr/local/bin/dramatiq --path . --processes 4 --threads 4 django_dramatiq.setup django_dramatiq.tas.tasks judge.tasks
nobody 2816 0.6 1.5 48216 31620 ? Sl 16:15 0:01 /usr/local/bin/python /usr/local/bin/dramatiq --path . --processes 4 --threads 4 django_dramatiq.setup django_dramatiq.tas.tasks judge.tasks
root 514 0.7 0.8 1481644 17500 ? Ssl 16:15 0:01 /usr/bin/containerd
root 509 0.8 0.8 989136 18300 ? Ssl 16:15 0:01 /usr/bin/python3 /usr/bin/fail2ban-server -xf start
root 501 0.9 0.8 119664 18352 ? Ssl 16:15 0:01 /usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
root 2495 0.1 0.8 92952 18356 ? S 16:15 0:00 /usr/bin/python3 /usr/local/bin/gunicorn --workers 8 --threads 8 --error-logfile /log/gunicorn.log --time 600 --bind 0.0.
root 2493 0.1 0.8 92984 18380 ? S 16:15 0:00 /usr/bin/python3 /usr/local/bin/gunicorn --workers 8 --threads 8 --error-logfile /log/gunicorn.log --time 600 --bind 0.0.
root 2491 0.1 0.8 92948 18376 ? S 16:15 0:00 /usr/bin/python3 /usr/local/bin/gunicorn --workers 8 --threads 8 --error-logfile /log/gunicorn.log --time 600 --bind 0.0
一个ClamAV吃了800M的内存...而且作用还不是很大,想想办法把它清掉算了
iRedMail官方论坛上面已经有人问过了:
A solution to ClamAV consuming too much memory
- In /etc/amavis/conf.d/50-user, find the following:
@av_scanners = (
#### http://www.clamav.net/
['ClamAV-clamd',
\&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.ctl"],
qr/\bOK$/, qr/\bFOUND$/,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
@av_scanners_backup = (
### http://www.clamav.net/ - backs up clamd or Mail::ClamAV
['ClamAV-clamscan', 'clamscan',
"--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
- Comment out the ClamAV-clamd block, and copy the ClamAV-clamscan block from @av_scanners_backup into @av_scanners, like this:
@av_scanners = (
#### http://www.clamav.net/
#['ClamAV-clamd',
#\&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd.ctl"],
#qr/\bOK$/, qr/\bFOUND$/,
#qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
### http://www.clamav.net/ - backs up clamd or Mail::ClamAV
['ClamAV-clamscan', 'clamscan',
"--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
@av_scanners_backup = (
### http://www.clamav.net/ - backs up clamd or Mail::ClamAV
['ClamAV-clamscan', 'clamscan',
"--stdout --disable-summary -r --tempdir=$TEMPBASE {}", [0], [1],
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);
然后删掉/etc/rc2.d/K01clamav-freshclam
,新建一个/etc/cron.d/clamav-freshclam
,实现每4个小时扫描一次:
# /etc/cron.d/clamav-freshclam
# freshen signatures every 4 hours
23 0,4,8,12,16,20 * * * clamav /etc/init.d/clamav-freshclam no-daemon
再把sysctl的swap参数调一下:(来源:Understanding vm.swappiness)
vm.swappiness=1
The value of 60 is a compromise that works well for modern desktop
- A smaller value is a recommended option for a server system,
- As the Red Hat Performance Tuning manual points out, a
- swappiness value is recommended for database workloads. For
example, for Oracle databases, Red Hat recommends a swappiness value
of 10. In contrast, for MariaDB databases, it is recommended to set
swappiness to a value of 1.
操作了一下现在轻松多了:
[email protected]:~# free -m
total used free shared buff/cache available
Mem: 1994 527 943 10 523 1308
Swap: 2047 693 1354
Patoto server now fast again!
respond-post-10
vegas slots online http://onlinecasinouse.com/# - play casino free casino slot games casino game online casino slots