Cloud-oriented Life

Cloud Native Technology Improves Lives

asdf and Node.js Plugin

asdf is a single CLI tool for managing multiple runtime versions. It extend with a simple plugin system to install your favourite language: Dart, Elixir, Flutter, Golang (Go), Java, Node.js, Python, Ruby …

This article is about how to use asdf and Node.js plugin to install multiple Node.js versions on macOS with the Homebrew package manager.

Read more »

OSSImport is a free tool created by the Alibaba Cloud product team to assist with data backup and migration into the Alibaba Cloud Object Storage Service (OSS). Using OSSImport data can be migrated from either local storage or from third party cloud platforms. Currently supported data sources include Qiniu, Baidu BOS, AWS S3, Azure Blob, Youpai Cloud, Tencent Cloud COS, Kingsoft KS3, HTTP, and other OSS buckets.

Read more »

migration_comments

Using MigrationComments, you can simply add comments during your migrations. Or if you already have existing data structures, just add the comments afterwards in a separate migration. And of course you can always modify and delete these comments in later migrations.

So where are these comments used? Firstly, they will be included in your schema.rb dump which is where your IDE (e.g. RubyMine, VS Code) should be learning about your model structure. This means that they’ll be available at any point in your project. Additionally, if you are using the 'annotate’ gem, these comments will be added to the annotations that are generated within your model.rb file.

Read more »

Github or Gitlab use ~/.ssh/id_rsa as the default SSH private key. But sometimes you need more accounts than one for access to Github or Gitlab and similar tools. For example you can have one account for your projects at home and second account for your company.

There are three ways to Use multiple SSH private keys within git commands.

Read more »

rails_semantic_logger

Semantic Logger is a comprehensive Rails logging interface that enables human and machine readable logging outputs.

  • Colorful text log files for humans to read.

  • JSON log files containing all Semantic information that machines can easily comsume.

  • Write to multiple output destinations at the same time.

  • Forward logs to a centralized logging system, via JSON output or built-in appenders.

Read more »

FAQs about SCP

zsh report errors no matches found while zsh uses scp to transfer files with wildcards

1
2
$ scp [email protected]:/Users/cloudolife/.ssh/* ~/.ssh/
sh: no matches found: [email protected]:/Users/cloudolife/.ssh/*

The reason is because zsh tries to expand *. No matches error will be reported when the file cannot be found locally.

There are two approaches:

Option 1, Avoid zsh to expand *

  • Add a backslash() before * to prevent escaping

    1
    $ scp [email protected]:/Users/cloudolife/.ssh\* ~/.ssh/
  • Or, Enclose the path (or the path including the server) with single or double quotes

    1
    2
    3
    4
    # Single quotation mark, including server address
    scp '[email protected]:/Users/cloudolife/.ssh/*' ~/.ssh/
    # Double quotation mark, without server address
    scp [email protected]:"/Users/cloudolife/.ssh/*" ~/.ssh/

But sometimes the above two methods using wildcards for local paths are invalid, then refer to next:

Option 2, Switch to /bin/bash

/bin/bash does not have the problem of expanding *.

1
$ chsh -s /bin/bash

zsh 使用scp传输文件时使用通配符报错_SimonLiu的博客-CSDN博客

FAQs about using Vagrant for building and managing virtual machine environments

Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.

There are some FAQs about Vagrant.

Read more »

Usage

First, edit Vagrant file to add external disk configuration.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true

# Customize the amount of memory on the VM:
vb.memory = "1024"

+ file_to_disk = './disks/external-disk-1.vdi'
+ # 100 * 1024 = 100GB
+ vb.customize ['createhd', '--filename', file_to_disk, '--size', 100 * 1024]
+ # IDE mode
+ vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
+ # SATA Controller mode
+ # vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end

Then, run vagrant up or vagrant reload to make external disk available.

1
2
3
4
$ VAGRANT_EXPERIMENTAL=disks vagrant up

# Or reload
# $ VAGRANT_EXPERIMENTAL=disks vagrant reload

Done!

1
2
3
4
5
$ vagrant ssh -c lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20.0G 0 disk
├─sda1 8:1 0 19.6G 0 part
sdb 8:16 0 100.0G 0 disk

FAQs

Could not find a controller named ‘SATA Controller’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ VAGRANT_EXPERIMENTAL=disks vagrant up
...
A customization command failed:

["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "./disks/disk-1.vdi"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["storageattach", "5454cd06-0f61-43c5-a14e-071c9100439c", "--storagectl", "SATA Controller", "--port", "1", "--device", "0", "--type", "hdd", "--medium", "./disks/disk-1.vdi"]

Stderr: VBoxManage: error: Could not find a controller named 'SATA Controller'
>

Please fix this customization and try again.

Check current Storage Controller Name.

1
2
3
4
5
6
7
$ VBoxManage showvminfo 5454cd06-0f61-43c5-a14e-071c9100439c | grep "Storage"
Storage Controller Name (0): IDE
Storage Controller Type (0): PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 2
Storage Controller Port Count (0): 2
Storage Controller Bootable (0): on

Change Storage Controller Name SATA Controller from to IDE.

1
2
3
4
5
+     # IDE mode
+ vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
+ # SATA Controller mode
+ # vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
- vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]

VERR_ALREADY_EXISTS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ VAGRANT_EXPERIMENTAL=disks vagrant up
A customization command failed:

["createhd", "--filename", "./disks/disk-1.vdi", "--size", 1048576]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["createhd", "--filename", "./disks/disk-1.vdi", "--size", "1048576"]

Stderr: 0%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage: error: Failed to create medium
VBoxManage: error: Could not create the medium storage unit '/Users/cloudolife/col-vagrant/disks/disk-1.vdi'.
VBoxManage: error: VDI: cannot create image '/Users/cloudolife/col-vagrant/disks/disk-1.vdi' (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 450 of file VBoxManageDisk.cpp
>

Please fix this customization and try again.

There is already a disk disk-1.

Check the UUID of the disk disk-1

1
2
3
4
5
$ VBoxManage list hdds
...
UUID: <UUID>
Location: /home/vagrant/vagrants/vagrant-example/disks/disk-1.vdi
...

Delete the disk disk-1.

1
$ vboxmanage closemedium disk <UUID> --delete

Then, run VAGRANT_EXPERIMENTAL=disks vagrant up.

References

[1] Add a second disk to system using vagrant - https://gist.github.com/leifg/4713995

[2] Vagrant virtualbox multiple disks - https://gist.github.com/muresan/e81df5d8aaf8be78b4ecdf787a9dba15

[3] How to define multiple disks inside Vagrant using VirtualBox provider – sleeplessbeastie’s notes - https://sleeplessbeastie.eu/2021/05/10/how-to-define-multiple-disks-inside-vagrant-using-virtualbox-provider/

[4] Fix for VBoxManage: error: Could not find a controller named ‘SATA’ Error | Sharmi Writes Here - https://www.minvolai.com/fix-for-vboxmanage-error-could-not-find-a-controller-named-sata-error/

[5] Vagrant by HashiCorp - https://www.vagrantup.com/

[6] Oracle VM VirtualBox - https://www.virtualbox.org/

0%