vagrant-centos配置

本文档将指导你如何利用Vagrant搭建和配置CentOS操作系统。通过Vagrant,你可以轻松创建一个标准化的开发环境,并在其中安装必要的科学计算库如numpy。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

virtualbox官网:
https://www.virtualbox.org
vagrant官网:
https://www.vagrantup.com/downloads.html
centos-box:网址:
http://cloud.centos.org/centos/7/vagrant/x86_64/images/
1.下载:
https://releases.hashicorp.com/vagrant/2.1.5/vagrant_2.1.5_x86_64.dmg
http://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7.box
https://download.virtualbox.org/virtualbox/6.0.12/VirtualBox-6.0.12-133076-Win.exe
下载不了,可以用linux下载
wget 网址
2.安装vagrant,virtualBox  目录没限制
3.dos 命令下:
           cd d:/virtual
           vagrant box add centos c:/download/CentOS-7.box
           vagrant init centos
           virtural目录下有个vagrantfile文件,
           修改文件内容:
              config.vm.box = "centos"
             config.vm.network "private_network", ip: "192.168.33.10"
              config.vm.synced_folder "D:/www", "/home/www"
             保存
          
           在virtual目录下,vagrant up 启动虚拟机
         可以在virtualBox软件中看到软件正在启动
        
4.vagrant常用命令:
                        vagrant box list 查看列表
                        vagrant box add e:/centos.box --name centos_1  添加镜像
                       vagrant init centos_1  开始初始化
                         vagrant halt 停止
                         vagrant reload  重新启动
                          vagrant up  启动
                          vagrant box add 虚拟机名称   虚拟机   安装虚拟机
5.常见错误:
    1)Vagrant was unable to mount VirtualBox shared folders. This is usually because the filesystem "vboxsf" is not available. This filesystem is made available via the VirtualBox Guest Additions and kernel module. Please verify that these guest additions are p
   
 vagrant plugin  install  vagrant-vbguest

  2)必须先安装virtualbox,再安装vagrant



    目前新版本:

      

          https://download.virtualbox.org/virtualbox/6.1.16/VirtualBox-6.1.16-140961-Win.exe    

    

           https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.msi



  3)

    No package kernel-devel-3.10.0-957.27.2.el7.x86_64 available.

Error: Nothing to do

==> default: Checking for guest additions in VM...

    default: No guest additions were detected on the base box for this VM! Guest

    default: additions are required for forwarded ports, shared folders, host only

    default: networking, and more. If SSH fails on this machine, please install

    default: the guest additions and repackage the box to continue.

    default:

    default: This is not an error message; everything may continue to work properly,

    default: in which case you may ignore this message.

The following SSH command responded with a non-zero exit status.

Vagrant assumes that this means the command failed!



yum install -y kernel-devel-`uname -r`



  解决:先登录虚拟机,

     vagrant ssh  

     su root  123456  管理员登录(sudo passwd root 修改root密码就可以登录)

     yum update

     yum install -y  kernel-devel
4.vagrant  SSH is not running, the authentication information was changed 怎么办?
vagrantfile文件中,加入
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"  
/usr/sbin/sshd -T  可以看到启动不了的具体原因
semanage port -l | grep ssh  可以查看ssh 是否可以用这个端口
             
5.vagrant : incompatible character encodings:GBK and UTF-8 错误怎么办?
virtualbox 软件打开,管理->全局设定->常规:
                                                      默认电脑位置中的中文名称改为英文路径就可以解决了
6. systemctl stop firewalld  关闭防火墙   
    systemctl status firewalld  防火墙状态
7. 设置ip地址
    vi /etc/sysconfig/network-scripts/ifcfg-eth1
   
    #VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.33.11
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
#VAGRANT-END
保存, service network  restart  重启生效
 6. 如何关闭秘钥,使用账号密码登录?
    vi  /etc/ssh/sshd_config
     PasswordAuthentication yes   #no改为yes
    service sshd restart
21.6.5:vagrant导出已经搭建好的环境
            
vagrant package --base vagrant_default_1618648973447_84137 --output lamp.box
               vagrant_default_1618648973447_84137是虚拟机的名字
               lamp.box是导出的名字
              查看虚拟机名字的方法:

vagrant-centos配置

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dadashitou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值