【问题标题】:Is there any way for setting up mongodb as a server with vagrantfile?有没有办法将 mongodb 设置为带有 vagrantfile 的服务器?
【发布时间】:2019-01-26 10:32:40
【问题描述】:

目前我有以下环境: - Windows 7 64 位 - 流浪者 - 虚拟盒子 - 节点 - Webdriverio - 柴 - Appium

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

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

【问题讨论】:

    标签: mongodb vagrant windows-7-x64


    【解决方案1】:

    有一些像这样预装了 MongoDb 的 vagrant 图像 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 获取 vagrant 文件的地方,比如 cd D:\vagrantvagrant up

    【讨论】:

      猜你喜欢
      • 2019-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多