zoukankan      html  css  js  c++  java
  • ubuntu下用vagrant搭建集群环境

    1、安装virtualbox

    终端输入:sudo apt-get install virtualbox(事实从来都不是一番风顺的.......)

    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树
    正在读取状态信息... 完成
    virtualbox-5.0:i386 已经是最新的版本了。
    您可能需要运行“apt-get -f install”来纠正下列错误:
    下列软件包有未满足的依赖关系:
    virtualbox-5.0:i386 : 依赖: libcurl3:i386 (>= 7.16.2) 但是它将不会被安装
    依赖: libdevmapper1.02.1:i386 (>= 2:1.02.20) 但是它将不会被安装
    依赖: libpython2.7:i386 (>= 2.7) 但是它将不会被安装
    依赖: libsdl1.2debian:i386 (>= 1.2.11) 但是它将不会被安装
    依赖: libxmu6:i386 但是它将不会被安装
    依赖: psmisc:i386 但是它将不会被安装
    推荐: libsdl-ttf2.0-0:i386 但是它将不会被安装
    推荐: dkms:i386 但无法安装它
    推荐: linux-headers:i386
    推荐: gcc:i386 但是它将不会被安装
    推荐: binutils:i386 但是它将不会被安装
    推荐: pdf-viewer:i386
    E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“apt-get -f install”(也可以指定一个解决办法)。

    为解决这个问题,按照提示做,终端输入:sudo apt-get -f install(事实通常是一波三折的........)

    W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.ustc.edu.cn_ubuntu_dists_quantal-updates_main_binary-i386_Packages Hash 校验和不符
    W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.ustc.edu.cn_ubuntu_dists_quantal-updates_universe_binary-i386_Packages Hash 校验和不符
    W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.ustc.edu.cn_ubuntu_dists_quantal-security_main_binary-i386_Packages Hash 校验和不符
    W: 无法下载 bzip2:/var/lib/apt/lists/partial/mirrors.ustc.edu.cn_ubuntu_dists_quantal-security_universe_binary-i386_Packages Hash 校验和不符
    E: Some index files failed to download. They have been ignored, or old ones used instead.

    什么鬼......,百度了一下,终于找到了解决办法,终端输入:

    sudo mv /var/lib/apt/lists /var/lib/apt/lists.bak

    sudo mkdir /var/lib/apt/lists
    然后继续:sudo apt-get -f install(成功)
    终于修复了依赖关系
    再试一遍:sudo apt-get install virtualbox(成功)
    将会同时安装下列软件:
      dkms libgsoap8 libqt5x11extras5 libsdl1.2debian libvncserver1
      virtualbox-dkms virtualbox-qt
    建议安装:
      vde2 virtualbox-guest-additions-iso
    下列软件包将被【卸载】:
      virtualbox-5.2:i386
    下列【新】软件包将被安装:
      dkms libgsoap8 libqt5x11extras5 libsdl1.2debian libvncserver1 virtualbox
      virtualbox-dkms virtualbox-qt
    升级了 0 个软件包,新安装了 8 个软件包,要卸载 1 个软件包,有 236 个软件包未被升级。
    需要下载 24.3 MB/24.7 MB 的归档。
    解压缩后将会空出 77.8 MB 的空间。
    您希望继续执行吗? [Y/n] y
    获取:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libsdl1.2debian amd64 1.2.15+dfsg1-3 [168 kB]
    获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox-dkms all 5.1.38-dfsg-0ubuntu1.16.04.1 [650 kB]
    获取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox amd64 5.1.38-dfsg-0ubuntu1.16.04.1 [15.9 MB]
    获取:4 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox-qt amd64 5.1.38-dfsg-0ubuntu1.16.04.1 [7,503 kB]
    已下载 24.3 MB,耗时 2分 46秒 (146 kB/s)                                                                                                                                                                   
    (正在读取数据库 ... 系统当前共安装有 405828 个文件和目录。)
    正在卸载 virtualbox-5.2:i386 (5.2.16-123759~Ubuntu~xenial) ...
    正在处理用于 libc-bin (2.23-0ubuntu10) 的触发器 ...
    正在处理用于 gnome-menus (3.13.3-6ubuntu3.1) 的触发器 ...
    正在处理用于 desktop-file-utils (0.22-1ubuntu5.1) 的触发器 ...
    正在处理用于 bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) 的触发器 ...
    Rebuilding /usr/share/applications/bamf-2.index...
    正在处理用于 mime-support (3.59ubuntu1) 的触发器 ...
    正在处理用于 shared-mime-info (1.5-2ubuntu0.1) 的触发器 ...
    正在处理用于 hicolor-icon-theme (0.15-0ubuntu1) 的触发器 ...
    正在选中未选择的软件包 dkms。
    (正在读取数据库 ... 系统当前共安装有 404991 个文件和目录。)
    正准备解包 .../dkms_2.2.0.3-2ubuntu11.5_all.deb  ...
    正在解包 dkms (2.2.0.3-2ubuntu11.5) ...
    正在选中未选择的软件包 libgsoap8:amd64。
    正准备解包 .../libgsoap8_2.8.28-1_amd64.deb  ...
    正在解包 libgsoap8:amd64 (2.8.28-1) ...
    正在选中未选择的软件包 libqt5x11extras5:amd64。
    正准备解包 .../libqt5x11extras5_5.5.1-3build1_amd64.deb  ...
    正在解包 libqt5x11extras5:amd64 (5.5.1-3build1) ...
    正在选中未选择的软件包 libsdl1.2debian:amd64。
    正准备解包 .../libsdl1.2debian_1.2.15+dfsg1-3_amd64.deb  ...
    正在解包 libsdl1.2debian:amd64 (1.2.15+dfsg1-3) ...
    正在选中未选择的软件包 libvncserver1:amd64。
    正准备解包 .../libvncserver1_0.9.10+dfsg-3ubuntu0.16.04.2_amd64.deb  ...
    正在解包 libvncserver1:amd64 (0.9.10+dfsg-3ubuntu0.16.04.2) ...
    正在选中未选择的软件包 virtualbox-dkms。
    正准备解包 .../virtualbox-dkms_5.1.38-dfsg-0ubuntu1.16.04.1_all.deb  ...
    正在解包 virtualbox-dkms (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    正在选中未选择的软件包 virtualbox。
    正准备解包 .../virtualbox_5.1.38-dfsg-0ubuntu1.16.04.1_amd64.deb  ...
    正在解包 virtualbox (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    正在选中未选择的软件包 virtualbox-qt。
    正准备解包 .../virtualbox-qt_5.1.38-dfsg-0ubuntu1.16.04.1_amd64.deb  ...
    正在解包 virtualbox-qt (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    正在处理用于 man-db (2.7.5-1) 的触发器 ...
    正在处理用于 libc-bin (2.23-0ubuntu10) 的触发器 ...
    正在处理用于 systemd (229-4ubuntu21.2) 的触发器 ...
    正在处理用于 ureadahead (0.100.0-19) 的触发器 ...
    正在处理用于 hicolor-icon-theme (0.15-0ubuntu1) 的触发器 ...
    正在处理用于 gnome-menus (3.13.3-6ubuntu3.1) 的触发器 ...
    正在处理用于 desktop-file-utils (0.22-1ubuntu5.1) 的触发器 ...
    正在处理用于 bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) 的触发器 ...
    Rebuilding /usr/share/applications/bamf-2.index...
    正在处理用于 mime-support (3.59ubuntu1) 的触发器 ...
    正在处理用于 shared-mime-info (1.5-2ubuntu0.1) 的触发器 ...
    正在设置 dkms (2.2.0.3-2ubuntu11.5) ...
    正在设置 libgsoap8:amd64 (2.8.28-1) ...
    正在设置 libqt5x11extras5:amd64 (5.5.1-3build1) ...
    正在设置 libsdl1.2debian:amd64 (1.2.15+dfsg1-3) ...
    正在设置 libvncserver1:amd64 (0.9.10+dfsg-3ubuntu0.16.04.2) ...
    正在设置 virtualbox-dkms (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    Loading new virtualbox-5.1.38 DKMS files...
    First Installation: checking all kernels...
    Building only for 4.15.0-24-generic
    Building initial module for 4.15.0-24-generic
    Done.
    
    vboxdrv:
    Running module version sanity check.
     - Original module
       - No original module exists within this kernel
     - Installation
       - Installing to /lib/modules/4.15.0-24-generic/updates/dkms/
    
    vboxnetadp.ko:
    Running module version sanity check.
     - Original module
       - No original module exists within this kernel
     - Installation
       - Installing to /lib/modules/4.15.0-24-generic/updates/dkms/
    
    vboxnetflt.ko:
    Running module version sanity check.
     - Original module
       - No original module exists within this kernel
     - Installation
       - Installing to /lib/modules/4.15.0-24-generic/updates/dkms/
    
    vboxpci.ko:
    Running module version sanity check.
     - Original module
       - No original module exists within this kernel
     - Installation
       - Installing to /lib/modules/4.15.0-24-generic/updates/dkms/
    
    depmod....
    
    DKMS: install completed.
    正在设置 virtualbox (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    vboxweb.service is a disabled or a static unit, not starting it.
    正在设置 virtualbox-qt (5.1.38-dfsg-0ubuntu1.16.04.1) ...
    正在处理用于 libc-bin (2.23-0ubuntu10) 的触发器 ...
    正在处理用于 systemd (229-4ubuntu21.2) 的触发器 ...
    正在处理用于 ureadahead (0.100.0-19) 的触发器 ...

    验证一下virtualbox是否安装成功:virtualbox –help(会谈出虚拟窗口)

    2  vagrant是ruby开发的,所有安装ruby相关的东西
      sudo apt-get -y install ruby rubygems

    3.安装vagrant

    sudo apt-get install vagrant

    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树       
    正在读取状态信息... 完成       
    下列软件包是自动安装的并且现在不需要了:
      gcc-5-base:i386 libasn1-8-heimdal:i386 libasyncns0:i386 libbsd0:i386
      libcaca0:i386 libcurl3:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386
      libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386
      libelf1:i386 libffi6:i386 libflac8:i386 libgl1-mesa-dri:i386
      libgl1-mesa-glx:i386 libglapi-mesa:i386 libglib2.0-0:i386 libgmp10:i386
      libgnutls30:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386
      libhcrypto4-heimdal:i386 libheimbase1-heimdal:i386 libheimntlm0-heimdal:i386
      libhogweed4:i386 libhx509-5-heimdal:i386 libicu55:i386 libidn11:i386
      libjson-c2:i386 libk5crypto3:i386 libkeyutils1:i386 libkrb5-26-heimdal:i386
      libkrb5-3:i386 libkrb5support0:i386 libldap-2.4-2:i386 libllvm6.0:i386
      libnettle6:i386 libogg0:i386 libopus0:i386 libp11-kit0:i386
      .............................................
    ............................................
    使用'sudo apt autoremove'来卸载它(它们)。 将会同时安装下列软件: bsdtar bundler curl libgmp-dev libgmpxx4ldbl ruby-bundler ruby-childprocess ruby-dev ruby-domain-name ruby-erubis ruby-ffi ruby-http-cookie ruby-i18n ruby-listen ruby-log4r ruby-mime-types ruby-molinillo ruby-net-http-persistent ruby-net-scp ruby-net-sftp ruby-net-ssh ruby-netrc ruby-nokogiri ruby-rb-inotify ruby-rest-client ruby-sqlite3 ruby-thor ruby-unf ruby-unf-ext ruby2.3-dev sqlite3 建议安装: bsdcpio gmp-doc libgmp10-doc libmpfr-dev publicsuffix sqlite3-doc 下列【新】软件包将被安装: bsdtar bundler curl libgmp-dev libgmpxx4ldbl ruby-bundler ruby-childprocess ruby-dev ruby-domain-name ruby-erubis ruby-ffi ruby-http-cookie ruby-i18n ruby-listen ruby-log4r ruby-mime-types ruby-molinillo ruby-net-http-persistent ruby-net-scp ruby-net-sftp ruby-net-ssh ruby-netrc ruby-nokogiri ruby-rb-inotify ruby-rest-client ruby-sqlite3 ruby-thor ruby-unf ruby-unf-ext ruby2.3-dev sqlite3 vagrant 升级了 0 个软件包,新安装了 32 个软件包,要卸载 0 个软件包,有 236 个软件包未被升级。 需要下载 3,509 kB 的归档。 解压缩后会消耗 18.4 MB 的额外空间。 您希望继续执行吗? [Y/n] y 获取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 bsdtar amd64 3.1.2-11ubuntu0.16.04.3 [47.9 kB] 获取:2 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 ruby-molinillo all 0.4.3-1 [12.1 kB] 获取:3 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 ruby-net-http-persistent all 2.9.4-1 [15.9 kB] 获取:4 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 ruby-thor all 0.19.1-2 [43.7 kB] 获取:5 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 ruby-bundler all 1.11.2-1 [122 kB] 获取:6 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 bundler all 1.11.2-1 [4,796 B] 获取:7 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.8 [139 kB] 获取:8 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libgmpxx4ldbl amd64 2:6.1.0+dfsg-2 [8,948 B] 获取:9 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libgmp-dev amd64 2:6.1.0+dfsg-2 [314 kB] .............................................
    ..............................................
    正在选中未选择的软件包 curl。 正准备解包 .../curl_7.47.0-1ubuntu2.8_amd64.deb ... 正在解包 curl (7.47.0-1ubuntu2.8) ... 正在选中未选择的软件包 libgmpxx4ldbl:amd64。 正准备解包 .../libgmpxx4ldbl_2%3a6.1.0+dfsg-2_amd64.deb ... 正在解包 libgmpxx4ldbl:amd64 (2:6.1.0+dfsg-2) ... 正在选中未选择的软件包 libgmp-dev:amd64。 正准备解包 .../libgmp-dev_2%3a6.1.0+dfsg-2_amd64.deb ... 正在解包 libgmp-dev:amd64 (2:6.1.0+dfsg-2) ... 正在选中未选择的软件包 ruby-ffi。 正准备解包 .../ruby-ffi_1.9.10debian-1build2_amd64.deb ... 正在解包 ruby-ffi (1.9.10debian-1build2) ... 正在选中未选择的软件包 ruby-childprocess。 正准备解包 .../ruby-childprocess_0.5.9-1ubuntu1_all.deb ... 正在解包 ruby-childprocess (0.5.9-1ubuntu1) ... 正在选中未选择的软件包 ruby2.3-dev:amd64。 正准备解包 .../ruby2.3-dev_2.3.1-2~16.04.10_amd64.deb ... 正在解包 ruby2.3-dev:amd64 (2.3.1-2~16.04.10) ... 正在选中未选择的软件包 ruby-dev:amd64。 正准备解包 .../ruby-dev_1%3a2.3.0+1_amd64.deb ... 正在解包 ruby-dev:amd64 (1:2.3.0+1) ... 正在选中未选择的软件包 ruby-unf-ext。 正准备解包 .../ruby-unf-ext_0.0.7.2-1build2_amd64.deb ... 正在解包 ruby-unf-ext (0.0.7.2-1build2) ... 正在选中未选择的软件包 ruby-unf。 正准备解包 .../ruby-unf_0.1.4-1_all.deb ... 正在解包 ruby-unf (0.1.4-1) ... 正在选中未选择的软件包 ruby-domain-name。 正准备解包 .../ruby-domain-name_0.5.20160216-2_all.deb ... 正在解包 ruby-domain-name (0.5.20160216-2) ... 正在选中未选择的软件包 ruby-erubis。 正准备解包 .../ruby-erubis_2.7.0-3_all.deb ... 正在解包 ruby-erubis (2.7.0-3) ... 正在选中 正在设置 ruby-erubis (2.7.0-3) ... 正在设置 ruby-http-cookie (1.0.2-1) ... 正在设置 ruby-i18n (0.7.0-2) ... 正在设置 ruby-rb-inotify (0.9.7-1) ... 正在设置 ruby-listen (3.0.3-3) ... 正在设置 ruby-log4r (1.1.10-4) ... 正在设置 ruby-mime-types (2.6.1-1) ... 正在设置 ruby-net-ssh (1:3.0.1-3) ... 正在设置 ruby-net-scp (1.2.1-3) ... 正在设置 ruby-net-sftp (1:2.1.2-3) ... 正在设置 ruby-netrc (0.10.3-1) ... 正在设置 ruby-nokogiri (1.6.7.2-3build1) ... 正在设置 ruby-rest-client (1.8.0-2ubuntu1) ... 正在设置 ruby-sqlite3 (1.3.11-2build1) ... 正在设置 sqlite3 (3.11.0-1ubuntu1) ... 正在设置 vagrant (1.8.1+dfsg-1ubuntu0.2) ... 正在处理用于 libc-bin (2.23-0ubuntu10) 的触发器 ...

     vagrant安装成功

    下面来配置虚拟环境

    创建一个开发目录:并且初始化

    tan@tan-Precision-Tower-3620:~$ mkdir env
    tan@tan-Precision-Tower-3620:~$ cd env
    tan@tan-Precision-Tower-3620:~/env$ vagrant centos/7
    Usage: vagrant [options] <command> [<args>]
    
        -v, --version                    Print the version and exit.
        -h, --help                       Print this help.
    
    Common commands:
         box             manages boxes: installation, removal, etc.
         destroy         stops and deletes all traces of the vagrant machine
         global-status   outputs status Vagrant environments for this user
         halt            stops the vagrant machine
         help            shows the help for a subcommand
         init            initializes a new Vagrant environment by creating a Vagrantfile
         login           log in to HashiCorp's Vagrant Cloud
         package         packages a running vagrant environment into a box
         plugin          manages plugins: install, uninstall, update, etc.
         port            displays information about guest port mappings
         powershell      connects to machine via powershell remoting
         provision       provisions the vagrant machine
         push            deploys code in this environment to a configured destination
         rdp             connects to machine via RDP
         reload          restarts vagrant machine, loads new Vagrantfile configuration
         resume          resume a suspended vagrant machine
         snapshot        manages snapshots: saving, restoring, etc.
         ssh             connects to machine via SSH
         ssh-config      outputs OpenSSH valid configuration to connect to the machine
         status          outputs status of the vagrant machine
         suspend         suspends the machine
         up              starts and provisions the vagrant environment
         version         prints current and latest Vagrant version
    
    For help on any individual command run `vagrant COMMAND -h`
    
    Additional subcommands are available, but are either more advanced
    or not commonly used. To see all subcommands, run the command
    `vagrant list-commands`.
    
    tan@tan-Precision-Tower-3620:~/env$ vagrant init centos/7
    A `Vagrantfile` has been placed in this directory. You are now
    ready to `vagrant up` your first virtual environment! Please read
    the comments in the Vagrantfile as well as documentation on
    `vagrantup.com` for more information on using Vagrant.
    tan@tan-Precision-Tower-3620:~/env$ ls
    Vagrantfile

    env中的vagrantfile就是虚拟环境的配置文件

    这里配置的系统是centos/7

    开启虚拟机:

    由于仅仅配置了系统是centos/7,并未实际安装, 第一次开启时,找不到centos/7

    
    tan@tan-Precision-Tower-3620:~/env$ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'centos/7' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
        default: Box Version: >= 0
    ==> default: Loading metadata for box 'centos/7'
        default: URL: https://vagrantcloud.com/centos/7
    ==> default: Adding box 'centos/7' (v1804.02) for provider: virtualbox
        default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1804.02/providers/virtualbox.box
    default: Progress: 16%

    所以现场下载安装.......

    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'centos/7' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
        default: Box Version: >= 0
    ==> default: Loading metadata for box 'centos/7'
        default: URL: https://vagrantcloud.com/centos/7
    ==> default: Adding box 'centos/7' (v1804.02) for provider: virtualbox
        default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1804.02/providers/virtualbox.box
    ==> default: Successfully added box 'centos/7' (v1804.02) for 'virtualbox'!
    ==> default: Importing base box 'centos/7'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Checking if box 'centos/7' is up to date...
    ==> default: Setting the name of the VM: env_default_1532934316119_87902
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (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: 
        default: Vagrant insecure key detected. Vagrant will automatically replace
        default: this with a newly generated keypair for better security.
        default: 
        default: Inserting generated public key within guest...
        default: Removing insecure key from the guest if it's present...
        default: Key inserted! Disconnecting and reconnecting using new SSH key...
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
        default: No guest additions were detected on the base box for this VM! Guest
        default: additions are required for forwarded ports, shared folders, host only
        default: networking, and more. If SSH fails on this machine, please install
        default: the guest additions and repackage the box to continue.
        default: 
        default: This is not an error message; everything may continue to work properly,
        default: in which case you may ignore this message.
    ==> default: Rsyncing folder: /home/tan/env/ => /vagrant

    安装完成

    登录虚拟机......并更新.....

    tan@tan-Precision-Tower-3620:~/env$ vagrant ssh
    [vagrant@bogon ~]$ ls
    [vagrant@bogon ~]$ sudo yum update
    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    Determining fastest mirrors
     * base: mirrors.163.com
     * extras: mirrors.huaweicloud.com
     * updates: mirrors.huaweicloud.com
    base                                                                                                                                                                                 | 3.6 kB  00:00:00     
    extras                                                                                                                                                                               | 3.4 kB  00:00:00     
    updates                                                                                                                                                                              | 3.4 kB  00:00:00     
    (1/4): extras/7/x86_64/primary_db                                                                                                                                                    | 172 kB  00:00:00     
    (2/4): base/7/x86_64/group_gz                                                                                                                                                        | 166 kB  00:00:00     
    (3/4): updates/7/x86_64/primary_db                                                                                                                                                   | 4.3 MB  00:00:00     
    (4/4): base/7/x86_64/primary_db                                                                                                                                                      | 5.9 MB  00:00:06     
    Resolving Dependencies
    --> Running transaction check
    ---> Package NetworkManager.x86_64 1:1.10.2-13.el7 will be updated
    ---> Package NetworkManager.x86_64 1:1.10.2-16.el7_5 will be an update
    .....................................................................
    ....................................................

    接下来安装jdk1.8

    [vagrant@bogon ~]$ sudo yum install java-1.8.0-openjdk
    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.163.com
     * extras: mirrors.huaweicloud.com
     * updates: mirrors.huaweicloud.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.181-3.b13.el7_5 will be installed
    --> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.181-3.b13.el7_5 for package: 1:java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
    ............................................................................................................................................
    ........................................

    安装spark(opt是新建的文件夹,存放下载的东西)

    https://archive.apache.org/dist/spark/spark-2.1.1/spark-2.1.1-bin-hadoop2.7.tgz 是官网上spark压缩包的链接地址
    [vagrant@bogon ~]$ cd opt
    [vagrant@bogon opt]$ curl -O https://archive.apache.org/dist/spark/spark-2.1.1/spark-2.1.1-bin-hadoop2.7.tgz
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  191M  100  191M    0     0   129k      0  0:25:13  0:25:13 --:--:--  963k
    
    

    下载完成后解压

    [vagrant@bogon opt]$ tar zxvf spark-2.1.1-bin-hadoop2.7.tgz
    spark-2.1.1-bin-hadoop2.7/
    spark-2.1.1-bin-hadoop2.7/NOTICE
    spark-2.1.1-bin-hadoop2.7/jars/
    spark-2.1.1-bin-hadoop2.7/jars/bonecp-0.8.0.RELEASE.jar
    spark-2.1.1-bin-hadoop2.7/jars/commons-net-2.2.jar
    spark-2.1.1-bin-hadoop2.7/jars/javax.servlet-api-3.1.0.jar
    spark-2.1.1-bin-hadoop2.7/jars/hadoop-annotations-2.7.3.jar
    spark-2.1.1-bin-hadoop2.7/jars/hadoop-hdfs-2.7.3.jar
    spark-2.1.1-bin-hadoop2.7/jars/oro-2.0.8.jar
    ...........................................
    .........................................

     进入解压的后的文件夹,安装spark
    [vagrant@bogon opt]$ cd spark-2.1.1-bin-hadoop2.7/         
    [vagrant@bogon spark-2.1.1-bin-hadoop2.7]$ ls
    LICENSE  NOTICE  R  README.md  RELEASE  bin  conf  data  examples  jars  licenses  python  sbin  yarn
    [vagrant@bogon spark-2.1.1-bin-hadoop2.7]$ bin/pyspark
    Python 2.7.5 (default, Jul 13 2018, 13:06:57) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
    Setting default log level to "WARN".
    To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
    18/07/30 08:24:39 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    18/07/30 08:24:47 WARN ObjectStore: Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0
    18/07/30 08:24:47 WARN ObjectStore: Failed to get database default, returning NoSuchObjectException
    18/07/30 08:24:47 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
    Welcome to
          ____              __
         / __/__  ___ _____/ /__
        _ / _ / _ `/ __/  '_/
       /__ / .__/\_,_/_/ /_/\_   version 2.1.1
          /_/
    
    Using Python version 2.7.5 (default, Jul 13 2018 13:06:57)
    SparkSession available as 'spark'.
    >>> 

    pyspark安装成功

    待续........

     
  • 相关阅读:
    skynet源码分析之socketchannel
    skynet源码分析之master/salve集群模式
    skynet源码分析之网络层——网关服务器
    Android反编译基础(apktoos)--广工图书馆APK
    Android-Native-Server 启动和注册详细分析
    Android NDK r8 windows环境搭建
    Android 4.1.1源码编译
    Android Binder------ServiceManager启动分析
    更改系统盘符后DFS无法复制故障处理
    Centos6.9部署Gitlab-11.9.8并汉化
  • 原文地址:https://www.cnblogs.com/tsdblogs/p/9389548.html
Copyright © 2011-2022 走看看