Ubuntu14.04安裝ROOT集羣

以前嘗試在CentOS7上部署ROOT集羣,卻發現不管是源碼包安裝,仍是官方提供的二進制包,都缺乏了關鍵的xproofd可執行文件,致使PoD不能運行。沒有辦法,只能嘗試在其餘OS上部署,這裏我選擇了Ubuntu14.04c++

部署準備

修改apt源

  修改/etc/apt/sources.list,換成國內的163源,下載會更快和穩定一些。git

# vim /etc/apt/sources.list
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse

  再調用apt-get update更新index。github

安裝gcc,g++

  若是系統已經安裝gcc和g++,可跳過此步驟。shell

# apt-get install gcc
# apt-get install g++

安裝cmake

  直接經過apt-get安裝的cmake在安裝ROOT組件時會出現問題,因此這裏建議源碼安裝,我這裏使用的是2.8.8版本。官網下載地址:https://cmake.org/files/,可選擇本身適合的版本。bootstrap

- 解壓:tar xvf cmake-2.8.8.tar.gz
- 進入解壓目錄:cd cmake-2.8.8
- ./bootstrap
- make
- make install

安裝zlib庫

  github上(https://github.com/madler/zlib)可下載對應的zlib庫,我使用的是1.2.3版本,下載地址爲:https://github.com/madler/zlib/archive/v1.2.3.zip
- 解壓:unzip zlib-1.2.3.zip
- 進入解壓目錄:cd zlib-1.2.3
- ./configure
注意:在make以前,須要修改Makefile,不然調用庫時會出現錯誤。找到 CFLAGS=-O3 -DUSE_MMAP這一行,在後面加入-fPIC,即變成CFLAGS=-O3 -DUSE_MMAP -fPIC
- make
- make installubuntu

其餘庫

apt-get install procmailvim

部署ROOT集羣

安裝ROOT

  binary安裝:https://root.cern.ch/content/release-60606。選擇對應的OS系統編譯包。解壓並將其移動至/opt目錄下:bash

# tar zxvf root_v6.06.06.Linux-ubuntu14-x86_64-gcc4.8.tar.gz
# mv root /opt

  再將ROOT相關配置寫入初始化文件,這裏在/etc/profile.d/root.sh末尾加入如下語句:服務器

export ROOTSYS=/opt/root
export PATH=$PATH:$ROOTSYS/bin
source $ROOTSYS/bin/thisroot.sh

  source /etc/profile.d/root.sh讓配置生效。運行命令root -b測試root是否能正常運行:app

#root -b
root: error while loading shared libraries: libXpm.so.4: cannot open shared object file: No such file or directory

  缺乏libXpm庫,運行apt-get install libxpm4命令安裝。安裝時有可能會提示缺乏安裝包,這和本地的源index有關係,須要先向遠端源同步後(運行apt-get update命令),再安裝xpm包。安裝成功。

# apt-get install libxpm4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libxpm4
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 37.0 kB of archives.
……

  再次運行root -b命令來測試,再次報錯。

# root -b
ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
    echo | LC_ALL=C c++  -pipe -m64 -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++11 -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-missing-field-initializers  -fPIC -fvisibility-inlines-hidden -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-unused-local-typedefs -O2 -DNDEBUG -xc++ -E -v - 2>&1 >/dev/null | awk '/^#include </,/^End of search/{if (!/^#include </ && !/^End of search/){ print }}' | grep -E "(c|g)\+\+"
results in
results in
with exit code 256
input_line_1:1:10: fatal error: 'new' file not found
#include <new>

  缺乏C++的new包,這個報錯極有多是未安裝c++引發的,由於ROOT及其它組件都是使用C++編寫的。所以須要安裝gcc和gcc-c++。

# apt-get install gcc
……
# apt-get install g++
……

  運行root -b命令,終於成功,未報錯。

安裝XRootD

  安裝XRootD有兩種方法,經過ROOT源碼包中的腳本安裝,或者直接從官網下載源碼安裝。

經過ROOT源碼包中的腳本安裝XRootD

  進入ROOT源碼包目錄,執行如下語句便可:

./build/unix/installXrootd.sh -v 3.0.0 /opt

源碼安裝XRootD:

  解壓後並進入源碼目錄:

# mkdir build; cd build
# cmake /root/xrootd-3.3.0 -DCMAKE_INSTALL_PREFIX=/opt/xrootd
# make
# make install

  若是徹底成功,則能夠相關配置寫入初始化文件,這裏能夠繼續加入/etc/profile.d/root.sh的末尾:

source $ROOTSYS/bin/setxrd.sh /opt/xrootd/

安裝PoD

  官網(http://pod.gsi.de)下載源碼,這裏下載使用的是3.16版本的源碼:pod.gsi.de/releases/pod/3.16/PoD-3.16-Source.tar.gz。若是鏈接失效,可自行查找。解壓源碼壓縮包後,並進入源碼目錄:

cmake命令

mkdir build
cd build
cmake -C ../BuildSetup.cmake ..

  運行cmake時,提示缺乏boost庫,這裏須要安裝boost庫。

apt-get install libboost-dev

  安裝後繼續運行上述的cmake命令,仍是報錯,提示缺乏如下庫:

The following Boost libraries could not be found:

          boost_thread
          boost_program_options
          boost_filesystem
          boost_system
          boost_unit_test_framework

  有個小tips:這些庫直接使用apt-get install +庫名的方式是不成功的,由於安裝包和這個名稱並不徹底匹配,這裏能夠用apt-cache search的方法來查找安裝包的名稱再安裝,以boost_thread爲例。

# apt-cache search boost | grep thread
libboost-thread-dev - portable C++ multi-threading (default version)
libboost-thread1.46-dev - portable C++ multi-threading
libboost-thread1.46.1 - portable C++ multi-threading
libboost-thread1.48-dev - portable C++ multi-threading
libboost-thread1.48.0 - portable C++ multi-threading

  根據這個提示,我就能夠直接安裝apt-get install libboost-thread-dev便可。如下:

apt-get install libboost-thread-dev
apt-get install libboost-program-options-dev
apt-get install libboost-filesystem-dev
apt-get install libboost-system-dev
apt-get install libboost-test-dev

  再接着運行cmake -C ../BuildSetup.cmake ..命令,終於成功。

make命令

  運行make命令,又報錯了。

/usr/include/boost/thread/xtime.hpp:23:5: error: expected identifier before numeric constant
     TIME_UTC=1

  這個是boost1.5版本如下的一個固有bug,變量麼命名重複了。修改起來很簡單,打開/usr/include/boost/thread/xtime.hpp,將23行和71行的TIME_UTC都修改成TIME_UTC_便可,也就是說保證沒有重命名。
  再次運行make命令,再次提示錯誤。

/root/PoD-3.16-Source/app/MiscCommon/proof_status_file/ProofStatusFile.h:88:13: error: 'uint16_t' does not name a type
             uint16_t xpdPort() const

  看起來是編譯時不認識uint16_t這個別名,修改很簡單,頭文件包含便可。在/root/PoD-3.16-Source/app/MiscCommon/proof_status_file/ProofStatusFile.h中的第19行加入#include <stdint.h>。具體插入的位置可能因PoD代碼版本不一樣而有些差異,但有C或者C++基礎的人應該很容易能找到合適的位置。
  再次運行make命令,終於完美經過。

make install命令

  該命令運行無任何報錯。若是無指定配置,PoD會被安裝在用戶目錄的Pod目錄下,如我以root用戶安裝,則安裝在/root/PoD目錄下。

PoD安裝最後一步

  相關配置寫入初始化文件,這裏能夠繼續加入/etc/profile.d/root.sh的末尾:

source /root/PoD/3.16/PoD_env.sh

  source /etc/profile.d/root.sh讓配置生效。運行pod-server start,若是是第一次運行,會下載相關組件wn_bins目錄到/root/PoD/3.16/bin/。若是服務器沒有訪問外網的權限,可使用虛擬機搭建以上全部步驟,下載wn_bins目錄。不管什麼OS,下載的wn_bins目錄都是同樣的,能夠直接拷貝。

組成ROOT集羣

  運行pod-server start,待其下載wn_bins目錄後,若是沒有出現錯誤,會出現以下結果:

# pod-server start
Starting PoD server...
updating xproofd configuration file...
starting xproofd...
starting PoD agent...
preparing PoD worker package...
selecting pre-compiled bins to be added to worker package...
PoD worker package: /root/.PoD/wrk/PoDWorker.sh
------------------------
XPROOFD [1809] port: 21001
PoD agent [1848] port: 22002
PROOF connection string: root@mac00000102030a.hostname.com:21001

  使用上述全部方法,搭建兩個服務器環境,從而搭建一套擁有一個server和一個client的小集羣。ROOT服務器之間又多種通信方式,這裏,咱們使用最簡單直接的ssh方式。首先,兩臺服務器須要創建ssh登陸互信,從而實現ssh登陸免密碼。搭建方法可見:http://chenlb.iteye.com/blog/211809。
  以後,選擇其中服務器A做爲server,服務器B做爲client(worker)。在server上,編輯/root/pod_ssh.cfg文件,內容以下:

@bash_begin@
    . /etc/profile.d/root.sh
@bash_end@

r1, root@109.105.115.249,,/tmp/test, 2

  前三行是ssh到client以後,須要執行的腳本文件,這裏就是在各client上執行下ROOT系統的參數配置,設置環境變量等。第五行則是訪問client的配置,每一個client都對應一行,由於咱們這裏只有一個client,因此就只有一行。這一行的格式是:
















1 2 3 4 5
client惟一識別符,不可重複 用戶名@ip或者hostname ssh參數,能夠爲空 client端工做目錄 指望的client端worker個數,能夠爲空

  而後,在server端執行pod-ssh -c /root/pod_ssh.cfg submit --debug來創建集羣。顯示以下,則說明server端成功:

# pod-ssh -c /root/pod_ssh.cfg submit --debug
**  [Mon, 29 Aug 2016 10:40:18 +0800]   preparing PoD worker package...
**  [Mon, 29 Aug 2016 10:40:18 +0800]   selecting pre-compiled bins to be added to worker package...
**  [Mon, 29 Aug 2016 10:40:18 +0800]   PoD worker package: /root/.PoD/wrk/PoDWorker.sh
**  [Mon, 29 Aug 2016 10:40:18 +0800]   pod-ssh config contains an inline shell script. It will be injected it into wrk. package
**  [Mon, 29 Aug 2016 10:40:18 +0800]   preparing PoD worker package...
**  [Mon, 29 Aug 2016 10:40:18 +0800]   inline shell script is found and will be added to the package...
**  [Mon, 29 Aug 2016 10:40:18 +0800]   selecting pre-compiled bins to be added to worker package...
**  [Mon, 29 Aug 2016 10:40:18 +0800]   PoD worker package: /root/.PoD/wrk/PoDWorker.sh
**  [Mon, 29 Aug 2016 10:40:18 +0800]   There are 5 threads in the tread-pool.
**  [Mon, 29 Aug 2016 10:40:18 +0800]   Number of PoD workers: 1
**  [Mon, 29 Aug 2016 10:40:18 +0800]   Number of PROOF workers: 2
**  [Mon, 29 Aug 2016 10:40:18 +0800]   Workers list:
**  [Mon, 29 Aug 2016 10:40:18 +0800]   [r1] with 2 workers at root@109.105.115.249:/tmp/test/r1
r1  [Mon, 29 Aug 2016 10:40:18 +0800]   pod-ssh-submit-worker is started for root@109.105.115.249 (dir: /tmp/test/r1, nworkers: 2, sshopt: )
**  [Mon, 29 Aug 2016 10:40:19 +0800]   
*******************
Successfully processed tasks: 1
Failed tasks: 0
*******************

  咱們再登陸client端,進入/root/pod_ssh.cfg中設置的client端工做目錄工做目錄。

# ls
libboost_filesystem-mt.so.5       libpod_protocol.so       PoD.cfg            PoDWorker.sh                              proof.conf       user_worker_env.sh  xpd.log
libboost_program_options-mt.so.5  libproof_status_file.so  pod-user-defaults  pod-wrk-bin-3.16-Darwin-universal.tar.gz  server_info.cfg  version
libboost_system-mt.so.5           libSSHTunnel.so          PoDWorker.lock     pod-wrk-bin-3.16-Linux-amd64.tar.gz       ssh-tunnel       xpd.cf
libboost_thread-mt.so.5           pod-agent                PoDWorker.pid      pod-wrk-bin-3.16-Linux-x86.tar.gz         ssh_worker.log   xpd.cf.bup

  可見,都是一些庫、配置文件和日誌等。咱們暫時主要關注日誌文件ssh_worker.log,日誌末尾顯示以下,則表示徹底成功:

***     [Mon, 29 Aug 2016 10:44:48 +0800]       Attempt to start pod-agent (1 out of 3)
***     [Mon, 29 Aug 2016 10:44:48 +0800]       Attempt to start and detect xproofd (1 out of 10)
***     [Mon, 29 Aug 2016 10:44:48 +0800]       trying to use XPROOF port: 21002
***     [Mon, 29 Aug 2016 10:44:48 +0800]       starting xproofd...
***     [Mon, 29 Aug 2016 10:44:48 +0800]       xproofd is running. pid=[2794] port=[21002]
***     [Mon, 29 Aug 2016 10:44:48 +0800]       starting pod-agent...
相關文章
相關標籤/搜索