Sandbox Procedure
Procedure & output when launching local sandbox with vagrant
Launch
cd /tmp && git clone git@github.com:Vonng/pigsty.git && cd pigstymake up # 拉起vagrant虚拟机make ssh # 配置虚拟机ssh访问 【单次,下次启动无需再次执行】sudo make dns # 写入Pigsty静态DNS域名 【sudo输入密码,可选,单次】make download # 下载最新离线软件包 【可选,可显著加速初始化】make upload # 将离线软件包上传至元节点
clean
清理所有的沙箱痕迹(如果有)
$ make cleancd vagrant && vagrant destroy -f==> node-3: Forcing shutdown of VM...==> node-3: Destroying VM and associated drives...==> node-2: Forcing shutdown of VM...==> node-2: Destroying VM and associated drives...==> node-1: Forcing shutdown of VM...==> node-1: Destroying VM and associated drives...==> meta: Forcing shutdown of VM...==> meta: Destroying VM and associated drives...
up4
执行make up4将调用vagrant up命令,根据Vagrantfile中的定义,使用Virtualbox创建四台虚拟机。
请注意第一次执行vagrant up时,软件会自动从官网下载 CentOS/7 的虚拟机镜像。如果您的网络状况不佳(例如没有FQ代理),则可能需要等待相当长的一段时间。 您也可以选择自己创建虚拟机,并根据 部署 一章的说明进行Pigsty部署(不建议)。
使用
make new4将执行make del4; make up4一次性完成幂等的4节点虚拟机销毁与重新创建工作。
$ make up4cd vagrant && vagrant upBringing machine 'meta' up with 'virtualbox' provider...Bringing machine 'node-1' up with 'virtualbox' provider...Bringing machine 'node-2' up with 'virtualbox' provider...Bringing machine 'node-3' up with 'virtualbox' provider...==> meta: Cloning VM...==> meta: Matching MAC address for NAT networking...==> meta: Setting the name of the VM: vagrant_meta_1653467035614_99943==> meta: Clearing any previously set network interfaces...==> meta: Preparing network interfaces based on configuration...meta: Adapter 1: natmeta: Adapter 2: hostonly==> meta: Forwarding ports...meta: 22 (guest) => 2222 (host) (adapter 1)==> meta: Running 'pre-boot' VM customizations...==> meta: Booting VM...==> meta: Waiting for machine to boot. This may take a few minutes...meta: SSH address: 127.0.0.1:2222meta: SSH username: vagrantmeta: SSH auth method: private keymeta: Warning: Connection reset. Retrying...meta: Warning: Remote connection disconnect. Retrying...meta: Warning: Connection reset. Retrying...meta: Warning: Remote connection disconnect. Retrying...meta: Warning: Connection reset. Retrying...==> meta: Machine booted and ready!==> meta: Checking for guest additions in VM...meta: No guest additions were detected on the base box for this VM! Guestmeta: additions are required for forwarded ports, shared folders, host onlymeta: networking, and more. If SSH fails on this machine, please installmeta: the guest additions and repackage the box to continue.meta:meta: This is not an error message; everything may continue to work properly,meta: in which case you may ignore this message.==> meta: Setting hostname...==> meta: Configuring and enabling network interfaces...==> meta: Rsyncing folder: /Volumes/Data/pigsty/vagrant/ => /vagrant==> meta: Running provisioner: shell...meta: Running: /var/folders/nb/nvvpjqvx55z7j1kzt9g7slfw0000gn/T/vagrant-shell20220525-46785-oyqlbp.shmeta: [INFO] write ssh config to /home/vagrant/.ssh==> node-1: Cloning VM...==> node-1: Matching MAC address for NAT networking...==> node-1: Setting the name of the VM: vagrant_node-1_1653467085870_71907==> node-1: Fixed port collision for 22 => 2222. Now on port 2200.==> node-1: Clearing any previously set network interfaces...==> node-1: Preparing network interfaces based on configuration...node-1: Adapter 1: natnode-1: Adapter 2: hostonly==> node-1: Forwarding ports...node-1: 22 (guest) => 2200 (host) (adapter 1)==> node-1: Running 'pre-boot' VM customizations...==> node-1: Booting VM...==> node-1: Waiting for machine to boot. This may take a few minutes...node-1: SSH address: 127.0.0.1:2200node-1: SSH username: vagrantnode-1: SSH auth method: private keynode-1: Warning: Connection reset. Retrying...node-1: Warning: Remote connection disconnect. Retrying...node-1: Warning: Remote connection disconnect. Retrying...node-1: Warning: Connection reset. Retrying...node-1: Warning: Remote connection disconnect. Retrying...node-1: Warning: Connection reset. Retrying...==> node-1: Machine booted and ready!==> node-1: Checking for guest additions in VM...node-1: No guest additions were detected on the base box for this VM! Guestnode-1: additions are required for forwarded ports, shared folders, host onlynode-1: networking, and more. If SSH fails on this machine, please installnode-1: the guest additions and repackage the box to continue.node-1:node-1: This is not an error message; everything may continue to work properly,node-1: in which case you may ignore this message.==> node-1: Setting hostname...==> node-1: Configuring and enabling network interfaces...==> node-1: Rsyncing folder: /Volumes/Data/pigsty/vagrant/ => /vagrant==> node-1: Running provisioner: shell...node-1: Running: /var/folders/nb/nvvpjqvx55z7j1kzt9g7slfw0000gn/T/vagrant-shell20220525-46785-1yv4tae.shnode-1: [INFO] write ssh config to /home/vagrant/.ssh==> node-2: Cloning VM...==> node-2: Matching MAC address for NAT networking...==> node-2: Setting the name of the VM: vagrant_node-2_1653467132919_42678==> node-2: Fixed port collision for 22 => 2222. Now on port 2201.==> node-2: Clearing any previously set network interfaces...==> node-2: Preparing network interfaces based on configuration...node-2: Adapter 1: natnode-2: Adapter 2: hostonly==> node-2: Forwarding ports...node-2: 22 (guest) => 2201 (host) (adapter 1)==> node-2: Running 'pre-boot' VM customizations...==> node-2: Booting VM...==> node-2: Waiting for machine to boot. This may take a few minutes...node-2: SSH address: 127.0.0.1:2201node-2: SSH username: vagrantnode-2: SSH auth method: private keynode-2: Warning: Connection reset. Retrying...node-2: Warning: Remote connection disconnect. Retrying...node-2: Warning: Connection reset. Retrying...node-2: Warning: Remote connection disconnect. Retrying...node-2: Warning: Connection reset. Retrying...node-2: Warning: Remote connection disconnect. Retrying...==> node-2: Machine booted and ready!==> node-2: Checking for guest additions in VM...node-2: No guest additions were detected on the base box for this VM! Guestnode-2: additions are required for forwarded ports, shared folders, host onlynode-2: networking, and more. If SSH fails on this machine, please installnode-2: the guest additions and repackage the box to continue.node-2:node-2: This is not an error message; everything may continue to work properly,node-2: in which case you may ignore this message.==> node-2: Setting hostname...==> node-2: Configuring and enabling network interfaces...==> node-2: Rsyncing folder: /Volumes/Data/pigsty/vagrant/ => /vagrant==> node-2: Running provisioner: shell...node-2: Running: /var/folders/nb/nvvpjqvx55z7j1kzt9g7slfw0000gn/T/vagrant-shell20220525-46785-zgwsig.shnode-2: [INFO] write ssh config to /home/vagrant/.ssh==> node-3: Cloning VM...==> node-3: Matching MAC address for NAT networking...==> node-3: Setting the name of the VM: vagrant_node-3_1653467179461_75182==> node-3: Fixed port collision for 22 => 2222. Now on port 2202.==> node-3: Clearing any previously set network interfaces...==> node-3: Preparing network interfaces based on configuration...node-3: Adapter 1: natnode-3: Adapter 2: hostonly==> node-3: Forwarding ports...node-3: 22 (guest) => 2202 (host) (adapter 1)==> node-3: Running 'pre-boot' VM customizations...==> node-3: Booting VM...==> node-3: Waiting for machine to boot. This may take a few minutes...node-3: SSH address: 127.0.0.1:2202node-3: SSH username: vagrantnode-3: SSH auth method: private keynode-3: Warning: Connection reset. Retrying...node-3: Warning: Remote connection disconnect. Retrying...node-3: Warning: Remote connection disconnect. Retrying...node-3: Warning: Connection reset. Retrying...node-3: Warning: Remote connection disconnect. Retrying...node-3: Warning: Connection reset. Retrying...==> node-3: Machine booted and ready!==> node-3: Checking for guest additions in VM...node-3: No guest additions were detected on the base box for this VM! Guestnode-3: additions are required for forwarded ports, shared folders, host onlynode-3: networking, and more. If SSH fails on this machine, please installnode-3: the guest additions and repackage the box to continue.node-3:node-3: This is not an error message; everything may continue to work properly,node-3: in which case you may ignore this message.==> node-3: Setting hostname...==> node-3: Configuring and enabling network interfaces...==> node-3: Rsyncing folder: /Volumes/Data/pigsty/vagrant/ => /vagrant==> node-3: Running provisioner: shell...node-3: Running: /var/folders/nb/nvvpjqvx55z7j1kzt9g7slfw0000gn/T/vagrant-shell20220525-46785-11saraj.shnode-3: [INFO] write ssh config to /home/vagrant/.ssh
ssh
新拉起的虚拟机默认用户为vagrant,需要配置本机到虚拟机的免密ssh访问。 执行make ssh命令将调用vagrant的ssh-config命令,将pigsty虚拟机节点的ssh配置文件写入~/.ssh/pigsty_config。
通常该命令只需要在首次启动沙箱时执行一次,后续重新拉起的虚拟机通常会保有相同的SSH配置。
执行完毕后,用户才可以使用类似ssh node-1的方式通过SSH别名连接至沙箱内的虚拟机节点。
$ make sshcd vagrant && vagrant ssh-config > ~/.ssh/pigsty_config 2>/dev/null; trueif ! grep --quiet "pigsty_config" ~/.ssh/config ; then (echo 'Include ~/.ssh/pigsty_config' && cat ~/.ssh/config) > ~/.ssh/config.tmp; mv ~/.ssh/config.tmp ~/.ssh/config && chmod 0600 ~/.ssh/config; fiif ! grep --quiet "StrictHostKeyChecking=no" ~/.ssh/config ; then (echo 'StrictHostKeyChecking=no' && cat ~/.ssh/config) > ~/.ssh/config.tmp; mv ~/.ssh/config.tmp ~/.ssh/config && chmod 0600 ~/.ssh/config; fi
dns
此命令将Pigsty沙箱虚拟机的静态DNS配置写入/etc/hosts,通常该命令只需要在首次启动沙箱时执行一次。
执行完毕后,用户才可以从本地浏览器使用域名访问 http://g.pigsty 等WebUI。
注意DNS命令需要SUDO权限执行,需要输入密码,因为/etc/hosts文件需要特权方可修改。
$ sudo make dnsPassword: #<在此输入用户密码>if ! grep --quiet "pigsty dns records" /etc/hosts ; then cat files/dns >> /etc/hosts; fi
Last modified 2022-06-04: fill en docs (5a858d3)