添加用户
sudo adduser mpit
增加权限
sudo visudo
切换用户
su - mpit
安装openmpi
sudo apt install libopenmpi-dev
测试单机
mpiexec -np 8 hostname
多机环境
关闭防火墙
sudo ufw status
sudo ufw disable
修改hosts
sudo vim /etc/hosts 添加 IP地址 主机名
创建ssh
ssh-keygen -t rsa
将自己的公钥传给别的机器,注意也需要发给本机
ssh-copy-id -i ~/.ssh/id_rsa.pub 机器名@IP地址
加入know_host,全部ssh一遍,包括自己
ssh m
测试多机,
需先编辑hf,加入m slots=4 s1 slots=4
mpiexc -np 8 -hostfile hf hostname
权限/home/mpit .ssh/至少755
测试本程序,先将代码传入主机
scp data.c mpit@IP:~/mp
mpicc aaa.c -o aaa
gcc data.c -o data
./data 100000 4 testdata
chmod 700 testdata
chmod 700 datades
运行
mpirun -hostfile hf -np 8 aaa
注意
生成testdata后chmod 700 testdata
修改hf文件
修改datades文件
两边都要编译,但只有主机需要testdata hf datades
NUTCH官方文档https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=115515088
安装java8
sudo apt install openjdk-8-jdk
编辑~/.bashrc
vim ~/.bashrc 在末尾添加export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
source ~/.bashrc 环境生效
获得安装包
wget https://mirrors.tuna.tsinghua.edu.cn/apache/nutch/1.17/apache-nutch-1.17-bin.tar.gz
解压
tar -zxf apache-nutch-1.17-bin.tar.gz
进入文件夹内
cd apache-nutch-1.17-bin
编辑配置
vim conf/nutch-site.xml 加入官方文档的内容
vim conf/nutch-default.xml
对 http.agent.name
http.robots.agents
http.agent.description
http.agent.url
http.agent.email
http.agent.version
这几项的value随便添加内容,使得不为空
创建种子Url
mkdir -p urls
cd urls
touch seed.txt
vim seed.txt 加入种子URL
注入种子
bin/nutch inject crawl/crawldb urls
开始爬取 1000个
bin/nutch generate crawl/crawldb crawl/segments -topN 1000
s2=`ls -d crawl/segments/2* | tail -1`
echo $s2
bin/nutch fetch $s2
bin/nutch parse $s2
bin/nutch updatedb crawl/crawldb $s2
将爬去的文本信息导出 其中20200812172328应为刚刚爬取得到的目录名,data_oscar为导出后的文件名
bin/nutch readseg -dump crawl/segments/20200812172328/ data_oscar /segments -nofetch -nogenerate -noparse -noparsedata -nocontent
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <mpi.h>
#include <stdbool.h>
#define BLOCK 1024*1024
double *ldata;
double *gdata;
double *gsd;
double *cdata;
double *tdata;
int double_cmp(const void *a,const void *b){
return *(double *)a>*(double *)b?1:-1;
}
void merge(double *a, double *b, double* temp, const bool low, int lsize)
{
int pa, pb, ptemp;
if (low)