Skip to content

Commit

Permalink
libvirt zfs
Browse files Browse the repository at this point in the history
  • Loading branch information
huataihuang committed Nov 8, 2023
1 parent 5da87a3 commit b2c3b76
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 19 deletions.
58 changes: 48 additions & 10 deletions source/android/install/lineageos_apps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,66 @@
LineageOS 应用
=====================

我尝试在精简的LineageOS环境使用 :ref:`pixel_4` :
我尝试在精简的LineageOS环境使用 :ref:`pixel_4`

初始安装
==========
LineageOS自带应用
==================

LineageOS的初始安装非常精简,只有少量必须的应用

应用安装
==========
- Music非常简洁,但是使用有点特殊:

- 暂时不安装 Google Apps ,只在自己需要的应用官方网站下载各自软件包(我使用的软件极少)
- 同步音乐是存放到 ``Download`` 目录(以及子目录) ( ``adb push * /sdcard/Music`` 到 Music 目录下不能自动识别 ): ( `LOS Default Music Player doesn't find my mp3 audio <https://www.reddit.com/r/LineageOS/comments/urjvsj/comment/i8yk5nm/>`_ )
- 文件同步后,需要重启一次 Music 就能够识别

- Camera只有基本功能,虽然够用但是无法充分发挥pixel的 ``计算摄影`` 优势,所以替换为使用 Google Camera

安装Google apps
================

我最初想避免安装Google apps:

- 我担心Google全家桶实际上我并不需要这么多软件(之前使用Google Android 13官方镜像,默认安装了太多的狗家程序)
- 只想用最少的资源来运行一个简洁的ASOP系统

不过,经过短暂的尝试,我放弃上述想法,还是在 :ref:`lineageos_20_pixel_4` 后,再次 ``sideload`` 刷入 ``MindTheGapps`` :

- LineageOS只有非常简单的相机功能,实际上无法发挥出Pixel的摄影性能: 毕竟Google只针对Pixel系列优化了自己的摄影算法,其他手机都无法享用
- 难以找到合适的方式安装 :ref:`kindle` for Android,毕竟我主要的手机功能就是看书
- 需要使用Google的一些服务: Photos, keep, fit, youtube ... 缺乏基础服务的Android系统虽然轻量级,但是使用确实不便

LineageOS 使用的 ``MindTheGapps`` 默认只安装 Google Play Store 和 Google ,所以还算比较精简。

.. note::

有些应用WEB实际上非常流畅,所以可以不用单独安装程序,直接使用WEB即可:

- YouTube
- Twitter

非Google Play Store的应用
==========================

- `微信官网应用下载 <https://weixin.qq.com>`_ 国民应用,如果不想失去社交的话还是得安装。微信现在也臃肿了,所以要在设置中把所有不需要的功能开关都关闭掉
- `支付宝官网应用下载 <https://alipay.com/>`_ 一定要开启极速模式,并且关闭所有页面功能
- `KOReader <https://f-droid.org/en/packages/org.koreader.launcher.fdroid/>`_ 非常轻量级的电子书阅读器,比 :ref:`kindle` 快捷(自己维护电子书同步)
- `脉脉 <https://maimai.cn/>`_
- `高德地图 <https://mobile.amap.com/>`_


应用安装(尝试后放弃这种精简方式)
=================================

- :strike:`暂时不安装 Google Apps ,只在自己需要的应用官方网站下载各自软件包(我使用的软件极少)`

- `微信官网应用下载 <https://weixin.qq.com>`_
- `支付宝官网应用下载 <https://alipay.com/>`_
- 高德地图
- :strike:`大众点评` 使用微信小程序

- Amazone AppStore: 由于一些商业软件找到,或许可以从Amazone AppStore获得(Amazone的应用商店安装包只有16MB,依赖较少)

- kindle
- :strike:`Amazone AppStore` : 我最初想采用Amazone AppStore获得(Amazone的应用商店安装包只有16MB,依赖较少)软件,但是实践发现并不适合LineageOS

遇到一个问题 Amazone AppStore 会检查Android版本,但是LineageOS不能识别,所以导致无法安装兼容版本。有什么方法模拟成 Android 13?
- kindle: 无法识别LineageOS,所以会以不兼容理由拒绝安装

- `F-Droid <https://f-droid.org/>`_ 开源应用商店,不过我没有安装(网站提供了开放的直接下载应用,我只选择需要的应用安装)

