Ubuntu16.04系统ONOS2.2的安装

一.安装bazel1.2.0
在普通用户模式下

sudo apt install g++ unzip zip
sudo apt-get install openjdk-8-jdk

bazel二进制源下载

chmod +x bazel-<version>-installer-linux-x86_64.sh
./bazel-<version>-installer-linux-x86_64.sh --user

在~/.bashrc中加入

export PATH="$PATH:$HOME/bin"

让环境变量生效

source ~/.bashrc

二.安装ONOS2.2

sudo git clone https://gerrit.onosproject.org/onos
#切換分支到onos-2.0
cd onos
sudo git checkout onos-2.2
sudo git branch

在普通用户模式下

$ bazel build onos

出现错误一:

ERROR: /home/ipoc345/onos/protocols/lisp/ctl/BUILD:18:1: //protocols/lisp/ctl:onos-protocols-lisp-ctl depends on @concurrent_trees//jar:jar in repository @concurrent_trees which failed to fetch. no such package '@concurrent_trees//jar': java.io.IOException: Error downloading [http://repo1.maven.org/maven2/com/googlecode/concurrent-trees/concurrent-trees/2.6.1/concurrent-trees-2.6.1.jar] to /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/external/concurrent_trees/concurrent-trees-2.6.1.jar: GET returned 404 Not Found

解决方法:

gedit \tools\build\bazel\generate_workspace.bzl

在文件里用Ctrl+f搜索上面404的链接,把http://repo1.maven.org/maven2/com/googlecode/concurrent-trees/concurrent-trees/2.6.1/concurrent-trees-2.6.1.jar改成http://repo2.maven.org/maven2/com/googlecode/concurrent-trees/concurrent-trees/2.6.1/concurrent-trees-2.6.1.jar或者换成其他的源,重新build错误消失

出现错误二:

tar: apache-karaf-4.2.6/examples/karaf-itest-example/src/test/java/org/apache/karaf: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example/src/test/java/org/apache: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example/src/test/java/org: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example/src/test/java: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example/src/test: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example/src: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples/karaf-itest-example: Cannot change ownership to uid 1001, gid 1001: Invalid argument
tar: apache-karaf-4.2.6/examples: Cannot change ownership to uid 1001, gid 1001: Invalid argument

解决方法:
之前是在root用户下进行bazel build的,应该在普通用户模式下进行,切换到普通用户模式下运行,错误消失

出现错误三:
bazel build onos --sandbox_debug --verbose_failures

Executing genrule //web/gui:_onos-gui-npm-install failed (Exit 1) bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)
  (cd /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    TMPDIR=/tmp \
  /home/ipoc345/.cache/bazel/_bazel_ipoc345/install/84defa6eb1e9416bf92d6f89ab2d4f31/linux-sandbox -t 15 -w /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos -w /tmp -w /dev/shm -D -- /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; echo '\''if [[ "external/remotejdk11_linux" = /* ]]; then JHOME=external/remotejdk11_linux; else JHOME=$PWD/external/remotejdk11_linux; fi'\'' > jdk_genrule_setup.sh; echo '\''export PATH=$JHOME/bin:$PATH:'\'' >> jdk_genrule_setup.sh; source jdk_genrule_setup.sh; echo '\''Hi,xueqing!'\''; ROOT=`pwd` && echo '\''Hi,xueqing2'\'' && export HOME=. && export XDG_CONFIG_HOME=bazel-out/k8-fastbuild/bin/web/gui/config && export BABEL_DISABLE_CACHE=1 && if [[ ! -z ${HTTP_PROXY-} ]]; then NPM_ARGS="--proxy $HTTP_PROXY --without-ssl --insecure"; else NPM_ARGS=""; fi && NPM=$ROOT/external/nodejs/bin/npm && mkdir -p tools/gui && cd tools/gui && jar xf ../../bazel-out/k8-fastbuild/bin/tools/gui/tools-gui-gulp.jar && echo '\''Hi,xueqing3'\'' && $NPM install --no-cache --loglevel=error >npm-install.out 2>&1 && echo '\''Hi,xueqing4'\'' && find . -name package.json | while read pjson; do egrep -v '\''/execroot/'\'' $pjson > ptmp; mv ptmp $pjson; done && find package.json gulpfile.babel.js node_modules gulp-tasks -type f -exec touch -t 201806280000 {} \; && jar Mcf $ROOT/bazel-out/k8-fastbuild/bin/web/gui/onos-gui-npm-install.jar package.json gulpfile.babel.js node_modules gulp-tasks')
src/main/tools/linux-sandbox.cc:154: linux-sandbox-pid1 has PID 28650
src/main/tools/linux-sandbox-pid1.cc:175: working dir: /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos
src/main/tools/linux-sandbox-pid1.cc:194: writable: /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos
src/main/tools/linux-sandbox-pid1.cc:194: writable: /tmp
src/main/tools/linux-sandbox-pid1.cc:194: writable: /dev/shm
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/pts
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /dev/shm
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/mqueue
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/hugepages
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/lock
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/user/1000
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/user/1000/gvfs
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/security
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/systemd
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/cpu,cpuacct
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/pids
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/net_cls,net_prio
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/cpuset
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/hugetlb
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/blkio
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/freezer
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/rdma
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/perf_event
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/devices
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/memory
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/pstore
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/debug
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/debug/tracing
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/config
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/fuse/connections
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc/sys/fs/binfmt_misc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc/sys/fs/binfmt_misc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /root/.gvfs
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /tmp
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /dev/shm
src/main/tools/process-tools.cc:118: sigaction(32, &sa, nullptr) failed
src/main/tools/process-tools.cc:118: sigaction(33, &sa, nullptr) failed
src/main/tools/linux-sandbox-pid1.cc:437: waitpid returned 2
src/main/tools/linux-sandbox-pid1.cc:457: child exited with code 1
src/main/tools/linux-sandbox.cc:204: child exited normally with exitcode 1

解决方法
进入这个文件夹
cd /home/ipoc345/.cache/bazel/_bazel_ipoc345/1587d346382e625ef1c8852acab1dd3a/sandbox/linux-sandbox/1745/execroot/org_onosproject_onos/tools/gui
找到npm-install.out文件,查看到底出了什么错误

genrule
stderr: npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `./node_modules/gulp/bin/gulp.js build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

根据提示,进一步查看错误log

14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/home/cjx/onos/buck-out/gen/web/gui/node-bin-v8.1.2/node-binaries/lib/node_modules/npm/lib/utils/li
fecycle.js:283:16)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at EventEmitter.emit (events.js:213:7)
14 verbose stack     at ChildProcess.<anonymous> (/home/cjx/onos/buck-out/gen/web/gui/node-bin-v8.1.2/node-binaries/lib/node_modules/npm/lib/utils/sp
awn.js:40:14)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at ChildProcess.emit (events.js:213:7)
14 verbose stack     at maybeClose (internal/child_process.js:897:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid [email protected]

在ONOS-dev小组里搜了一下解决方法,发现大多是加代理、还有就是让重启重新运行
我重启了服务器,然后重新运行后发现不行,还是这个错,准备搜索npm加代理的方法,然后又让bazel重新运行一次,结果发现突然编译成功,太惊喜了。应该就是网的问题,在这次成功之前,我应该已经试过了几十次bazel build onos了

想说ONOS真是我装过最难装的开源软件了
希望这个帖子能够给大家带来帮助

你可能感兴趣的:(ONOS)