首页 > 其他 > 详细

Vagrant之CentOS

时间:2018-02-25 21:24:21      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:doc   配置文件   com   打包   mode   服务   virt   conf   ant   

Vagrant之CentOS

Vagrant官网

https://www.vagrantup.com

https://app.vagrantup.com/boxes/search

https://app.vagrantup.com/centos/boxes/7

前提安装Vagrant,Virtualbox

https://my.oschina.net/u/159293/blog/1623730

一、box

下载box

https://vagrantcloud.com/centos/boxes/7/versions/1801.02/providers/virtualbox.box

rename virtualbox.box centos7.4.1708.box

添加box

vagrant box add centos7.4.1708 E:\work\box\centos7.4.1708.box

生成公钥

http://git.mydoc.io/?t=154712

ssh-keygen -t rsa -C "xxxxx@xxxxx.com" 

# 说明
生成公钥存在于C:\Users\your name\.ssh

配置文件 :Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.box = "centos7.4.1708"
    config.vm.define "centos7" do |config|
        config.vm.provider "virtualbox" do |v|
            v.customize ["modifyvm", :id, "--name", "centos7", "--memory", "1024"]
        end
        config.vm.hostname = "centos7"
        config.vm.network :public_network, ip: "192.168.5.201", bridge: "eth1"
        config.vm.provision "file", source: "C:/Users/admin/.ssh/id_rsa.pub", destination: "~/.ssh/authorized_keys"
    end
end

如果不下载box,在上述配置文件中配置box

https://app.vagrantup.com/centos/boxes/7

config.vm.box = "centos/7"
config.vm.box_version = "1801.02"

二、run

启动

vagrant up centos7

运行Provisioners

https://www.vagrantup.com/docs/provisioning/basic_usage.html

vagrant provision centos7

# 说明
只有运行Provisioners,配置文件中的config.vm.provision才会生效
上述配置是把本地的公钥上传到服务器

登录

vagrant ssh centos7

# 使用ssh软件登录,如Putty,Xshell5

安装软件包

# 安装软件包
yum groupinstall "Compatibility libraries" "Base" "Development tools" -y
yum groupinstall "debugging Tools" "Dial-up Networking Support" -y
# 查看选包的情况
yum grouplist

打包box

vagrant package centos7 --output E:\work\box\centos7.4.1708v2.box

Vagrant之CentOS

标签:doc   配置文件   com   打包   mode   服务   virt   conf   ant   

原文:https://www.cnblogs.com/okokabcd/p/8470526.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号