M103: Basic Cluster Administration chapter 0 Introduction学习记录

原创 2018年04月15日 23:55:37

M103: Basic Cluster Administration chapter 0 Introduction学习记录

运行环境

操作系统:windows 10 家庭中文版
Mongodb :Mongodb 3.4

Mongodb安装路径:E:>MongoDB\Server\3.4\bin\
Mongodb存储路径:E:>MongoDB\data

课后问题

lab

Download Handouts:

m103/m103-vagrant-env.zip

In order to effectively learn from this class, you should be completing problems in a real MongoDB cluster. To do this, we will use a development environment called Vagrant that makes it easy to provision a virtual machine with Virtualbox.

We first need to download Vagrant and Virtualbox. Vagrant requires that we use version 5.1 of Virtualbox (in the link), so click the link and download the correct option for your operating system.

Now, download the handout above and create a folder in your home directory called m103. Copy the handout to this directory and then navigate to the handout directory m103-vagrant-env in your terminal. Bring up your Vagrant environment by running these commands (this will take a few minutes):

vagrant up --provision

This command brings up your virtual machine, if it’s not already running. It also builds directories in the VM and downloads all the software and validation scripts necessary to complete this course.

vagrant ssh

This command connects to your Vagrant instance using SSH. To validate that your box is running properly, execute the following command from the Vagrant command line:

validate_box

Please enter the validation key you receive here:

解答

按题目要求下载文件m103/m103-vagrant-env.zip,并解压至路径E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env

分别下载并安装Vagrant 和Virtualbox工具

切换至m103/m103-vagrant-env.zip文件的解压路径:

C:\Users\Shinelon>e:

E:\>cd E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env

启动vagrant环境(第一次启动需要下载很多文件包,需确保网络通畅):

E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env>vagrant up --provision
E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env>vagrant up --provision
Bringing machine 'mongod-m103' up with 'virtualbox' provider...
==> mongod-m103: Running provisioner: shell...
    mongod-m103: Running: C:/Users/Shinelon/AppData/Local/Temp/vagrant-shell20180415-6724-19t9v00
    mongod-m103: + config
    mongod-m103: + sudo su
    mongod-m103: + echo -e never
    mongod-m103: + echo -e never
    mongod-m103: + echo manual
    mongod-m103: + sudo tee /etc/init/mongod.override
    mongod-m103: manual
    mongod-m103: Install MongoDB Enterprise Repository
    mongod-m103: + update_repo
    mongod-m103: + echo 'Install MongoDB Enterprise Repository'
    mongod-m103: + echo 'deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu trusty/mongodb-enterprise/testing multiverse'
    mongod-m103: + sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
    mongod-m103: deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu trusty/mongodb-enterprise/testing multiverse
    mongod-m103: + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
    mongod-m103: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.teCsAxoEF2 --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
    mongod-m103: gpg:
    mongod-m103: requesting key A15703C6 from hkp server keyserver.ubuntu.com
    mongod-m103: gpg:
    mongod-m103: key A15703C6: "MongoDB 3.4 Release Signing Key <packaging@mongodb.com>" not changed
    mongod-m103: gpg:
    mongod-m103: Total number processed: 1
    mongod-m103: gpg:
    mongod-m103:              unchanged: 1
    mongod-m103: + echo 'Update Repositories'
    mongod-m103: Update Repositories
    mongod-m103: + sudo apt-get update -y
    mongod-m103: Hit http://security.ubuntu.com trusty-security InRelease
    mongod-m103: Ign http://repo.mongodb.com trusty/mongodb-enterprise/testing InRelease
    mongod-m103: Ign http://archive.ubuntu.com trusty InRelease
    mongod-m103: Hit http://security.ubuntu.com trusty-security/main Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates InRelease
    mongod-m103: Get:1 http://repo.mongodb.com trusty/mongodb-enterprise/testing Release.gpg [801 B]
    mongod-m103: Hit http://security.ubuntu.com trusty-security/universe Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports InRelease
    mongod-m103: Hit http://security.ubuntu.com trusty-security/main amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty Release.gpg
    mongod-m103: Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/main Sources
    mongod-m103: Hit http://repo.mongodb.com trusty/mongodb-enterprise/testing Release
    mongod-m103: Ign http://repo.mongodb.com trusty/mongodb-enterprise/testing Release
    mongod-m103: Hit http://security.ubuntu.com trusty-security/main Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/restricted Sources
    mongod-m103: Hit http://security.ubuntu.com trusty-security/universe Translation-en
    mongod-m103: Ign http://repo.mongodb.com trusty/mongodb-enterprise/testing/multiverse amd64 Packages/DiffIndex
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/universe Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/multiverse Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/main amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/restricted amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/universe amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/main Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/multiverse Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/restricted Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-updates/universe Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/main Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/restricted Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/universe Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/multiverse Sources
    mongod-m103: Hit http://repo.mongodb.com trusty/mongodb-enterprise/testing/multiverse amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/main amd64 Packages
    mongod-m103: Ign http://repo.mongodb.com trusty/mongodb-enterprise/testing/multiverse Translation-en_US
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/restricted amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/universe amd64 Packages
    mongod-m103: Ign http://repo.mongodb.com trusty/mongodb-enterprise/testing/multiverse Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/main Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/multiverse Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/restricted Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty-backports/universe Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty Release
    mongod-m103: Hit http://archive.ubuntu.com trusty/main Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty/restricted Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty/universe Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty/multiverse Sources
    mongod-m103: Hit http://archive.ubuntu.com trusty/main amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty/universe amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty/multiverse amd64 Packages
    mongod-m103: Hit http://archive.ubuntu.com trusty/main Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty/multiverse Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty/restricted Translation-en
    mongod-m103: Hit http://archive.ubuntu.com trusty/universe Translation-en
    mongod-m103: Ign http://archive.ubuntu.com trusty/main Translation-en_US
    mongod-m103: Ign http://archive.ubuntu.com trusty/multiverse Translation-en_US
    mongod-m103: Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
    mongod-m103: Ign http://archive.ubuntu.com trusty/universe Translation-en_US
    mongod-m103: Fetched 801 B in 27s (29 B/s)
    mongod-m103: Reading package lists...
    mongod-m103: W
    mongod-m103: :
    mongod-m103: GPG error: http://repo.mongodb.com trusty/mongodb-enterprise/testing Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 58712A2291FA4AD5
    mongod-m103: + echo 'Installing MongoDB Enterprise Dependencies'
    mongod-m103: Installing MongoDB Enterprise Dependencies
    mongod-m103: + sudo apt-get install -y libgssapi-krb5-2 libsasl2-2 libssl1.0.0 libstdc++6 snmp
    mongod-m103: Reading package lists...
    mongod-m103: Building dependency tree...
    mongod-m103: Reading state information...
    mongod-m103: libsasl2-2 is already the newest version.
    mongod-m103: libgssapi-krb5-2 is already the newest version.
    mongod-m103: libssl1.0.0 is already the newest version.
    mongod-m103: libstdc++6 is already the newest version.
    mongod-m103: snmp is already the newest version.
    mongod-m103: 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
    mongod-m103: + install_mongod
    mongod-m103: + echo 'Install MongoDB Enterprise'
    mongod-m103: Install MongoDB Enterprise
    mongod-m103: + sudo apt-get install --force-yes -y mongodb-enterprise
    mongod-m103: Reading package lists...
    mongod-m103: Building dependency tree...
    mongod-m103: Reading state information...
    mongod-m103: mongodb-enterprise is already the newest version.
    mongod-m103: 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
    mongod-m103: + mkdir -p /var/log/mongodb/
    mongod-m103: + sudo chown vagrant:vagrant -R /var/log/mongodb
    mongod-m103: + sudo chown vagrant:vagrant -R /var/lib/mongodb
    mongod-m103: + sudo echo '
    mongod-m103: security:
    mongod-m103:   authorization: enabled'
    mongod-m103: + sudo tee -a /etc/mongod.conf
    mongod-m103:
    mongod-m103: security:
    mongod-m103:   authorization: enabled
    mongod-m103: + echo 'Done installing MongoDB Enterprise'
    mongod-m103: Done installing MongoDB Enterprise
    mongod-m103: + user_setup
    mongod-m103: + sudo sh -c 'killall mongod; true'
    mongod-m103: mongod: no process found
    mongod-m103: + sudo mkdir -p /data
    mongod-m103: + sudo chmod -R 777 /data
    mongod-m103: + mkdir -p /data/db
    mongod-m103: + mkdir -p /home/vagrant/data
    mongod-m103: + chmod -R 777 /home/vagrant/data
    mongod-m103: + chown -R vagrant:vagrant /home/vagrant/data
    mongod-m103: + mkdir -p /var/m103/validation
    mongod-m103: + echo 'Set LC_ALL=C to .profile'
    mongod-m103: Set LC_ALL=C to .profile
    mongod-m103: + sudo echo 'export LC_ALL=C'
    mongod-m103: + sudo echo PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/var/m103/validation
    mongod-m103: + data_path
    mongod-m103: + sudo mkdir -p /data
    mongod-m103: + sudo chown -R vagrant:vagrant /data
    mongod-m103: + install_pymongo
    mongod-m103: + sudo apt-get -y install python-pip
    mongod-m103: Reading package lists...
    mongod-m103: Building dependency tree...
    mongod-m103: Reading state information...
    mongod-m103: python-pip is already the newest version.
    mongod-m103: 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
    mongod-m103: + sudo pip install pymongo
    mongod-m103: Requirement already satisfied (use --upgrade to upgrade): pymongo in /usr/local/lib/python2.7/dist-packages
    mongod-m103: Cleaning up...
    mongod-m103: + download_dataset
    mongod-m103: + echo 'Downloading Dataset'
    mongod-m103: Downloading Dataset
    mongod-m103: + curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.json.tgz -o products.json.tgz

开启另一个窗口,进入此box:

C:\Users\Shinelon>e:

E:\>cd MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env

E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env>vagrant ssh
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-144-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sun Apr 15 14:24:35 UTC 2018

  System load:  0.15              Processes:           89
  Usage of /:   3.6% of 39.34GB   Users logged in:     0
  Memory usage: 6%                IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.

New release '16.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

执行所给出命令:

vagrant@m103:~$ validate_box
validate_box: command not found

等待很久以后,box终于完全打开,显示如下:

    mongod-m103:         sudo tar -xzvf m103_validation.tgz -C /var/m103/validation
    mongod-m103:         rm -rf m103_validation.tgz'
    mongod-m103: + echo '#!/bin/bash
    mongod-m103:         echo -n '\''m103 rocks'\'' | openssl sha256 | sed -e s/\(stdin\)=.//'
    mongod-m103: + chmod -R +x /var/m103/validation/
    mongod-m103: + chown root:root /var/m103/validation
    mongod-m103: + echo 'Done: Downloaded Validation Scripts'
    mongod-m103: Done: Downloaded Validation Scripts
    mongod-m103: + echo DONE
    mongod-m103: DONE

E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env>

此时再在box中执行查询就可得到结果:

vagrant@m103:~$ validate_box
6445a3f8b6f1cc5873cf1ac94194903444602708d4eb189d42b6e65ca594d80d

解析

检查E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env路径下的控制文件Vagrantfile,发现其中有一行:

server.vm.provision :shell, path: "provision-mongod", args: ENV['ARGS']

检查此provision-mongod脚本文件(也存放在E:\MongoDB\m103\chapter_0_introduction_setup\m103-vagrant-env路径下),发现validate_box文件的创建语句:

echo "#!/bin/bash
        curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/m103_validation.tgz -o m103_validation.tgz
        sudo tar -xzvf m103_validation.tgz -C /var/m103/validation
        rm -rf m103_validation.tgz" > /var/m103/validation/download_validators
  echo "#!/bin/bash
        echo -n 'm103 rocks' | openssl sha256 | sed -e s/\(stdin\)=.//" > /var/m103/validation/validate_box
  chmod -R +x /var/m103/validation/
  chown root:root /var/m103/validation

可推断出validate_box文件的路径为/var/m103/validation/validate_box,内容为:

#!/bin/bash
        echo -n 'm103 rocks' | openssl sha256 | sed -e s/\(stdin\)=.//

在box中任意创建一个文件,写入此内容并授予权限:

vagrant@m103:~$ vim a

#!/bin/bash
        echo -n 'm103 rocks' | openssl sha256 | sed -e s/\(stdin\)=.//


vagrant@m103:~$ chmod 755 ./a

执行此文件,同样可得到结果,还不用等( ̄▽ ̄)”

vagrant@m103:~$ ./a
6445a3f8b6f1cc5873cf1ac94194903444602708d4eb189d42b6e65ca594d80d

M103: Basic Cluster Administration chapter 1 The Mongod学习记录

M103: Basic Cluster Administration chapter 1 The Mongod学习记录 运行环境 操作系统:windows 10 家庭中文版 Mongodb ...
  • sunbocong
  • sunbocong
  • 2018-04-16 16:25:40
  • 85

最近在看英文版的高数书calculus···

calculus···还是从高中的数学基础知识,发现还是看英文版更能了解数学的含义···记得初中时候学过1个e的符号,一直到高中都不知道有什么确切的用途,结果看了英文版本的calculus后,才明白过...
  • huruihappy
  • huruihappy
  • 2009-08-07 15:42:00
  • 563

AX 2009 Mangement

  • 2013年11月19日 01:28
  • 852KB
  • 下载

Introduction to Algorithms, Second Edition _ONE (Adding)

  Introduction to Algorithms(Second Edition)【原书名】 Introduction to Algorithms(Second Edition) 【原出版社】 ...
  • dfreng
  • dfreng
  • 2008-10-19 12:04:00
  • 5895

统计学习导论 Chapter2--What Is Statistical Learning?

Book: An Introduction to Statistical Learning with Applications in R http://...
  • zhangjunhit
  • zhangjunhit
  • 2017-11-21 09:49:57
  • 289

Data.Manipulation.with.R.2nd.Edition.1785288814

  • 2015年05月29日 10:57
  • 1.34MB
  • 下载

Algebra Chapter 0 (Paolo Aluffi) pdf

  • 2018年03月21日 23:44
  • 21.35MB
  • 下载

RHCE RHCA Shell 运维

  • 2013年09月11日 12:08
  • 1.43MB
  • 下载

ES-338 Sun Cluster 3.1 Administration

  • 2011年02月20日 17:09
  • 3.01MB
  • 下载

《pattern recognition》 3rd by Sergios

  • 2009年05月28日 22:16
  • 12.93MB
  • 下载
收藏助手
不良信息举报
您举报文章:M103: Basic Cluster Administration chapter 0 Introduction学习记录
举报原因:
原因补充:

(最多只允许输入30个字)