sudo addgroup hadoop
sudo adduser --ingroup hadoop hduser
将下好的jdk-8u162-linux-x64.tar.gz
解压,将目录改名为jdk1.8
,并拷贝到/usr/local
目录下。
sudo tar -zxvf jdk-8u162-linux-x64.tar.gz
mv jdk-8u162-linux-x64.tar.gz /usr/local/jdk1.8
切换到hduser
用户下,将Java环境变量写入~/.bashrc
中。
export JAVA_HOME=/usr/local/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin
测试Java是否安装成果。
java -version
在具有管理权限的用户下,解压hadoop-2.5.1.tar.gz
,改名为hadoop
并改其所属用户和用户组。
sudo tar -zxvf hadoop-2.5.1.tar.gz
mv hadoop-2.5.1.tar.gz /usr/local/hadoop
cd /usr/local
sudo chown -R hduser:hadoop hadoop
安装SSH Server
sudo apt-get install openssh-server
在hduser
下,生成密钥对
cd ~/.ssh/
ssh-keygen -t rsa
cat ./id_rsa.pub >> ./authorized_keys
设置Hadoop的环境变量,编辑~/.bashrc
export HADOOP_HOME=/usr/local/hadoop
编辑Hadoop目录下的etc/hadoop/core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/app/hadoop/tmp</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
编辑Hadoop目录下的etc/hadoop/hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/app/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/app/hadoop/tmp/dfs/data</value>
</property>
</configuration>
编辑Hadoop目录下的etc/hadoop/mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
编辑hadoop目录下的etc/hadoop/yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
</configuration>
配置完成后,执行NameNode的格式化
./bin/hdfs namenode -format
看到 “successfully formatted” 和 “Exitting with status 0” 的提示,表示成功
运行Hadoop
./sbin/start-all.sh
使用jps
命令观察相关进程是否启动
在具有管理权限的用户下,安装git和maven
sudo apt-get install git
sudo apt-get install maven
mvn -version
确保maven版本在3以上
从Github上克隆Giraph
cd /usr/local
sudo git clone https://github.com/apache/giraph.git
sudo chown -R hduser:hadoop giraph
su - hduser
编辑~/.bashrc
export GIRAPH_HOME=/usr/local/giraph
保存文件,编译Giraph
source ~/.bashrc
cd $GIRAPH_HOME
mvn -Phadoop_2 -DskipTests package
如果依赖包不能下载,可能需要更换镜像源,下载慢可以挂一个代理,这些都可以在maven的settings.xml
中进行配置。
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Giraph Parent .............................. SUCCESS [1:04.901s]
[INFO] Apache Giraph Core ................................ SUCCESS [38.283s]
[INFO] Apache Giraph Blocks Framework .................... SUCCESS [15.860s]
[INFO] Apache Giraph Examples ............................ SUCCESS [16.587s]
[INFO] Apache Giraph Accumulo I/O ........................ SUCCESS [39.829s]
[INFO] Apache Giraph HBase I/O ........................... SUCCESS [45.671s]
[INFO] Apache Giraph HCatalog I/O ........................ SUCCESS [46.907s]
[INFO] Apache Giraph Gora I/O ............................ SUCCESS [1:12.667s]
[INFO] Apache Giraph Distribution ........................ SUCCESS [31.032s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
出现以上信息则编译成功