使用Vagrant配置本地開發環境

      網友投稿 917 2025-04-03

      從二零一四年開始使用vagrant+VirtualBox搭建linux開發環境,配置簡單靈活,后臺運行占用內存少,比vmware好用很多,果斷棄用vmware轉投vagrant的懷抱;無論是個人搭建開發環境還是團隊統一開發環境,vagrant是最方便快捷的方式。


      問題一:

      但是最近在使用的時候遇到一些坑,記錄下來以免下次遇到浪費時間去查找解決;經過是這樣的:從家里的agrant打包了一份開發環境到公司的新電腦上,vagrant init {boxname}初始化后使用vagrant up啟動虛擬機卻一直啟動失敗,提示如下:

      D:\webroot\vagrant>vagrant up

      Bringing machine 'default' up with 'VirtualBox' provider...

      ==> default: Clearing any previously set forwarded ports...

      ==> default: Clearing any previously set network interfaces...

      ==> default: Preparing network interfaces based on configuration...

      default: Adapter 1: nat

      ==> default: Forwarding ports...

      default: 22 => 2222 (adapter 1)

      ==> default: Booting VM...

      ==> default: Waiting for machine to boot. This may take a few minutes...

      default: SSH address: 127.0.0.1:2222

      default: SSH username: vagrant

      default: SSH auth method: private key

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      default: Warning: Connection timeout. Retrying...

      Timed out while waiting for the machine to boot. This means that

      Vagrant was unable to communicate with the guest machine within

      the configured ("config.vm.boot_timeout" value) time period.

      If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong.

      If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly,as well.

      If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.

      通過查找資料,在stackowverflow上有網友也遇到過相同問題并給出解決方案如下:

      將Vagrantfile配置文件中vb.gui = true的注釋去掉

      config.vm.provider "virtualbox" do |vb|

      # # Don't boot with headless mode

      vb.gui = true

      #

      # # Use VBoxManage to customize the VM. For example to change memory:

      # vb.customize ["modifyvm", :id, "--memory", "1024"]

      end

      運行vagrant up 啟動 virtualbox 后,GUI會給出提示

      VT-x/AMD-V硬件加速在您的系統中不可用。您的64-位虛擬機將無法檢測到 64-位處理器,從而無法啟動。

      這是由于在BOIS中沒有開啟cpu虛擬化支持,重啟F2或F10等進入BIOS設置Virtualization為Enable(我的Thinkpad是Security=>Virtualizatio設置為Enable);

      電腦重啟后,再次vagrant up啟動虛擬機還是有一些問題,當時也沒有記錄下來錯誤信息,只記得解決方案是使用vagrant destroy將虛擬機從磁盤中刪除,然后使用vagrant up命令重新創建。

      問題二 (2015.5.7更新)

      vagrant啟動報錯The following SSH command responded with a non-zero exit status.

      D:\vagrant_web>vagrant up

      Bringing machine 'default' up with 'virtualbox' provider...

      ==> default: Clearing any previously set forwarded ports...

      ==> default: Clearing any previously set network interfaces...

      ==> default: Preparing network interfaces based on configuration...

      default: Adapter 1: nat

      default: Adapter 2: hostonly

      ==> default: Forwarding ports...

      default: 80 => 8080 (adapter 1)

      使用Vagrant配置本地開發環境

      default: 3000 => 3000 (adapter 1)

      default: 22 => 2222 (adapter 1)

      ==> default: Booting VM...

      ==> default: Waiting for machine to boot. This may take a few minutes...

      default: SSH address: 127.0.0.1:2222

      default: SSH username: vagrant

      default: SSH auth method: private key

      default: Warning: Connection timeout. Retrying...

      ==> default: Machine booted and ready!

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

      ==> default: Configuring and enabling network interfaces...

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

      Vagrant assumes that this means the command failed!

      ARPCHECK=no /sbin/ifup eth1 2> /dev/null

      Stdout from the command:

      Device eth1 does not seem to be present, delaying initialization.

      Stderr from the command:

      雖然vagrant up啟動報錯,但是vagrant ssh還是能登陸虛擬機的,進入虛擬機后,執行如下命令

      sudo rm -f /etc/udev/rules.d/70-persistent-net.rules

      對, 問題就處在在持久網絡設備udev規則(persistent network device udev rules)是被原VM設置好的,再用box生成新VM時,這些rules需要被更新。而這和Vagrantfile里對新VM設置private network的指令發生沖突。刪除就好了。

      vagrant reload 再次啟動就OK。

      以上問題完美解決,記錄下來,避免忘記!

      Vagrant官網 文檔齊全.

      segment安裝使用方法 網友分享的使用說明,簡單明了!

      虛擬化

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:excel如何生成并編輯柱狀圖(excel里怎么生成柱狀圖)
      下一篇:Python學習隨筆
      相關文章
      亚洲无码日韩精品第一页| 国产精品亚洲av色欲三区| 国产成人亚洲综合无码| 亚洲乱码国产乱码精华| 亚洲中文字幕乱码AV波多JI| 国产亚洲福利在线视频| ASS亚洲熟妇毛茸茸PICS| 国产精品亚洲精品| 亚洲综合精品第一页| 亚洲一区二区三区深夜天堂| 亚洲成人免费网址| 亚洲高清中文字幕综合网| 亚洲综合一区二区| 亚洲国产精品成人精品软件| 亚洲国产理论片在线播放| 亚洲AV无码一区二区三区在线| 亚洲成a人片7777| 亚洲av无码专区在线| 久久乐国产综合亚洲精品| 亚洲大尺度无码无码专线一区 | 亚洲人成77777在线播放网站不卡| 亚洲日本在线免费观看| 亚洲国产模特在线播放| 亚洲伊人久久大香线焦| 亚洲综合激情五月丁香六月| 亚洲乱亚洲乱妇24p| 国产成人亚洲综合a∨| 亚洲精品亚洲人成在线观看下载| 亚洲人成人无码网www国产| 337p日本欧洲亚洲大胆裸体艺术 | 国产午夜亚洲不卡| 久久久久国产成人精品亚洲午夜| 亚洲色欲一区二区三区在线观看| 久久久亚洲精品视频| 911精品国产亚洲日本美国韩国 | 亚洲成a人片在线观看日本麻豆| 亚洲第一黄片大全| 亚洲精品无码久久久久去q | 国产大陆亚洲精品国产| 亚洲国产精品狼友中文久久久| 激情综合色五月丁香六月亚洲|