http://blog.csdn.net/pipisorry/article/details/51350908

export HADOOP_HOME=/usr/local/hadoop-2.6.4
export GRAPHLITE_HOME=/opt/GraphLite/GraphLite-0.20

pika:/opt/GraphLite/GraphLite-0.20$ . bin/setenv
pika:/opt/GraphLite/GraphLite-0.20$cd engine
pika:/opt/GraphLite/GraphLite-0.20/engine$make       #apt-get install -y make      #没有安装make的话要安装
pika:/opt/GraphLite/GraphLite-0.20/engine$cd ..
pika:/opt/GraphLite/GraphLite-0.20$ls bin/
clean-output  graphlite  hash-partitioner.pl  setenv  start-graphlite  start-worker

Compile and Run Vertex Program

1. build example

pika:/opt/GraphLite/GraphLite-0.20$cd example

如果没有安装g++的要安装apt-get install -y g++

pika:/opt/GraphLite/GraphLite-0.20/example$make
g++ -std=c++0x -g -O2 -I/usr/local/hadoop-2.6.4/include -I/opt/GraphLite/GraphLite-0.20/include PageRankVertex.cc -fPIC -shared -o PageRankVertex.so
check if example/PageRankVertex.so is successfully generated:

pika:/opt/GraphLite/GraphLite-0.20/example$ls
Makefile  PageRankVertex.cc  PageRankVertex.so

2. run example

如果没有开启ssh的要开启/etc/init.d/ssh start,一般上面步骤对都开启了

pika:/opt/GraphLite/GraphLite-0.20/example$cd ..

pika:/opt/GraphLite/GraphLite-0.20$start-graphlite example/PageRankVertex.so Input/facebookcombined_4w Output/out

Note: 如果这一步出错了,直接ctrl+c并没有杀掉所有graphlite进程,系统cpu占用还是100%,所以要打开系统监视器来end process: 进程名为graphlite。

查看输出结果:

pika:/opt/GraphLite/GraphLite-0.20$cat Output/out_*

...

4031: 1.050963
4035: 0.152987

当然也可以测试自己写的代码和输入文件

编写自己的同步图计算程序并测试代码结果

计算KCore:一个图G的 KCore 是G的子图,这个子图的每个顶点的度>=K;输入:无向图 (有成对的有向边);输出:  KCore 子图中的所有顶点

#将自己写的代码KcoreVertex.cc和输入文件的目录(/media/pika/files/mine/c_workspace/BDMS/BDMS代码和输入文件下载)cp到graphlite example目录下

pika:/opt/GraphLite/GraphLite-0.20$cd example/

pika:/opt/GraphLite/GraphLite-0.20/example$mv PageRankVertex.cc ori.cc                   #重命名之前的文件

pika:/opt/GraphLite/GraphLite-0.20/example$rm PageRankVertex.so -f                          #删除之前产生的中间文件

