Linux|centos7|终端录屏神器asciinema的部署和初步使用

简介: Linux|centos7|终端录屏神器asciinema的部署和初步使用

前言:

Linux下的录屏软件不是很多的,但最近在青云云计算官网无意中发现了一个Linux下的录屏神器,非常的nice,只是在分享方面比较弱。

下面将就centos7下如何部署asciinema,以及如何初步使用它做一个简单的介绍。

青云的演示地址:

在 Kubernetes 上最小化安装 KubeSphere

该软件的官方演示地址:

ai script usage examples - asciinema

一,

简介

asciinema 是一个自由开源的用于录制终端会话并将它们分享到网络上的解决方案。

当你在你的终端内运行 asciinema rec 来启动录像时,你输入命令的时候,终端内的所有输出都会被抓取。

当抓取停止时(通过按下 Ctrl-D 或输出 exit),抓取的输出将会被上传到 asciinema.org 的网站,并为后续的回放做准备。

Asciinema 项目由多个不同的完整的部分组成,比如 asciinema 命令行工具、asciinema.org API 和 JavaScript 播放器。

Asciinema 的灵感来自于 scriptscriptreplay 命令。

那么,这个软件的优势是实时录制,最重要的是可以与播放内容交互,例如,复制录屏里的文字等等。当然,可以基于此软件做运维审计,并且一些比较复杂的操作可以通过此软件录制后分享给需要的同事,使得各种操作更加的直观,一目了然。细节拉满

如果仔细看了上面的示例,我相信你会对它的特点有一个充分的了解,并且会喜欢上这个软件(魅力无法阻挡啊~~~~~~)。

#####附 ,据我的观察,asciinema这个软件是英国的,因为服务器好像是在英国。

二,

asciinema的安装部署

该软件是基于python运行的,而很不幸,Linux自带的Python2.7并不太符合。

该软件的安装方式非常的多,主流部署方式都支持,例如,yum,apt,brew,docker,pip等等,推荐的部署方式是pip,但我并不是特别推荐该方式,因为pip方式还是比较麻烦的。

本例是使用的centos7,因此,本文将以centos7下的yum部署为主。

yum的方式部署需要epel源和OS源,本文都采用阿里云的yum源来进行安装

1,

epel源

cat > /etc/yum.repos.d/eeel.repo <<EOF
[eoel]
name=epel
baseurl=https://mirrors.aliyun.com/epel-archive/7.7/x86_64/
enable=1
gpgcheck=0
EOF

2,

OS源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

3,

开始安装

可以看到安装了Python-3.6

[root@centos4 yum.repos.d]# yum install asciinema
Loaded plugins: fastestmirror
Repository 'local' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
中间省略了。。。。
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libtirpc-0.2.4-0.16.el7.x86_64                                                                                                                                            1/6 
  Installing : python3-setuptools-39.2.0-10.el7.noarch                                                                                                                                   2/6 
  Installing : python3-pip-9.0.3-8.el7.noarch                                                                                                                                            3/6 
  Installing : python3-3.6.8-19.el7_9.x86_64                                                                                                                                             4/6 
  Installing : python3-libs-3.6.8-19.el7_9.x86_64                                                                                                                                        5/6 
  Installing : asciinema-1.4.0-2.el7.noarch                                                                                                                                              6/6 
  Verifying  : libtirpc-0.2.4-0.16.el7.x86_64                                                                                                                                            1/6 
  Verifying  : asciinema-1.4.0-2.el7.noarch                                                                                                                                              2/6 
  Verifying  : python3-3.6.8-19.el7_9.x86_64                                                                                                                                             3/6 
  Verifying  : python3-setuptools-39.2.0-10.el7.noarch                                                                                                                                   4/6 
  Verifying  : python3-pip-9.0.3-8.el7.noarch                                                                                                                                            5/6 
  Verifying  : python3-libs-3.6.8-19.el7_9.x86_64                                                                                                                                        6/6 
Installed:
  asciinema.noarch 0:1.4.0-2.el7                                                                                                                                                             
Dependency Installed:
  libtirpc.x86_64 0:0.2.4-0.16.el7   python3.x86_64 0:3.6.8-19.el7_9   python3-libs.x86_64 0:3.6.8-19.el7_9   python3-pip.noarch 0:9.0.3-8.el7   python3-setuptools.noarch 0:39.2.0-10.el7  

三,

