vagrant鎼缓centos鐜

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vagrant鎼缓centos鐜相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/org' title='org'>org   htm   鐩稿悓   form   cti   reload   vagrant   杩炴帴   

vagrant鎼缓centos鐜

鍓嶈█

macos浣滀负寮€鍙戠幆澧冨凡缁忕浉褰撴柟渚匡紝鏈夊緢涓板瘜鐨勫伐鍏凤紝濡?code>homebrew绫讳技浜巙buntu鐨?code>apt-get鍜宑entos鐨?code>yum锛屽緢鏂逛究鍦板畨瑁呭悇绉嶅紑鍙戝伐鍏枫€備絾缁堢┒涓庣嚎涓婄敓浜х幆澧冧笉鍚岋紝鍗充究瀹夎鐨勬槸鐩稿悓鐨勮蒋浠讹紝瀹夎鐩綍锛岀鐞嗘柟寮忛兘鏈夋墍涓嶅悓銆傚綋椤圭洰寰堝鏉傦紝鎴栬€呮湁澶氫釜椤圭洰鏃讹紝寰堝鏄撳皢mac鏈湴鐜寮勫緱涔变竷鍏碂銆?/p>

涓轰簡鑳戒笌绾夸笂鐢熶骇鐜涓€鑷达紝灏濊瘯杩囩敤docker, 骞舵病鏈夋兂璞′腑鐨勬柟渚匡紝鍙兘鏄垜瀵筪okcer鐨勪簡瑙eお灏戙€備笖瑙夊緱docker鐨勯棬妲涜緝楂樸€?/p>

琛¢噺鍚勭鏂规鍚庯紝鏈€缁堥€夋嫨鐢╲agrant涓巚irtualBox鎼缓涓€涓畬鏁寸殑linux绯荤粺锛岃繖鏍疯兘澶熶笌绾夸笂鐢熶骇鐜涓€鑷达紝涔熻兘寰堟柟渚垮湴杩涜绉绘銆?/p>

鐜鍑嗗

鎴戦€夋嫨鐨勬槸 centos7.2 鐨勯暅鍍?/p>

瀹夎

鏂板缓鐩綍centos锛屼綔涓簐agrant鐨勬牴鐩綍

  • 瀵煎叆涓嬭浇鐨勯暅鍍?/li>
?  centos  vagrant box add centos ~/Downloads/vagrant-centos-7.2.box
# 灏哹ox鍛藉悕涓篶entos
  • 鍒濆鍖?/li>
?  centos  vagrant init

浼氳嚜鍔ㄧ敓鎴?code>Vagrantfile閰嶇疆鏂囦欢

淇敼閰嶇疆鏂囦欢

璁剧疆box鍚嶇О

box鍚嶇О椤讳笌涓婇潰鍛戒护鎸囧畾鐨刡ox鍚嶄竴鑷?/p>

config.vm.box = "centos"

绔彛杞彂

config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

macos涓嶅厑璁稿皢鏈満鐨?0绔彛杞彂, 瑙e喅鏂规鍙傜収锛?mac璁剧疆绔彛杞彂

寮€鍚痭fs

榛樿鐨剉irtualBox鍏变韩鏂囦欢閫熷害澶參锛岄渶瑕佸惎鐢╪fs榛樿

Vagrantfile 璁剧疆锛?/p>

config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder "/Users/airmb/Downloads/work", "/home/wwwroot/work", :nfs => true, :mount_options => ['actimeo=2']

璁剧疆鍐呭瓨

鍐呭瓨澶у皬鏍规嵁鐗╃悊鏈哄唴瀛樿缃紝鎴戠殑mac鐗╃悊鏈烘槸8G鍐呭瓨锛屽垎閰嶄簡3G缁欒櫄鎷熸満

濡傛灉瑕佸畨瑁卪ysql5.7锛屽唴瀛樹笉鑳戒綆浜?G

config.vm.provider "virtualbox" do |vb|
  vb.memory = "3072"
end

鏌ョ湅ssh-config

鍙互鐢╲agrant榛樿鐢熸垚鐨刱ey,涔熷彲浠ュ皢鑷繁鐨勭閽ユ浛鎹㈠埌 IdentityFile 鎸囧畾鐨勬枃浠讹紝杩炴帴铏氭嫙鏈哄悗鍐嶅皢鍏挜鏀惧埌铏氭嫙鏈轰腑鐨?~/.ssh/authorized_keys

鍚姩铏氭嫙鏈?/p>

?  centos  vagrant up

杩炴帴杩涘叆铏氭嫙鏈?/p>

?  centos  vagrant ssh

榛樿鐨勫叡浜寕杞界洰褰曪細/home/vagrant

甯哥敤vagrant鍛戒护

  • vagrant up 鍚姩
  • vagrant ssh 杩涘叆铏氭嫙鏈?/li>
  • vagrant halt 鍏虫満
  • vagrant reload 閲嶅惎
  • 瀵煎嚭涓庡鍏?/li>
?  centos  vagrant package --base centos_default_1533259579120_24934 --out centos7.2.box # 瀵煎嚭box
?  centos  vagrant box add centos ./centos7.2.box # 瀵煎叆box

娓呯┖閲嶆柊瀵煎叆闀滃儚

褰撻渶瑕侀噸鏂板鍏ラ暅鍍忔椂锛屼负閬垮厤鍑虹幇鍚勭濂囧鎬€殑闂锛屾竻绌轰互涓嬪唴瀹癸細

# 灏嗙幇鏈夌殑box鍒犻櫎
?  centos  vagrant box list
centos (virtualbox, 0)
?  centos  vagrant box remove centos

?  centos  vagrant global-status --prune

?  centos  rm -rf .vagrant

?  centos  rm -rf Vagrantfile

?  centos  cd ~/VirtualBox\ VMs
?  VirtualBox VMs  ls
centos_default_1534145188471_82398
?  VirtualBox VMs  rm -rf ./*

閰嶇疆鏂囦欢 Vagrantfile

绔彛杞彂

config.vm.network "forwarded_port", guest: 80, host: 8080

鍐呭瓨鍒嗛厤

config.vm.provider "virtualbox" do |vb|
#   # Display the VirtualBox GUI when booting the machine
#   vb.gui = true
#
#   # Customize the amount of memory on the VM:
    vb.memory = "3072"
end

鐩綍鎸傝浇

config.vm.synced_folder "~/code", "/home/wwwroot/code", :owner=> 'vagrant', :group=>'www', :mount_options => ['dmode=775', 'fmode=775']

濉潙璁板綍

锛堟暟鎹瀛﹀涔犳墜鏈?1锛塩onda+jupyter鐜╄浆鏁版嵁绉戝鐜鎼缓

sparksql绯诲垪(涓€)鐜鎼缓

Hadoop+HBase+Spark+Hive鐜鎼缓

棰樺璇濓細2020 骞磋鎬庝箞鐢?Intellij IDEA 鎼缓 Haskell 鐜

LNMP鎼缓

鍩轰簬 Centos 7 鎼缓Nginx锛堝寘鍚櫄鎷熶富鏈猴級