麒麟操作系统(包括银河麒麟、中标麒麟等)作为国产主流Linux发行版,其性能监控与优化方法与其他Linux系统类似但也有自身特点。以下是系统性能监控和优化的全面方案:
top/htop:实时监控CPU、内存使用情况
top
htop # 需要先安装:sudo apt install htop
vmstat:监控系统整体性能
vmstat 1 # 每秒刷新一次
iostat:监控磁盘I/O
iostat -x 1
free:内存使用情况
free -h
sar:系统活动报告(需安装sysstat)
sudo apt install sysstat
sar -u 1 3 # CPU使用率
sar -r 1 3 # 内存使用
nmon:综合性能监控
sudo apt install nmon
nmon
dstat:多功能资源统计工具
sudo apt install dstat
dstat -cdngy
# 编辑sysctl.conf
sudo vim /etc/sysctl.conf
# 常见优化参数(根据实际情况调整)
vm.swappiness = 10 # 减少swap使用
vm.dirty_ratio = 10 # 减少脏页比例
vm.dirty_background_ratio = 5
net.ipv4.tcp_syncookies = 1 # 防止SYN洪水攻击
net.ipv4.tcp_max_syn_backlog = 8192
fs.file-max = 65535 # 增加文件描述符限制
# 使配置生效
sudo sysctl -p
# 查看启动服务
systemctl list-unit-files --type=service | grep enabled
# 禁用不必要的服务(根据实际情况)
sudo systemctl disable bluetooth.service
sudo systemctl disable cups.service
bash
# 编辑/etc/fstab
/dev/sda1 / ext4 defaults,noatime 0 1
bash
sudo apt install zram-config
sudo service zram-config restart
bash
# 在/etc/sysctl.conf中添加
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# 安装Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
tar xvfz prometheus-*.tar.gz
cd prometheus-*
# 配置并启动
./prometheus --config.file=prometheus.yml
国产CPU优化:针对飞腾、龙芯等国产CPU,使用特定内核参数
# 针对飞腾处理器的优化
echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
国产应用优化:针对WPS、微信等国产软件的专用优化参数
安全模块优化:合理配置安全模块(如SELinux)以减少性能开销
通过以上方法,您可以全面监控麒麟操作系统性能并进行有效优化。需要注意的是,优化应根据实际应用场景进行,避免过度优化导致系统不稳定。