Expand Down
1 change: 1 addition & 0 deletions source/kubernetes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ kubernetes管理了容器规模,从边缘计算的微小集群到数据中心
gpu/index
kubeflow/index
argo/index
kueue/index
k8s_android/index
k3s/index
platform/index
Expand Down
10 changes: 10 additions & 0 deletions source/kubernetes/kueue/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _kueue:

=========================================
Kueue - K8s原生批处理调度
=========================================

.. toctree::
:maxdepth: 2

intro_kueue.rst
33 changes: 33 additions & 0 deletions source/kubernetes/kueue/intro_kueue.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. _intro_kueue:

==================
Kueue简介
==================

批处理管理缘起
================

早期的Kubernetes专注于微服务工作负载调度,随着Kubernetes发展已经逐步进入HPC(高性能计算)领域,提供了构建批处理平台的强大而灵活的工具。这种转变是由于 :ref:`machine_learning` 不断增长的训练需求,以及高性能计算(HPC)系统向云转变的引发。

PGS在2022年Google Cloud Next ’22上宣布采用Google Cloud Platform构建了相当于世界排名第七的超级计算机, `使用1.2M vCPU运行在云端和Spot VM替代本地Cray超级计算机 <https://www.pgs.com/company/newsroom/news/industry-insights--hpc-in-the-cloud/?utm_source=thenewstack&utm_medium=website&utm_content=inline-mention&utm_campaign=platform>`_ 。

:ref:`big_data` 和 :ref:`machine_learning` 领域,采用批处理工作负载的用户通常依赖 Slurm, Mesos, HTCondor 或 Nomad 这些框架,为批处理任务提供必要的功能和扩展性。但是这些框架缺乏Kubernetes的提供的充满活力的生态系统(vibrant ecosystem),社区支持以及集成功能。现在Kubernetes社区投入大量资源,组建批处理工作组(Batch Working Group)致力于增强Kubernetes的批处理功能里。

Batch Working Group对Job API进行大量改进,使其支持更广泛的批处理工作负载。改进后的API允许用户管理批处理作业,提供可扩展性、性能和可靠性增强。

Kueue项目
===========

`Kueue作业调度系统 <https://kueue.sigs.k8s.io/>`_ 是Batch Working Group开发的专为Kubernetes批处理工作负载而设计,提供Job优先级(job prioritization)、回填(backfilling)、资源风格编排(resource flavors orchestration)和抢占(preemption),以确保高效、及时地处理批处理作业,同时保持资源使用效率最大化。

Kueue正在致力于构建与 :ref:`kubeflow` , Ray, :ref:`spark` 和 :ref:`airflow` 等各种框架的集成。这些集成使得用户能够利用Kubernetes的强大功能和灵活性,同时利用这些框架的专业能力,从而创建无缝且高效的批处理体验。

此外,Kueue还计划提供增强功能,包括自动缩放的作业级配置API(job-level provisioning APIs in autoscaling),嗲赌气插件、节点运行时增强等。

Kubernetes广泛的多租户、丰富的生态以及主要云计算厂商托管服务使得其成为寻求批处理任务优化和充分利用云计算的最佳选择。目前在批处理领域,有不同的框架以及方式实现通用概念(作业、作业组、作业队列)。未来可能会更快的发展,所以研究和学习 ``Kueue`` 项目,会对未来 :ref:`machine_learning` 发展有很大的助力。


参考
======

- `Kubernetes Evolution: From Microservices to Batch Processing Powerhouse <https://thenewstack.io/kubernetes-evolution-from-microservices-to-batch-processing-powerhouse/>`_
97 changes: 95 additions & 2 deletions source/kvm/libvirt/storage/libvirt_zfs_pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,103 @@ libvirt ZFS存储池
:ref:`arch_linux` 的 ``X86_64`` 架构对 :ref:`zfs` 和 :ref:`stratis` 都有良好支持,所以我计划:

- 在MacBook Pro 2013笔记本上同时采用这两种存储技术来构建 ``libvit`` 存储后端
- 在 :ref:`priv_cloud_infra` 上利用3块旧的HDD构建ZFS扩展 ``libvit`` 存储后端
- 在 :ref:`priv_cloud_infra` 上利用3块旧的HDD构建ZFS扩展 ``libvit`` 存储后端 (感觉性能会比较差,所以考虑这个ZFS存储作为离线数据存储)
- 在 :ref:`priv_cloud_infra` 使用购买的二手SSD磁盘 :ref:`sandisk_cloudspeed_eco_gen_ii_sata_ssd` 构建ZFS存储池提供虚拟机集群模拟

