os地址 https://releases.rancher.com/os/latest/rancheros.iso
官方文档: https://rancher.com/docs/os/v1.x/en/
1.1、生成ssh key : https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key
Generating a new SSH key
Open Git Bash.
Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096
This creates a new ssh key, using the provided email as a label.
Generating public/private rsa key pair.
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
1.2、建立cloud-config.y ml 文件:
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAA...ZZZ example1@rancher
- ssh-rsa BBB...ZZZ example2@rancher
hostname: linuxtest
rancher:
network:
dns:
nameservers:
- 114.114.114.114
- 114.114.115.115
1.3、验证文件正确性:
$ sudo ros config validate -i cloud-config.yml
1.4、开始安装:
[root@rancher /]# sudo ros install -c /tmp/cloud-config.yml -d /dev/sda
INFO[0000] No install type specified...defaulting to generic
Installing from rancher/os:v1.4.0
Continue [y/N]: y
INFO[0005] start !isoinstallerloaded
INFO[0005] trying to load /bootiso/rancheros/installer.tar.gz
cd7100a72410: Loading layer 4.403MB/4.403MB
5fc7296558d4: Loading layer 15.6MB/15.6MB
781f1861a62b: Loading layer 5.12kB/5.12kB
754b1a1ec10a: Loading layer 18.79MB/18.79MB
7e27cf2c698d: Loading layer 1.645MB/1.645MB
b92c6d05ef60: Loading layer 1.536kB/1.536kB
66bef27559a8: Loading layer 2.56kB/2.56kB
ba90e068c8db: Loading layer 3.072kB/3.072kB
Loaded image: rancher/os-installer:latest
INFO[0009] Loaded images from /bootiso/rancheros/installer.tar.gz
INFO[0009] starting installer container for rancher/os-installer:latest (new)
Installing from rancher/os-installer:latest
mke2fs 1.43.7 (16-Oct-2017)
Discarding device blocks: done
Creating filesystem with 2620928 4k blocks and 2621440 inodes
Filesystem UUID: 21f395b5-729e-4b54-815d-272db5c9aea0
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
Continue with reboot [y/N]:
然后就可以用rancher这个账号通过ssh登录系统了。
系统升级
ros os upgrade
安装docker-compose:
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
2.1、如果要一个docker重启后依然运行可以用下面方式create the /opt/rancher/bin/start.sh
script
$ sudo mkdir -p /opt/rancher/bin
$ echo "sudo system-docker start busydash" | sudo tee -a /opt/rancher/bin/start.sh
$ sudo chmod 755 /opt/rancher/bin/start.sh
2.2、切换操作系统
$ sudo ros console list
$ sudo ros console switch ubuntu