白嫖甲骨文云,但没有完全白嫖

听说甲骨文云有完全免费的VPS,气急败坏的去白嫖,看到首尔机房的延迟只有60ms果断下手,然后才知道整个棒子的甲骨文云的IP都被屏蔽了才后悔,应该听老人言用美国西海岸的机房。然鹅一切都太迟了,一个用户一张信用卡在免费账户中只能选一个机房,选定离手不能改……后来者看到这里一定要慎重选区呀!

仅限技术交流!

主机概况

甲骨文云的免费账户有两种VPS可以选,一种是普通x86的AMD处理器,1CPU/1G的普通机器;另一种是4CPU/24G的ARM机器。虽然提示说首尔和东京机房的ARM资源吃紧,不一定能嫖到,但是我不知道怎么回事蹲到了一个ARM机器,果断开了个机器。开实例的时候记得把私钥存下来,甲骨文云的主机默认ssh禁止用户名密码登录。

用的是Ubuntu 22.04的aarch64版本,甲骨文云的实例创建以后,虽然会给一个公网IP,但是此时还需要:

  • 在下方快速操作中选择将公共子网连接到Internet,一路默认点创建,之后上方面板中的网络安全组就有了ig-quick-action-NSG,编辑这个网络安全组,添加sshICMP等想要的入站规则;
  • 点面板中的子网,然后在安全列表中添加想要的的入站规则

由于首尔的甲骨文云全部被屏蔽了,只能走某瓦工了。外面的ping能通而且nc端口22也能通,用创建主机时拿到的私钥或在面板下方的控制台连接中拿到的私钥连接主机即可,用户名就在面板中,Ubuntu系统的默认用户名是ubuntu

1
ssh -i ~/.ssh/<oracle-cloud.key> ubuntu@<vps-ip-address>

查看机器的硬件还是相当给力的,lscpulsmem表示确实有4CPU/24G。甲骨文云在ARM机器的免费策略是,每月给CPU了3000小时,给内存了18000G小时,也就是31*24*4=297631*24*24=17865,所以理论上这个配置就是永久免费。这硬件跑点大应用应该不难。

1
2
3
4
5
6
7
8
9
sudo apt update && sudo apt dist-upgrade -y
sudo apt install zsh
sudo chsh -s $(which zsh)
sudo sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# /etc/ssh/sshd_config 中:
# 调整ssh会话一次存活60秒,自动重连60次
ClientAliveInterval 60
ClientAliveCountMax 60

开防火墙策略:

1
2
3
4
sudo ufw allow 22/tcp comment ssh
sudo ufw allow 443/tcp comment https
sudo ufw allow 80/tcp comment http
sudo ufw enable

安装docker

按照这篇文章一次安装完成:

  1. 更新,安装依赖:

    1
    2
    3
    4
    # update software repositories
    sudo apt update
    # install necessary packages for https apt calls
    sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  2. 使用Ubuntu构建的Armbian添加如下gpg秘钥:

    1
    2
    3
    4
    # add docker GPG key
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  3. (跳过)使用Debian构建的Armbian添加如下gpg秘钥:

    1
    2
    3
    4
    # add docker GPG key
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
  4. 安装docker:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # install docker
    sudo apt update
    sudo apt install docker-ce docker-ce-cli containerd.io
    # start docker service
    sudo systemctl start docker
    # enable docker service on startup
    sudo systemctl enable docker
    # create a docker group
    sudo groupadd docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
  5. 使用hello-world镜像测试安装结果:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    sudo docker run hello-world

    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    7050e35b49f5: Pull complete
    Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
    Status: Downloaded newer image for hello-world:latest

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash

    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/

    For more examples and ideas, visit:
    https://docs.docker.com/get-started/

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×