pika:/opt/GraphLite/GraphLite-0.20/example$cp /media/pika/files/mine/c_workspace/BDMS/BDMS/*.cc /opt/GraphLite/GraphLite-0.20/example
pika:/opt/GraphLite/GraphLite-0.20/example$cp /media/pika/files/mine/c_workspace/BDMS/BDMS/part2-input/* /opt/GraphLite/GraphLite-0.20/Input
pika:/opt/GraphLite/GraphLite-0.20/example$. ../bin/setenv
pika:/opt/GraphLite/GraphLite-0.20/example$make

pika:/opt/GraphLite/GraphLite-0.20$cd ..

#PageRankVertex实际已改成自己写的KcoreVertex,文件名修改的话也要修改Makefile文件再make

pika:/opt/GraphLite/GraphLite-0.20$start-graphlite example/PageRankVertex.so Input/KCore-graph0_4w Output/out 6

pika:/opt/GraphLite/GraphLite-0.20$cat Output/out_*

0
4
1
5
2
6
3

Graphlite程序的调试

lz并没有深入graphlite,调试仅仅是输出中间值。

在graphlite c++代码中(一般只是修改了节点的compute函数代码)cout输出结果,结果不会在屏幕上输出,但是会在${GRAPHLITE_HOME}目录中的workout目录下有文件输出。

通过设置最大超步数,一步一步调试吧。

注意事项

graphlite的c++代码(如compute函数中读取的数据)中的相对路径是相对${GRAPHLITE_HOME}来说的,也就是相对执行目录而言,而不是相对.cc代码或者.so文件。

运行出错及解决

Sender: connect: Connection refused错误

Sender: connect: Connection refused

Sender: connect: Connection refused

...

出错的可能原因:

1 可能是inputformatter中顶点类型的sizeof没改,或者说是某个类型定义为double,但是传递的是int

2 执行路径不对:example/PageRankVertex.so,这个路径就说明要在example的上级目录下执行这条命令
3 运行之前还有其它graphlite程序在运行,可能是之前运行graphlite时ctrl+c结束了,但是实际上进行还在后台执行,导致冲突,打开system-monitor结束graphlite进程(一般有多少个worker就有几个进程,都要结束)

皮皮blog

Netbeans IDE中调试基于graphlite实现的c++代码

...

皮皮blog

Docker中运行graphlite

Requirements

1. JDK 1.7.x + Hadoop 2.6.x

docker中Hadoop的安装参考[Hadoop:Hadoop单机伪分布式的安装和配置]

2. protocol buffers

root@dc34d732b74d:/# apt-get update

root@dc34d732b74d:/# sudo apt-get install protobuf-c-compiler libprotobuf-c0 libprotobuf-c0-dev

下载和安装graphlite

root@dc34d732b74d:/# apt-get install -y git              #没有安装git的话要安装,lz使用的是docker中配置的环境,很多都没有

root@dc34d732b74d:/# cd /opt

root@dc34d732b74d:/opt# git clone https://github.com/schencoding/GraphLite.git

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# vim bin/setenv 
export JAVA_HOME=/opt/jdk1.8.0_91
export HADOOP_HOME=/usr/local/hadoop-2.6.4
export GRAPHLITE_HOME=/opt/GraphLite/GraphLite-0.20
root@dc34d732b74d:/opt# . bin/setenv

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# cd engine

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# apt-get install -y make      #没有安装make的话要安装
root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# make

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# cd ..

check if bin/graphlite is successfully generated:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# ls bin/          
clean-output  graphlite  hash-partitioner.pl  setenv  start-graphlite  start-worker

Compile and Run Vertex Program

1. build example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# cd example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# apt-get install -y g++    #没有安装g++的要安装

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# make
g++ -std=c++0x -g -O2 -I/usr/local/hadoop-2.6.4/include -I/opt/GraphLite/GraphLite-0.20/include PageRankVertex.cc -fPIC -shared -o PageRankVertex.so
check if example/PageRankVertex.so is successfully generated:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# ls
Makefile  PageRankVertex.cc  PageRankVertex.so
2. run example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# cd ..

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# /etc/init.d/ssh start           #没有开启ssh的要开启

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# start-graphlite example/PageRankVertex.so Input/facebookcombined_4w Output/out

查看输出结果:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# cat Output/out_*

保存docker 容器为images

pika:~$docker ps

pika:~$docker commit 2379 graphlite1

当然也可以测试自己写的代码和输入文件

编写自己的同步图计算程序并测试代码结果

#将自己写的代码KcoreVertex.cc和输入文件的目录(代码和输入文件下载)挂载到docker image的/mnt目录下

Note: KcoreVertex.cc内容:KCore:一个图G的 KCore 是G的子图,这个子图的每个顶点的度>=K;输入:无向图 (有成对的有向边);输出:  KCore 子图中的所有顶点

pika:~$docker run -v /media/pika/files/mine/c_workspace/BDMS/BDMS:/mnt -it graphlite1 bash

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# mv PageRankVertex.cc ori.cc   #重命名之前的文件

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# rm PageRankVertex.so #删除之前产生的中间文件

root@23791b4028eb:/# cp /mnt/*.cc /opt/GraphLite/GraphLite-0.20/example

root@23791b4028eb:/# cp /mnt/part2-input/* /opt/GraphLite/GraphLite-0.20/Input

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20#  . bin/setenv

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# cd example/

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# make

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# cd ..

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# /etc/init.d/ssh start

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# start-graphlite example/PageRankVertex.so Input/KCore-graph0_4w Output/out 6     #PageRankVertex实际已改成自己写的KcoreVertex,文件名修改的话也要修改Makefile文件再make

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# cat Output/out_*
0
4
1
5
2
6
3

pika:~$docker ps

pika:~$docker commit <container id> graphlite

from: http://blog.csdn.net/pipisorry/article/details/51350908

ref: GraphLite的github主页

Prege(图计算框架)l: A System for Large-Scale Graph Processing(译)

分布式图并行计算框架:PowerGraph

最新文章

  1. Knockout.js随手记(5)
  2. IO流-字节输出流OutputStream异常处理
  3. JDBC driver connection string大全
  4. require.js的用法
  5. PHP内置函数
  6. 查看Safari和钥匙串中的密码
  7. Wow! Such Doge! - HDU 4847 (水题)
  8. Activity切换动画(overridePendingTransition)-翻页效果
  9. SignalR系列教程:在MVC5中使用SignalR
  10. 表likp新增第一次过账输入日期字段,vl02n/vl01n/vl03n/vl06o的增强
  11. ubuntu server 12.04 源
  12. Spring JDBC(一)jdbcTemplate
  13. 一步步部署基于Windows系统的Jenkins持续集成环境
  14. python绝技-运用python成为顶级黑客源代码
  15. Codeforces Round #228 (Div. 1)
  16. 【作业】用栈模拟dfs
  17. 汇编 shr 逻辑右移指令,shl 逻辑左移指令,SAL 算术左移指令,SAR 算术右移指令
  18. Centos7.4下keepalived-1.3.5的安装使用
  19. failed to register esriAddin
  20. 深入理解net core中的依赖注入、Singleton、Scoped、Transient(一)

热门文章

  1. FZU 2157 树形DP
  2. CentOs源码安装mysql-5.6.34(cmake)
  3. SpringBoot添加自定义拦截器
  4. Feign报错Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client
  5. Linux文件系统的介绍
  6. django 发送手机验证码
  7. git修改远程仓库地址
  8. 聪明的搜索算法’ A*算法
  9. AngularJs 笔记
  10. Arrays的二分查找