asciinema的初步使用

该命令的帮助:

[root@centos4 ~]# asciinema 
usage: asciinema [-h] [--version] {rec,play,upload,auth} ...
Record and share your terminal sessions, the right way.
positional arguments:
  {rec,play,upload,auth}
    rec                 Record terminal session
    play                Replay terminal session
    upload              Upload locally saved terminal session to asciinema.org
    auth                Manage recordings on asciinema.org account
optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
example usage:
  Record terminal and upload it to asciinema.org:
    asciinema rec
  Record terminal to local file:
    asciinema rec demo.json
  Record terminal and upload it to asciinema.org, specifying title:
    asciinema rec -t "My git tutorial"
  Record terminal to local file, "trimming" longer pauses to max 2.5 sec:
    asciinema rec -w 2.5 demo.json
  Replay terminal recording from local file:
    asciinema play demo.json
  Replay terminal recording hosted on asciinema.org:
    asciinema play https://asciinema.org/a/difqlgx86ym6emrmd8u62yqu8
For help on a specific command run:
  asciinema <command> -h

1,

录制一个片段并保存在本地,文件名称为test.json

########注:在录制的时候不能修改时间,否则JSON文件将不能正常结束,也就是文件损坏了,该文件不能播放,或者转出GIF图片了

[root@centos4 ~]# asciinema rec test.json
~ Asciicast recording started.
~ Hit Ctrl-D or type "exit" to finish.
[root@centos4 ~]# cd /opt/
[root@centos4 opt]# ls
containerd  harbor
[root@centos4 opt]# cd
[root@centos4 ~]# ls
123.gif  123.json  docker  docker-19.03.9.tgz  harbor  harbor-offline-installer-v1.5.0.tgz  kubesphere-images-v3.0.0  kubesphere_kiali_v1.38.tar  test.json
[root@centos4 ~]# ls
123.gif  123.json  docker  docker-19.03.9.tgz  harbor  harbor-offline-installer-v1.5.0.tgz  kubesphere-images-v3.0.0  kubesphere_kiali_v1.38.tar  test.json
[root@centos4 ~]# ls
123.gif  123.json  docker  docker-19.03.9.tgz  harbor  harbor-offline-installer-v1.5.0.tgz  kubesphere-images-v3.0.0  kubesphere_kiali_v1.38.tar  test.json
[root@centos4 ~]# rm -rf docker 
[root@centos4 ~]# time
real  0m0.000s
user  0m0.000s
sys 0m0.000s
[root@centos4 ~]# date
Wed Jun 28 08:09:45 CST 2023
[root@centos4 ~]# ntpdate ntp.aliyun.com
28 Jun 00:10:18 ntpdate[18369]: step time server 203.107.6.88 offset -28803.509938 sec
[root@centos4 ~]# #OK,录屏结束了!!!,此时是Ctrl+d 退出
[root@centos4 ~]# exit
~ Asciicast recording finished.

2,

将上面录制的名为test.json 的文件转换为GIF格式的图片:

[root@centos4 ~]# docker pull asciinema/asciicast2gif
Using default tag: latest
latest: Pulling from asciinema/asciicast2gif
7b8b6451c85f: Pull complete 
ab4d1096d9ba: Pull complete 
e6797d1788ac: Pull complete 
e25c5c290bde: Pull complete 
0d0a810f8aa3: Pull complete 
42065bcdfff8: Pull complete 
dd637d6e6d34: Pull complete 
d67f7d6bcade: Pull complete 
dc5855e21089: Pull complete 
118eab60d733: Pull complete 
837c1093fc9c: Pull complete 
274de556230c: Pull complete 
c465677e3bd4: Pull complete 
91b6be0aaeda: Pull complete 
0c13bd3587dc: Pull complete 
2af77900a905: Pull complete 
Digest: sha256:4ad3f3d913f59178ca69882431c3622cf9b7cd394e4f29e5ab31d4909033bdfc
Status: Downloaded newer image for asciinema/asciicast2gif:latest
docker.io/asciinema/asciicast2gif:latest
[root@centos4 ~]# docker run --rm -v $PWD:/data asciinema/asciicast2gif -s 2 -t solarized-dark test.json test.gif
==> Loading test.json...
==> Spawning PhantomJS renderer...
==> Generating frame screenshots...
==> Combining 32 screenshots into GIF file...
==> Done.

3,

