Vagrant 安装 Centos7

首先准备VirtualBox, 当前实验版本为:7.0.4-154605-Win;

再次下载Vagrant windows版本:当前实验版本:vagrant_2.3.4_windows_i686

如果安装VirtualBox过程中提示缺少:Microsoft Visual C++ 2019 Redistributable :则可单独下载安装。

安装过程中提示重启电脑。下面开始安装Centos7.

1:新建一个目录,用于运行Centos7;

2: 去官网上下载Centos7 的VirtualBox镜像,把下载的文件拷贝到步骤1,重命名为一个简短的名称,如centos7.box;

https://app.vagrantup.com/centos/boxes/7/versions/2004.01/providers/virtualbox.box

3:打开cmd命令行,cd 到步骤1的目录中,执行:vagrant box add --name 'centos7' centos7.box;

 D:\mix>vagrant box add --name 'centos7' centos7.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'centos7' (v0) for provider:
    box: Unpacking necessary files from: file://D:/mix/centos7.box
    box:
==> box: Successfully added box 'centos7' (v0) for 'virtualbox'!

4: vagrant init centos7:初始化centos7:

此时,会在当前目录下创建一个Vagrantfile文件;

D:\mix>vagrant init centos7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

5:vagrant up:

此时:打开virtualbox :可以看到实例化了一个centos的虚拟机:

 6:ssh 连接虚拟机:

vagrant ssh

 至此一台centos虚拟机环境就成功运行起来了;

7: 查看状态:vagrant status;

8: 停止运行:vagrant hault;

9:如要删除虚拟机:则执行: vagrant destroy;

10:修改root 密码:root默认的密码是vagrant,同时vagrant默认的密码也是vagrant

[vagrant@localhost ~]$ sudo passwd root
Changing password for user root.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

11:修改配置开启远程连接:
sudo vi /etc/ssh/sshd_config
将PermitRootLogin 改为yes;修改PasswordAuthentication 为yes

重启sshd服务:sudo systemctl restart sshd

12:确保可ping 通centos虚拟机,可使用FinalShell等工具连接虚拟机;

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值