惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

思有云 - IOIOX - 运维部署

甲骨文云 Oracle Cloud 引导卷扩展和块存储卷挂载 - 思有云 甲骨文云 Oracle Cloud 解决 ARM 服务器安装军哥 LNMP 环境的几个问题 - 思有云 PostgreSql 14 主从负载均衡部署记录 - 思有云 drone ci 工作流语法变量高级使用教程 - 思有云 部署 MinIO 通用 S3 协议对象存储服务当网盘和图床使用 - 思有云 Bark 推送服务的部署和使用小技巧 - 思有云 - IOIOX 分享三种常用的 drone 工作流 CI 配置 - 思有云 Docker 安装 Gitea + Drone 开源代码仓库及 CI/CD 教程 - 思有云 Docker Compose 部署监控系统 Prometheus + Grafana + Node Exporter + Cadvisor - 思有云
甲骨文云 Oracle Cloud 服务器防回收保活 docker 命令 - 思有云
博主: Stille · 2024-01-19 · via 思有云 - IOIOX - 运维部署

简介

近期甲骨文出台了政策,将对闲置的服务器进行停机或者回收处理,为了防止被删,网上各路大神也出了很多教程来让服务器高负载,不过大多数都是试用 shell 脚本循环计算,dd 复制空文件或者一些类似 lookbusy 等第三方软件来模拟高负载。

不过作为洁癖党,总是会避免安装一些不太了解的第三方软件,也但是一些脚本后台运行出问题,或者时间长了忘记了,所以还是觉得把脚本跑在 docker 里最合适,也最方便管理。可以做到想开就开,想关就关,还可以配合 crontab 定时开关。

更多甲骨文云 Oracle Cloud 相关技巧,教程及信息,请持续关注甲骨文云 Oracle Cloud 系列文章汇总:

本文为 Stille 原创文章.经实践,测试,整理发布.如需转载请联系作者获得授权,并注明转载地址.


教程

原理很简单,就是写了一段最简单的循环计算 shell 脚本,在 alpine 容器内部执行。只需要控制 docker 的启动和停止即可。

注意:本服务脚本仅占用 CPU 资源,甲骨文政策大概率满足其一即可。

CPU 占用效果

启动此容器后 CPU 占用大致效果图

docker

启动命令

docker run -d --name keeporaclealive --rm alpine sh -c "while true; do for i in {1..100000}; do j=$((i*i)); done; done"

停止命令

docker stop keeporaclealive

注意:上述启动命令加入了--rm参数,停止容器将自动删除容器,不会残留到系统中。

docker 常驻

启动命令

docker run -d --name keeporaclealive --restart always alpine sh -c "while true; do for i in {1..100000}; do j=$((i*i)); done; done"

上述命令将容器常驻,即使服务器重启也会自动启动服务。

停止命令

docker stop keeporaclealive
# 停止服务,容器不会被删除。
docker start keeporaclealive
# 再次启动容器。
docker rm keeporaclealive
# 停止后彻底删除容器。

docker compose

同时也可以用 docker compose 来管理,这样启动和停止命令会更加方便。

mkdir keeporaclealive
cd keeporaclealive
vi docker-compose.yml
# 创建 keeporaclealive 目录并新建 docker-compose.yml 文件,复制以下配置文件。

docker-compose.yml

version: '3'
services:
  keeporaclealive:
    image: alpine
    command: 'sh -c "while true; do for i in $$(seq 1 100000); do j=$$[i*i]; done; done"'
    restart: always

启动和停止可以用以下命令控制:

docker-compose up -d
# 启动
docker-compose down
# 停止

crontab 定时任务,每日 10 点启动,每日 14 点停止。
根据自身情况修改 /root/keeporaclealive 目录地址

crontab -e
# 添加以下两条记录
0 10 * * * cd /root/keeporaclealive && /usr/local/bin/docker-compose up -d
0 14 * * * cd /root/keeporaclealive && /usr/local/bin/docker-compose down

结语

更多甲骨文云 Oracle Cloud 相关技巧,教程及信息,请持续关注甲骨文云 Oracle Cloud 系列文章汇总:


晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. 晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。
RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。

赞赏作者

如果喜欢我的文章,觉得对你有帮助,请随意赞赏!