转换成功的GIF图片:

4,

播放JSON格式的录制的文件 test.json

asciinema play test.json

5,

上传录制的文件到官网

[root@centos4 ~]# asciinema upload test.json 
View the recording at:
    https://asciinema.org/a/593546

打开浏览器,输入https://asciinema.org/a/593546 就可以看到录制的内容了

未完待续!!!!

目录
相关文章
|
3月前
|
NoSQL 关系型数据库 Linux
ERPNext 搭建教程:Linux 一键部署与维护
ERPNext 是一款开源免费的企业资源计划系统,适用于中小企业信息化管理。基于 Python 和 Frappe 框架开发,支持财务、销售、人力、库存等模块,具备高度可定制性。本文介绍如何通过 Websoft9 在 Linux 下快速部署 ERPNext,并提供环境配置、系统维护等实用建议,适合开发者和企业用户快速上手。
423 7
ERPNext 搭建教程:Linux 一键部署与维护
|
5月前
|
监控 Linux 应用服务中间件
Linux多节点多硬盘部署MinIO:分布式MinIO集群部署指南搭建高可用架构实践
通过以上步骤,已成功基于已有的 MinIO 服务,扩展为一个 MinIO 集群。该集群具有高可用性和容错性,适合生产环境使用。如果有任何问题,请检查日志或参考MinIO 官方文档。作者联系方式vx:2743642415。
1421 57
|
3月前
|
Java Linux 网络安全
Linux云端服务器上部署Spring Boot应用的教程。
此流程涉及Linux命令行操作、系统服务管理及网络安全知识,需要管理员权限以进行配置和服务管理。务必在一个测试环境中验证所有步骤,确保一切配置正确无误后,再将应用部署到生产环境中。也可以使用如Ansible、Chef等配置管理工具来自动化部署过程,提升效率和可靠性。
353 13
|
3月前
|
关系型数据库 Linux Nacos
Rocky Linux 部署 Docker 和 NACOS 实例
本文介绍在阿里云环境下基于 Rocky Linux 搭建 Docker 并部署 Nacos 的完整流程。涵盖 Docker 安装、镜像加速配置、网络设置及 MySQL 与 Nacos 容器的创建,适用于开发与生产环境。
455 0
|
5月前
|
Linux 网络安全 iOS开发
SecureCRT & SecureFX 9.6.3 for macOS, Linux, Windows - 跨平台的多协议终端仿真和文件传输
SecureCRT & SecureFX 9.6.3 for macOS, Linux, Windows - 跨平台的多协议终端仿真和文件传输
1281 4
SecureCRT & SecureFX 9.6.3 for macOS, Linux, Windows - 跨平台的多协议终端仿真和文件传输
|
5月前
|
Linux 应用服务中间件 nginx
在CentOS上部署Minikube教程
至此,您已成功在CentOS上部署并使用Minikube。您可以自由探索Kubernetes的世界,熟练配置和管理Kubernetes集群。
455 20
|
5月前
|
开发框架 Java 关系型数据库
在Linux系统中安装JDK、Tomcat、MySQL以及部署J2EE后端接口
校验时,浏览器输入:http://[your_server_IP]:8080/myapp。如果你看到你的应用的欢迎页面,恭喜你,一切都已就绪。
404 17
|
5月前
|
Java 关系型数据库 MySQL
在Linux操作系统上设置JDK、Tomcat、MySQL以及J2EE后端接口的部署步骤
让我们总结一下,给你的Linux操作系统装备上最强的军队,需要先后装备好JDK的弓箭,布置好Tomcat的阵地,再把MySQL的物资原料准备好,最后部署好J2EE攻城车,那就准备好进军吧,你的Linux军团,无人可挡!
125 18
|
4月前
|
Oracle 关系型数据库 Linux
MyEMS开源系统安装之CentOS/RHEL/Rocky/AlmaLinux/Oracle Linux
本指南介绍如何在CentOS/RHEL/Rocky/AlmaLinux/Oracle Linux服务器上部署MyEMS开源能源管理系统。内容涵盖系统准备、数据库配置、多个MyEMS服务(如myems-api、myems-admin、myems-modbus-tcp等)的安装与配置,以及Nginx服务器设置和防火墙规则调整。通过完成所有步骤,您将能够访问MyEMS Admin UI和Web UI,默认端口分别为8001和80,初始登录凭据已提供。
164 0