8

甲骨文一键自动锻炼防止计算实例被回收

 2 years ago
source link: https://vpsxb.net/3924/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

甲骨文一键自动锻炼防止计算实例被回收 | VPS小白

> 网络资源 > 甲骨文一键自动锻炼防止计算实例被回收
202206191902179.png

整理自网络,请自行甄别使用


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

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的方法:



  1. apt -y update
  2. apt -y install curl build-essential
  3. curl -L http://www.devin.com/lookbusy/download/lookbusy-1.4.tar.gz -o lookbusy-1.4.tar.gz
  4. tar -xzvf lookbusy-1.4.tar.gz
  5. cd lookbusy-1.4/
  6. ./configure
  7. make install

新建systemd服务:



  1. systemctl edit --full --force lookbusy.service

写入如下配置:



  1. [Unit]
  2. Description=lookbusy service
  3. [Service]
  4. Type=simple
  5. ExecStart=/usr/local/bin/lookbusy -c 20 -m 5120MB
  6. Restart=always
  7. RestartSec=10
  8. KillSignal=SIGINT
  9. [Install]
  10. WantedBy=multi-user.target

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

启动并设置lookbusy开机自启:



  1. systemctl enable --now lookbusy.service

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

202302062306246.png

每天0点开始每3小时让 cpu 自动锻炼 600秒,一天锻炼8次共80分钟(负荷10%~20%),满足5%时间CPU利用率大于10%(每天至少72分钟),锻炼量可以根据自己情况随心调节

重新安装,请先卸载,不然会有两条定时记录 ⏲️,导致锻炼过度

一键锻炼:



  1. # AMD & ARM & CENTOS & DEBIAN & UBUNTU ALL IN ONE
  2. cd /root && wget https://raw.githubusercontent.com/velor2012/lookbusy-docker/main/lookbusy -O lookbusy && chmod +x lookbusy && sudo echo "0 */3 * * * root timeout 600 /root/lookbusy -c 10-20 -r curve" >> /etc/crontab && grep -q centos /etc/os-release && service crond restart || service cron restart

一键卸载:



  1. sed -i "/lookbusy/d" /etc/crontab && rm -f /root/lookbusy && grep -q centos /etc/os-release && service crond restart || service cron restart

1.gif

宝塔锻炼:
如果使用宝塔定时任务,就不用看前面的了,步骤如下:
1、在 shell 中执行下面命令,把 lookbusy 下载到 root 路径



  1. cd /root && wget https://raw.githubusercontent.com/velor2012/lookbusy-docker/main/lookbusy -O lookbusy && chmod +x lookbusy

2、在宝塔定时任务中配置如下图,脚本内容为



  1. timeout 600 /root/lookbusy -c 10-20 -r curve
202302062308390.png

3、在定时任务右下角可以测试执行,还能查看执行日志,非常直观好用

https://lala.im/8589.html

https://hostloc.com/thread-1132743-1-1.html


VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK