前言

最近甲骨文针对永久免费的资源出了个新的政策,具体看这里:

https://docs.oracle.com/en-us/iaas/Content/FreeTier/freetier_topic-Always_Free_Resources.htm

里面提到了如果计算实例长期空闲,可能会被回收:

  • Reclamation of Idle Compute Instances
  • Idle Always Free compute instances may be reclaimed by Oracle. Oracle will deem virtual machine and bare
  • metal compute instances as idle if, during a 7-day period, the following are true:
  • CPU utilization for the 95th percentile is less than 10%
  • Network utilization is less than 10%
  • Memory utilization is less than 10% (applies to A1 shapes only)

简单点说就是7天内,如果机器的cpu、内存、带宽使用率低于10%就视为是空闲的计算实例,可能会被回收。。。

我有2台免费的arm机器,确实一直放那里没怎么用,但是里面也跑了几个服务,只是这些服务都用不了多少资源,没办法为了机器不被回收,只能想办法把cpu、内存使用率再往上抬一抬。

这里介绍个小工具:lookbusy,这是一个linux系统负载生成器,可以根据你的配置来占用cpu、内存等资源。

以下是debian11编译安装lookbusy的方法:

apt -y update
apt -y install curl build-essential
curl -L http://www.devin.com/lookbusy/download/lookbusy-1.4.tar.gz -o lookbusy-1.4.tar.gz
tar -xzvf lookbusy-1.4.tar.gz
cd lookbusy-1.4/
./configure
make
make install

新建systemd服务:

systemctl edit --full --force lookbusy.service

写入如下配置:

[Unit]
Description=lookbusy service
 
[Service]
Type=simple
ExecStart=/usr/local/bin/lookbusy -c 20 -m 5120MB
Restart=always
RestartSec=10
KillSignal=SIGINT
 
[Install]
WantedBy=multi-user.target

参数-c指cpu使用率,-m指内存使用率。可以根据自己的实例配置来适当配置。

启动并设置lookbusy开机自启:

systemctl enable --now lookbusy.service

检查机器cpu、内存、负载情况,确定超过甲骨文规定的10%即可:

top

转自:https://lala.im/8589.html

Last modification:February 4, 2023
If you think my article is useful to you, please feel free to appreciate