阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu 14.04安装ROOT集群

124次阅读
没有评论

共计 8950 个字符,预计需要花费 23 分钟才能阅读完成。

之前尝试在 CentOS7 上部署 ROOT 集群,却发现无论是源码包安装,还是官方提供的二进制包,都缺少了关键的 xproofd 可执行文件,导致 PoD 不能运行。没有办法,只能尝试在其他 OS 上部署,这里我选择了Ubuntu 14.04

部署准备

修改 apt 源

修改 /etc/apt/sources.list,换成国内的 163 源,下载会更快和稳定一些。

# 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。

安装 gcc,g++

如果系统已经安装 gcc 和 g ++,可跳过此步骤。

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

安装 cmake

直接通过 apt-get 安装的 cmake 在安装 ROOT 组件时会出现问题,所以这里建议源码安装,我这里使用的是 2.8.8 版本。官网下载地址:https://cmake.org/files/,可选择自己适合的版本。

- 解压: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 install

其他库

apt-get install procmail

部署 ROOT 集群

安装 ROOT

binary 安装:https://root.cern.ch/content/release-60606。选择对应的 OS 系统编译包。解压并将其移动至 /opt 目录下:

# 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 是否能正常运行:

#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。具体插入的位置可能因 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 登录免密码。搭建方法可见:

使用 SSH 公钥密钥自动登陆 Linux 服务器 http://www.linuxidc.com/Linux/2017-02/140642.htm

集群环境 SSH 免密码登录设置 http://www.linuxidc.com/Linux/2017-03/141296.htm

之后,选择其中服务器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...

 

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计8950字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中