.. note::

libvirt ZFS存储池 非常类似 :ref:`libvirt_lvm_pool` ,基于卷来管理虚拟机的存储分配和隔离,是适合大型云计算的基础存储方案。虽然没有 :ref:`ceph_rbd_libvirt` 方案提供了分布式存储的容灾和高可用,但是非常适合构建低成本 spot vm 的存储。通过 ZFS 强大的海量存储管理能力,精简掉RAID功能,使用基础的卷管理能力来实现。

准备工作
=========

- SSD磁盘 :ref:`sandisk_cloudspeed_eco_gen_ii_sata_ssd` 已经在 :ref:`zfs_startup_zcloud` 已经构建了一个基础ZFS pool ``zpool-data`` :

.. literalinclude:: ../../../linux/storage/zfs/admin/zfs_startup_zcloud/zpool_create
:caption: 在磁盘 ``sda`` 上创建ZFS的存储池,名字为 ``zpool-data``

检查 ``zpool list`` 输出如下:

.. literalinclude:: ../../../linux/storage/zfs/admin/zfs_startup_zcloud/zpool_list_output
:caption: 使用 ``zpool list`` 检查现有的zpool存储池 可以看到刚创建的 ``zpool-data``

- 当前 ``zcloud`` 上构建的 :ref:`libvirt` 存储:

.. literalinclude:: libvirt_zfs_pool/virsh_pool-list_output
:caption: ``virsh pool-list`` 查看当前系统已经具备的 libvirt 存储池
:emphasize-lines: 4-6

其中:

- ``images`` 是默认本地磁盘存储池 ``/var/lib/libvirt/images`` 目录
- ``images_lvm`` 是 :ref:`libvirt_lvm_pool`
- ``images_rbd`` 是 :ref:`ceph_rbd_libvirt`

接下来我们创建一个ZFS存储池 ``images_zfs``

- 在 :ref:`ubuntu_linux` 平台,需要安装 libvirt 的 ZFS 存储驱动软件包:

.. literalinclude:: libvirt_zfs_pool/ubuntu_install_libvirt_zfs_driver
:caption: 在 Ubuntu 系统上安装libvirt的ZFS驱动

ZFS存储池定义
==============

- 对于已经存在的 ZFS 存储池 ``zpool-data`` 需要定义为libvirt的存储池:

.. literalinclude:: libvirt_zfs_pool/virsh_pool_define_zfs
:caption: 定义 ``zpool-data`` 存储池作为libvirt的存储池

遇到报错显示没有zfs存储池后端:

.. literalinclude:: libvirt_zfs_pool/virsh_pool_define_zfs_err
:caption: 定义 ``zpool-data`` 存储池作为libvirt的存储池报错,显示没有zfs后端

这是因为没有安装上文所说的 **libvirt 的 ZFS 存储驱动软件包** ``libvirt-daemon-driver-storage-zfs`` ,此外,安装了这个libvirt的ZFS驱动之后,一定要重新启动一次 ``libvirtd`` 服务,否则也会报上述错误。

如果一切正常,则会看到输出

.. literalinclude:: libvirt_zfs_pool/virsh_pool_define_zfs_output
:caption: 定义 ``zpool-data`` 存储池作为libvirt的存储池的成功输出信息

.. note::

我发现重启一次 ``libvirtd`` 服务,会出现 :ref:`ceph_rbd_libvirt` 的存储池 ``images_rbd`` 处于 ``inactive`` 状态,需要手工激活一次

- 设置libvirt的ZFS存储池自动启动,并激活:

.. literalinclude:: libvirt_zfs_pool/virsh_pool_zfs_start
:caption: libvirt的ZFS存储池自动启动,并激活

完成后检查 ``virsh pool-list`` 输出如下:

.. literalinclude:: libvirt_zfs_pool/virsh_pool-list_all
:caption: ``virsh pool-list`` 输出
:emphasize-lines: 7

创建虚拟机
============

- 为虚拟机创建ZFS卷(方法类似 :ref:`libvirt_lvm_pool` ):

.. literalinclude:: libvirt_zfs_pool/virsh_vol_create_zfs
:caption: 为虚拟机创建20G容量的ZFS卷

