系统环境说明
deepin
系统:deepin V20
平台:x86_64
CentOS
系统:CentOS8
平台:x86_64
使用vagrant
安装centos6
安装 virtualbox
deepin V20
sudo apt install virtualbox-6.1
CentOS8
新建 /etc/yum.repos.d/virtualbox.repo,内容为
[virtualbox]
name=Virtualbox Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/virtualbox/rpm/el$releasever/
gpgcheck=0
enabled=1
刷新缓存并安装 virtualbox 即可。
sudo yum makecache
sudo yum install VirtualBox-6.1.x86_64
安装vagrant
vagrant
软件下载地址- 安装
# 下载vagrant软件
wget https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_linux_amd64.zip
# 解压安装
mkdir ~/App/vagrant
unzip vagrant_2.2.10_linux_amd64.zip -d ~/App/vagrant
# 配置环境变量
echo "export PATH=~/App/vagrant:$PATH" >> ~/.bashrc
# 立即生效环境变量
source ~/.bashrc
# 安装插件
vagrant plugin install --plugin-clean-sources --plugin-source https://gems.ruby-china.com/ vagrant-vbguest
安装centos6
# 下载centos6镜像
vagrant box add centos6 http://mirrors.ustc.edu.cn/centos-cloud/centos/6/vagrant/x86_64/images/CentOS-6-x86_64-Vagrant-2004_01.VirtualBox.box
# 初始化
vagrant init centos6
# 启动启动
vagrant up
常见问题
- 执行
vagrant up
,出现如下错误:
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /home/dev/vagrant/pixiu-yang/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL -o ControlMaster=auto -o ControlPath=/tmp/vagrant-rsync-20200902-7232-xv4it4 -o ControlPersist=10m -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/home/dev/vagrant/pixiu-yang/.vagrant/machines/default/virtualbox/private_key'" "--exclude" ".vagrant/" "/home/dev/vagrant/pixiu-yang/" "[email protected]:/vagrant"
Error: Auto configuration failed
139703436113624:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
139703436113624:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
139703436113624:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
139703436113624:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]
解决方法:
echo "export OPENSSL_CONF=/etc/ssl" >> ~/.bashrc
source ~/.bashrc
vagrant
常用命令
# 使用ssh登陆vagrant虚拟机系统
vagrant ssh
# 同步vagrant虚拟机与物理机文件
vagrant rsync-auto
# 重新加载虚拟机
vagrant reload
# 销毁镜像
vagrant destroy
# 启动启动
vagrant up
# 关闭虚拟机
vagrant halt
vagrant
虚拟机镜像相关信息
- vagrant镜像默认密码
默认普通用户名:vagrant
密码:vagrant
默认root用户名:root
密码:vagrant