Tag: cloud

  • 部落格迁移到甲骨文云

    感觉这是重复每隔几年就要进行的练习,这一次把Blog从Amazon Lightsail VPS迁移到了甲骨文云(Oracle Cloud)的虚拟机。

    很多人白嫖甲骨文云(确实有非常丰厚的免费额度),我之前架设的Termux的APT镜像也是用的甲骨文的免费资源。但是最近发现免费账户基本allocate不到资源了,所以填了个信用卡升级到了Pay As You Go账户级别,突然就能allocate到VM了。虽然是付费账户,但只要还是在免费额度以内,并不会产生费用所以其实无所谓。

    甲骨文云的定价真的是白菜价(免费啊!),开了个四核24G内存的VM来作为我主要的VPS,其中一个用途就是用来跑这个博客(部落格)网站。促使我从Amazon Lightsail搬过来并不是因为我不想每个月掏那3.5美金(好吧,不只是),而是很快亚马逊要开始对公用的IPv4地址收取额外的费用。已经被亚马逊云收费恶心过一次了(给的CPU非常垃圾,超过的部分要额外收费,超得太过了还会pause导致前一段时间VPS无响应了一天)。一对比,甲骨文云的虚拟主机性能高出太多,还不要钱!

    吐槽完了,分享一下这次迁移的心得。

    1. 首先从原主机上做一个新的备份,把/var/www/整个目录都备份下来,然后MySQL或者MariaDB也做一个备份(这里至少需要备份wordpress这个table
    2. 把备份传到新主机上(用scp安全传输)
    3. 新主机依次安装配置好:
      • nginx
      • php-fpm
      • iptables (保证80和443端口开放)
      • mysql-server or mariadb-server (用和原主机一样的vendor,不然可能恢复备份的时候会有问题)
    4. 恢复wordpress到新主机的数据库里
    5. 恢复/var/www/,可能需要按新的nginx配置稍微改动权限或者nginx的配置文件

    一开始我在新VM安装配置的是MySQL,结果恢复备份的时候就有问题(database engine不一致,好像用了个MySQL没有或者是默认没有的引擎)。彻底删掉重新配置安装MariaDB就没事了。

    后来又遇到恢复的SQL用户没法登录的问题,好在这个简单,我删掉重新创建一个同名的用户(同样的密码)就OK了。

    我遇到的最大的问题,是wordpress本身没法运行,害得我要重新下载安装wordpress,不过可以继续用原来的数据库所以并没有丢失任何帖子或者评论,多媒体附件从之前的备份wp_content目录下拷贝过来修改好权限也没问题。就是插件都要重新安装配置,干脆就趁机轻装上阵少了几个插件,然后换了一套主题。

    另一个小问题是,因为IP地址变化,要在DNS那边改动,估计会导致有一段时间暂时无法访问。要申请新的SSL证书,LetsEncrypt也会要检查DNS记录,所以要稍微耐心一点。

    目前个人感觉网站访问速度比之前在亚马逊垃圾VPS要快一些。操作系统也从CentOS 7换成了Ubuntu 22.04,所以很多组件也随着升级了(PHP升级到8.1了!),也算是个bonus

  • Home Assistant Core Setup on Banana Pi M5

    There is no support for BananaPi M5 from Home Assistant OS, which leaves me either the container or the core version. Originally I was going to use the container image, however, it needs too much disk space (7GB was not enough as it maxed out my onboard storage). I went for Home Assistant Core instead, and this post records my journey setting it up.

    1. Install uv (a Python environment manager)
    2. Install latest Python (3.13 at the time of writing), because Home Assistant Core has deprecated the support for older versions of Python
    3. Install Home Assistant Core (official documentation as a reference). I’m using uv to manage the virtual environment (note that I’ll enable ISAL for better performance).
    cd /srv/homeassistant/
    uv venv pyenv --python 3.13
    source pyenv/bin/activate
    uv pip install homeassistant==2024.12.3
    uv pip install isal  # ISAL for faster gzip and zlib
    1. Install and configure Cloudflare Zero Trust Tunnel (official documentation for remote tunnel). To expose my Home Assistant access to the public Internet, so that I can access it everywhere. Besides, some cloud-based services require that access because they use callbacks (the alternative is to pay for Nabu Casa which is a subscription-based service). Configure the access control in Cloudflare Zero Trust so that only verified emails from a restricted list have access (additional policies can be set for a new application that bypasses any control for cloud services callbacks)
      • Worth noting that the cloudflared add-on cannot be used because Home Assistant Core doesn’t support add-ons.
    2. Setup a new service in systemd for Home Assistant’s hass so that it starts on boot and restarts on failures. I created this file /etc/systemd/system/ha@homeassistant.service (systemctl enable and systemctl start afterwards):
    [Unit]
    Description=Home Assistant
    After=network-online.target
    After=network.target
    
    [Service]
    Type=simple
    User=homeassistant
    ExecStart=/srv/homeassistant/pyenv/bin/hass
    Restart=on-failure
    RestartSec=5s
    
    [Install]
    WantedBy=multi-user.target
    
  • A New Termux Mirror

    TL; DR. https://termux.librehat.com is a new Termux packages mirror! Maintained by me, synchronised every six hours, located in the United Kingdom, hosted by Oracle Cloud.

    In the full article below, I’ll write up how to set up a Termux mirror (or in general, a Debian packages repository mirror).

    (more…)
  • 来份Brunch笔电瞬间变身Chromebook

    自从几年前卖掉华硕的一台小Chromebook后,看到Android和Linux应用程式的支持增加,又开始有点馋涎Chromebook……不过因为今年疫情全球大爆发,电子产品(尤其是适合居家办公和学习的)价格一路上扬(或者缺货)。Chromebook今年出货量增长更是迅猛(Windows PC, MacBook, Chromebook分类中增长幅度最大)。问我这台2015年买的老笔电尚能饭否?答曰:Brunch

    出厂预装的Windows 10早被我卸载干净了,单Linux系统(OpenSUSE)用了有一年多了,看到Brunch这个项目能在自己笔电上体验Chrome OS变身Chromebook,赶紧试验了一把,没想到效果出奇地好!这里特意用中文记载一下Linux下安装Chrome OS和后续升级的办法以供中文网络世界的朋友参考。

    (more…)
  • Virtual Linux Desktop Experience in Azure

    I wouldn’t believe that I will be writing this 10 years ago. It’s 2020 though. Microsoft has improved a lot of services for Linux, ranging from developer tools like Visual Studio Code, to the protagonist today: Azure (cloud computing). Azure has steadfastly become a real credible alternative to Amazon EC2 (or AWS in general). Today, I want to share my experience of using a virtual machine on Microsoft Azure cloud. To be more specific, it is a Linux desktop virtual machine (SLES 15).

    (more…)