这里创建的将要用于虚拟机的ZFS卷并不会挂载到物理主机目录,不过可以通过 ``zfs list`` 命令查看:

.. literalinclude:: libvirt_zfs_pool/zfs_list
:caption: ``zfs list`` 可以查看到为虚拟机创建的卷
:emphasize-lines: 5

- 创建虚拟机( :ref:`create_vm` ):

.. literalinclude:: ../../startup/create_vm/create_centos7_vm_zfs
:caption::ref:`libvirt_zfs_pool` 创建CentOS 7虚拟机

参考
=======

- `ZFS and libvirt <https://sim.ovh/libvirt/zfs/>`_
- `Lucanuscervus Notes: ZFS Using ZFS with libvirt <https://lucanuscervus-notes.readthedocs.io/en/latest/Filesystems/ZFS/ZFS%20-%20Using%20ZFS%20with%20%20libvirt/>`_
- `libvirt storage: ZFS pool <https://libvirt.org/storage.html#zfs-pool>`_
- `KVM with ZFS support <https://operationroot.com/?p=1595>`_
- `KVM with ZFS support <https://operationroot.com/kvm-with-zfs-support.html>`_
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt install libvirt-daemon-driver-storage-zfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Name State Autostart
------------------------------------
boot-scratch active yes
images active yes
images_lvm active yes
images_rbd active yes
images_zfs active yes
nvram active yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Name State Autostart
------------------------------------
boot-scratch active yes
images active yes
images_lvm active yes
images_rbd active yes
nvram active yes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
virsh pool-define-as --name images_zfs --source-name zpool-data --type zfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: Failed to define pool images_zfs
error: internal error: missing backend for pool type 12 (zfs)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pool images_zfs defined
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
virsh pool-autostart images_zfs
virsh pool-start images_zfs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
virsh vol-create-as images_zfs centos7-zfs 20G
6 changes: 6 additions & 0 deletions source/kvm/libvirt/storage/libvirt_zfs_pool/zfs_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NAME USED AVAIL REFER MOUNTPOINT
zpool-data 283G 1.40T 112K /zpool-data
zpool-data/android 262G 1.40T 262G /zpool-data/android
zpool-data/ccache 96K 1.40T 96K /zpool-data/ccache
zpool-data/centos7-zfs 20.6G 1.42T 56K -
zpool-data/y-k8s 96K 1.40T 96K /zpool-data/y-k8s
7 changes: 6 additions & 1 deletion source/kvm/startup/create_vm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ ARM环境Ubuntu虚拟机
--location=http://mirrors.163.com/centos/7/os/x86_64/ \
--extra-args="console=tty0 console=ttyS0,115200"

- CentOS 7虚拟机在线安装( 使用 :ref:`libvirt_zfs_pool` ,创建方法同下文 **创建CentOS 7 (vault)虚拟机** ):

.. literalinclude:: create_vm/create_centos7_vm_zfs
:caption::ref:`libvirt_zfs_pool` 创建CentOS 7虚拟机

- CentOS 6.10 虚拟机在线安装::

virt-install \
Expand Down Expand Up @@ -225,7 +230,7 @@ ARM环境Ubuntu虚拟机
.. note::

- 存储采用 :ref:`ceph_rbd_libvirt`
- 和 :ref:`centos_8_replacement` 相似,需要采用 `centos-vault 163镜像 <http://mirrors.163.com/centos-vault/>`_ 安装
- 和 :ref:`centos_8_replacement_docker_image` 相似,需要采用 `centos-vault 163镜像 <http://mirrors.163.com/centos-vault/>`_ 安装

- 在 :ref:`ceph_rbd_libvirt` 上构建 RBD磁盘:

Expand Down
13 changes: 13 additions & 0 deletions source/kvm/startup/create_vm/create_centos7_vm_zfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# virsh vol-create-as images_zfs centos7-zfs 20G

virt-install \
--network bridge:br0 \
--name centos7-zfs \
--ram=4096 \
--vcpus=2 \
--os-type=Linux --os-variant=rhl7 \
--boot uefi --cpu host-passthrough \
--disk vol=images_zfs/centos7-zfs,sparse=false,format=raw,bus=virtio,cache=none,io=native \
--graphics none \
--location=http://mirrors.163.com/centos-vault/7.8.2003/os/x86_64/ \
--extra-args="console=tty0 console=ttyS0,115200"
54 changes: 54 additions & 0 deletions source/linux/redhat_linux/almalinux/almalinux_vs_rockylinux.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.. _almalinux_vs_rockylinux:

