{"id":7734,"date":"2016-05-24T10:59:01","date_gmt":"2016-05-24T02:59:01","guid":{"rendered":"http:\/\/jpuyy.com\/?p=7734"},"modified":"2020-04-20T17:38:53","modified_gmt":"2020-04-20T09:38:53","slug":"vagrant%e4%bd%bf%e7%94%a8%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=7734","title":{"rendered":"vagrant\u4f7f\u7528\u7b14\u8bb0"},"content":{"rendered":"<p>\u5b89\u88c5 vagrant<\/p>\n<pre>https:\/\/www.vagrantup.com\/downloads.html\n<\/pre>\n<p>\u5982\u679c\u7f51\u7edc\u4e0d\u597d\u9996\u5148\u4e0b\u8f7d box \uff0c\u6bd4\u5982 centos6.box centos7.box<\/p>\n<p>\u6ce8\u518c\u4e00\u4e2a box\uff0c\u7ecf\u5e38\u7528\u7684\u53ef\u4ee5\u6dfb\u52a0\u4e3a base\uff0c\u505a\u4e3a default box<\/p>\n<pre>vagrant box add base ~\/osx-dmg\/centos7.box\nvagrant box add centos6 ~\/osx-dmg\/centos6.box\nvagrant box add centos7 ~\/osx-dmg\/centos7.box\n<\/pre>\n<p>\u67e5\u770b\u5df2\u7ecf\u5bfc\u5165\u7684 box<\/p>\n<pre>vagrant box list\n#\u6216\u8005\nls -l ~\/.vagrant.d\/boxes\n<\/pre>\n<p>\u5982\u679c\u7f51\u7edc\u6761\u4ef6\u597d\uff0c\u6dfb\u52a0\u5b98\u65b9\u7684 centos\/7 (\u6ce8\u610f\u5199\u6cd5)<\/p>\n<pre>$ vagrant box add centos\/7\n==&gt; box: Loading metadata for box 'centos\/7'\n    box: URL: https:\/\/vagrantcloud.com\/centos\/7\nThis box can work with multiple providers! The providers that it\ncan work with are listed below. Please review the list and choose\nthe provider you will be working with.\n\n1) hyperv\n2) libvirt\n3) virtualbox\n4) vmware_desktop\n\nEnter your choice: 2\n<\/pre>\n<p>\u5de5\u4f5c\u76ee\u5f55\u4e3a ~\/test\uff0c\u8fdb\u5165\u76ee\u5f55\uff0c\u521b\u5efa\u4e00\u53f0 centos7 \u7684\u673a\u5668\uff0c<code>--minimal<\/code> \u751f\u6210\u7684\u6587\u4ef6\u6ca1\u6709\u6ce8\u91ca<\/p>\n<pre>vagrant init centos\/7 --minimal\n<\/pre>\n<p>\u542f\u52a8<\/p>\n<pre>vagrant up<\/pre>\n<p>\u8fde\u63a5 vagrant<\/p>\n<pre>vagrant ssh\n<\/pre>\n<p>\u6267\u884c id \u547d\u4ee4<\/p>\n<pre>vagrant ssh -c 'id'<\/pre>\n<p>\u67e5\u770b\u5f53\u524d vagrant \u7ba1\u7406\u7684\u673a\u5668\uff0c\u6700\u524d\u9762\u4e3a\u673a\u5668 id<\/p>\n<pre>                                                                                \nvagrant global-status\n<\/pre>\n<p>\u4fee\u526a vagrant \u5df2\u7ecf\u574f\u6389\u7684\u673a\u5668<\/p>\n<pre>                                                   \nvagrant global-status --prune\n<\/pre>\n<p>\u5982\u679c\u6709\u4e0d\u9700\u8981\u7684 box<\/p>\n<pre>                                                                \nvagrant destroy id\n<\/pre>\n<p>\u51c6\u5907\u591a\u53f0\u865a\u62df\u673a\u73af\u5883<\/p>\n<pre>  config.vm.define \"web\" do |web|                                               \n    web.vm.box = \"centos6\"                                                      \n  end                                                                           \n                                                                                \n  config.vm.define \"db\" do |db|                                                 \n    db.vm.box = \"centos6\"                                                       \n  end\n<\/pre>\n<p>\u67e5\u770b\u673a\u5668\u7684\u72b6\u6001<\/p>\n<pre>vagrant status<\/pre>\n<p>\u67e5\u770b ssh \u4fe1\u606f<\/p>\n<pre>vagrant ssh-config<\/pre>\n<p>\u5173\u95ed vm<\/p>\n<pre>vagrant halt<\/pre>\n<p>\u4e0d\u9700\u8981\u7684 box \u5220\u9664<\/p>\n<pre>vagrant box remove centos\/7<\/pre>\n<p>vagrant \u5b98\u65b9 centos7 box:<\/p>\n<pre>https:\/\/vagrantcloud.com\/centos\/7\/<\/pre>\n<p>centos \u63d0\u4f9b\u7684 box:<\/p>\n<pre>http:\/\/cloud.centos.org\/centos\/7\/vagrant\/x86_64\/images\/<\/pre>\n<p>windows 10 \u5c06 virtualbox \u6362\u4e3a hyperv<br \/>\n\u4e0a\u9762\u83b7\u53d6 box \u6b65\u9aa4\u65f6\u9009 hyperv, \u5c06\u539f\u6765 virtualbox \u7684\u76f8\u5173 box \u5220\u9664<\/p>\n<pre>vagrant.exe box  remove centos\/7 --provider virtualbox --all<\/pre>\n<p>\u5207\u5230\u76ee\u5f55\u4e0b,\u5220\u9664\u76f8\u5173\u7684 vm<br \/>\nvagrant.exe destroy<br \/>\n\u542f\u52a8<\/p>\n<pre>vagrant up --provider hyperv<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5 vagrant https:\/\/www.vagrantup.com\/downloads.html \u5982\u679c\u7f51\u7edc\u4e0d\u597d\u9996\u5148\u4e0b\u8f7d box \uff0c\u6bd4\u5982 centos6.box centos7.box \u6ce8\u518c\u4e00\u4e2a box\uff0c\u7ecf\u5e38\u7528\u7684\u53ef\u4ee5\u6dfb\u52a0\u4e3a base\uff0c\u505a\u4e3a default box vagrant box add base ~\/osx-dmg\/centos7.box vagrant box add centos6 ~\/osx-dmg\/centos6.box vagrant box add centos7 ~\/osx-dmg\/centos7.box \u67e5\u770b\u5df2\u7ecf\u5bfc\u5165\u7684 box vagrant box list #\u6216\u8005 ls -l ~\/.vagrant.d\/boxes \u5982\u679c\u7f51\u7edc\u6761\u4ef6\u597d\uff0c\u6dfb\u52a0\u5b98\u65b9\u7684 centos\/7 (\u6ce8\u610f\u5199\u6cd5) $ vagrant box add centos\/7 ==&gt; box: Loading metadata for box &#8216;centos\/7&#8217; box: URL: https:\/\/vagrantcloud.com\/centos\/7 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-7734","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7734"}],"version-history":[{"count":24,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7734\/revisions"}],"predecessor-version":[{"id":8854,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7734\/revisions\/8854"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}