有没有办法将 mongodb 设置为带有 vagrantfile 的服务器



目前我在下面有环境:- 视窗 7 64 位-流浪- 虚拟盒子- Nodejs- 网络司机-柴- 阿普姆

我想用流浪者构建一个数据库服务器(使用 mongodb),我将作为客户端从我的 PC 连接。然后,我可以运行脚本在此数据库上创建测试数据。我将只为服务器(虚拟机)和客户端(物理机)使用一台 PC

有可能建立这个想法吗?以及如何实施它?如果有的话,请给我一些建议。

有一些预装了 MongoDb 的流浪映像,如下所示https://app.vagrantup.com/dansweeting/boxes/ubuntu-trusty64-mongo-node

创建流浪文件前任:

# created by Andrei Lupuleasa, December 2018.
Vagrant.require_version ">= 2.2.2"
# Automatically installs required plugin on Windows
if Vagrant::Util::Platform.windows?
  plugin = 'vagrant-winnfsd'
  system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin?(plugin)
end
Vagrant.configure(2) do |config|
  config.vm.box      = "dansweeting/ubuntu-trusty64-mongo-node" # VM OS version
  config.vm.hostname = "vagrantdev"
  # set IP and ports
  config.vm.network "private_network", ip: "192.168.44.10"
  # Sync the sources folder with the machine
  # For Windows `nfs` is preferred due to poor performance of default settings.
  if Vagrant::Util::Platform.windows?
    config.vm.synced_folder "share", "/var/www/html", type: 'nfs'
  else
    config.vm.synced_folder "share", "/var/www/html", mount_options: ["dmode=777","fmode=777"]
  end
  # Set to true if you want automatic checks
  config.vm.box_check_update = false
  # Copy personal private key with access to repository to machine
  config.vm.provision "file", source: "~/.ssh/id_rsa", destination: "~/.ssh/id_rsa"  
  config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub"
end

去你从cmd有流浪文件的地方,比如 cd D:vagrant并执行vagrant up

最新更新