===============================
AlmaLinux vs. Rocky Linux
===============================

2021年12月31日,随着CentOS Linux 8来到生命周期重点(End of Life, EoL),所有以CentOS作为Red Hat Enterprise Linux平替的企业和个人都需要考虑何去何从:

- CentOS将演变为CentOS Stream(9),作为RHEL的开发版本和"滚动发布"版本,意味着在生产环境中使用存在风险
- 作为个人爱好者,期望有企业级的开发学习环境,并且紧跟RHEL技术发展,可以选择社区驱动快速迭代的 :ref:`almalinux`
- `Rocky Linux <https://rockylinux.org/>`_ 承诺bug级复制的RHEL,则更为适合需要完全复制Red Hat Enterprise Linux的企业用户(有时候bug的兼容也很重要,避免触发生产环境work around失效),也适合企业规模升级后切换到Red Hat Enterprise Linux

区别
======

- 运营模式区别:

- AlmaLinux 是由 CloudLinux (专门为大型托管服务提供商和数据中心提供定制的基于 Linux 的操作系统的公司) 创建和资助,但完全由社区管理和驱动(CloudLinux不拥有该项目和软件)
- Rocky Linux由最初的 CentOS 项目创始人 Gregory Kurtzer 创立的 Rocky Enterprise Software Foundation (RESF) 控制和管理,意味着Kurtzer拥有Rocky(公司持有人和决策者)

- 社区区别:

- AlmaLinux 和开源社区结合更紧密,没有采用绕开RHEL协议的方式,所以是ABI兼容(RHEL和EPEL),开发极为活跃
- Rocky Linux采用了1:1 Bug级兼容,通过RHEL协议漏洞(购买RHEL服务可以获得源代码),实现像素级复制,更适合必须完全兼容RHEL的企业采用

- 商业支持区别:

- AlmaLinux背后支持是微软(和IBM竞争),如果想更快接触新技术,甚至可能采用微软Azure云计算,则可以选择AlmaLinux
- Rocky Linux背后支持是谷歌,未来可能会类似CentOS一样和RedHat合作,如果需要维护企业现有配置以及传统的Linux线路,则建议选择Rocky Linux

我的选择
=========

我在2023年双十一时期购买了阿里云促销的99元/年 2c2g (ecs.e-c1m1.large) 3Mbps带宽:

.. csv-table:: 阿里云2c2g (ecs.e-c1m1.large) 计算存储
:file: almalinux_vs_rockylinux/ecs.e-c1m1.large.csv
:widths: 20,20,20,20,20
:header-rows: 1

.. csv-table:: 阿里云2c2g (ecs.e-c1m1.large) 网络
:file: almalinux_vs_rockylinux/ecs.e-c1m1.large_network.csv
:widths: 20,20,20,20,20
:header-rows: 1

由于我不想采用默认的AliOS,所以综合上述对比,选择采用 AlmaLinux 来学习开发

参考
======

- `AlmaLinux vs Rocky Linux:CentOS 替代你选择哪一个? <https://www.51cto.com/article/705594.html>`_
- `CentOS Linux 即将到了生命周期终点,老用户何去何从 <https://www.linuxmi.com/centos-linux-eol.html>`_
- `同为CentOS的替代者,AlmaLinux 和 Rocky Linux有什么区别?该如何选择? <https://www.zhihu.com/question/503401806>`_
- `Alma Linux 与 Rocky Linux 有什么不同? <https://www.shixingceping.com/3906.html>`_
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
实例规格,vCPU,内存(GiB),云盘IOPS基础/突发,云盘带宽基础/突发(Gbit/s)
ecs.e-c1m1.large,2,2.0,0.8万/无,0.4/无
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
实例规格,网络带宽基础/突发(Gbit/s),多队列,弹性网卡,单网卡私有IPv4地址数
ecs.e-c1m1.large,0.2/最高2,1,2,2
17 changes: 17 additions & 0 deletions source/linux/redhat_linux/almalinux/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. _almalinux:

========================================
AlmaLinux
========================================

.. toctree::
:maxdepth: 1

almalinux_vs_rockylinux.rst

.. only:: subproject and html

Indices
=======

* :ref:`genindex`

0 comments on commit b2c3b76

Please sign in to comment.