AnolisOS 入门八:使用keentune(轻豚) 调优系统性能

Anolis 龙蜥社区https://openanolis.cn/轻豚主站https://openanolis.cn/sig/KeenTune

注意:使用keentune 前您应当对服务器硬件、Linux核心参数、网络通讯等知识领域有所了解

警告: 错误的使用调试工具,可能会使服务中断,请谨慎使用!

简介:

        性能调优,是一个将硬件、软件、操作系统融会贯通,将性能发挥到极致的过程。通常调校的目标是以用户的期望为依据,因此,调校的目标往往是符合用户的期盼即可。

1.安装:

       最低硬件要求:2核4G 10G可用磁盘空间

        这里使用dnf的方式,单机部署,有能力的同学可以使用源代码(git)编译的方式安装。       

#1.添加软件源
curl -o /etc/yum.repos.d/anolisos-experimental.repo  https://gitcode.net/-/snippets/1745/raw/master/anolisos-experimental.repo

#2.安装Keentune 相关软件
dnf install -y keentuned keentune-brain keentune-bench keentune-target

#3.安装依赖软件
dnf install -y python36 python36-devel go 


#4.pip切换国内源(可选)
mkdir ~/.pip
curl -o ~/.pip/pip.conf https://gitcode.net/-/snippets/1749/raw/master/pip.conf

#4.安装python3相关软件,注意:至少需要2G以上硬盘空间!!!
pip3 install --upgrade pip
pip3 install numpy==1.19.5 POAP==0.1.26 tornado==6.1 hyperopt==0.2.5 ultraopt==0.1.1 bokeh==2.3.2 requests==2.25.1 pySOT==0.3.3 scikit_learn==0.24.2 paramiko==2.7.2 PyYAML==5.4.1 pynginxconfig

#5.设置go 环境
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

二、启动

#1. 启动keentune相关服务
systemctl start keentuned keentune-brain keentune-target keentune-bench
 
#1. 查看服务状态
systemctl status keentuned keentune-brain keentune-target keentune-bench
 
#2.设置开机自动启动(可选)
systemctl enable keentuned keentune-brain keentune-target keentune-bench

使用 netstat -an | grep 98  确认从 9870-9874 的端口都已经开启 

注:如果有端口没有成功启动,请逐一对服务进行排查

三、简单使用

keentune 拥有两种性能调优模式,基于AI 的动态调优和基于预设场景的静态调优,这里我们选择静态调优继续:

通过 keentune profile list 可以看到,已经预设了5种使用场景

  1. cpu_high_load 高CPU负载
  2. io_high_throughput 高IO吞吐量
  3. mysql_tpcc MYSQL 的TPCC优化
  4. net_high_throuput 高网络吞吐量
  5. net_low_latency 网络低延迟
#查看帮助
keentune -h

#查看静态配置
keentune profile list

#查看指定配置的参数
keentune profile info --name cpu_high_load.conf

#使 cpu_high_load 配置生效
keentune profile set --name cpu_high_load.conf

设置成功后可以看到 [ok]状态,共有多少参数设置成功

使用sysctl -a  查看设置成功后的参数(此处以swappiness为例)

 注意:keentune 只是调整了运行值,重启后会恢复原值

恢复初始状态: 

# 恢复初始状态
keentune profile rollback

四、其他

1)手动调整预置场景参数

#目录下存放着所有预置场景的配置文件
/etc/keentune/profile 

上述目录存放着所有预置场景的配置文件,可以根据自己的经验、服务器配置对预设场景的参数进行手动调整 

2)使用网络预设场景时可能会遇到的问题

#应用 网络高负载或者 低延时场景时
#会遇到如下错误:

keentune profile set --name net_low_latency.conf
[ERROR] profile.Set failed, msg: Prepare before Set err:exec backup failed, err:response suc is false, msg is map[sysctl:sysctl: cannot stat /proc/sys/net/generic-receive-offload: No such file or directory]

 是因为配置文件中的如下参数造成的:

net.mtu: 1500
net.generic-receive-offload: off
net.generic-segmentation-offload: off
net.tcp-segmentation-offload: off

        由于在新的Linux 内核中 网卡的gro、gso、tso 设置已经交由 ethtool 工具来设置,解决方法如下:

        使用vi 等文本编辑工具,将 上述4条内容从 net_low_latency.conf 中删除,再执行如下命令:

#ethtool 关闭 gro gso tso,注:重启后会恢复默认值
#ethtool -K 网卡名称 命令
ethtool -K eth0 gro off 
ethtool -K eth0 gso off
ethtool -K eth0 tso off

#设置mtu 1500
echo "1500" > /sys/class/net/eth0/mtu

#启用策略
keentune profile set --name net_low_latency.conf

五、最后

        所谓前人种树后人白嫖,本文志在抛砖引玉,从官方文档可以看出基于AI的动态参数调整才是keentune 的核心价值所在。

参考文献:

https://openanolis.cn/sig/KeenTune

https://gitee.com/anolis/keentuned
https://gitee.com/anolis/keentune_bench
https://gitee.com/anolis/keentune_target
https://gitee.com/anolis/keentune_brain

____________________________________

2023-7-24 更新

原主站 http://keentune.io 已失效,切换到 KeenTune - OpenAnolis 龙蜥操作系统开源社区 

 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
搭建yum源是为了方便系统管理员进行软件包的管理和安装。在搭建yum源之前,我们需要一个可以作为服务器的机器,并且已经安装了Apache软件。 首先,我们需要下载所需的软件包,并将其放置在适当的位置。可以从官方网站上获取RPM包,也可以从其他渠道获取。下载好的软件包需要放置在一个统一的目录下,比如"/var/www/html/yum"。 接下来,我们需要配置Apache服务器,让其能够提供所需的软件包。可以通过编辑Apache配置文件来实现,该文件位于"/etc/httpd/conf/httpd.conf"。我们需要添加一些新的配置项,比如: Alias /yum /var/www/html/yum <Directory /var/www/html/yum> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> 然后,我们需要为每个软件包创建一个.repo文件,并将其放置在"/etc/yum.repos.d/"目录下。该文件中包含了软件包的详细信息和源码位置。可以使用任何文本编辑器来创建.repo文件。一个例子如下: [myrepo] name=My Yum Repository baseurl=http://your-server-ip/yum/ enabled=1 gpgcheck=0 确保将"your-server-ip"替换为你的服务器IP地址。 最后,我们需要更新yum缓存以使其能够读取新的源文件。可以运行以下命令: sudo yum clean all sudo yum makecache 现在,我们已经成功搭建了一个yum源。系统管理员可以使用yum命令来管理和安装软件包,并从自己的yum源中获取所需的软件。 总结起来,搭建yum源需要下载所需的软件包,配置Apache服务器,创建.repo文件并更新yum缓存。这样就可以方便地使用yum管理和安装软件包了。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值