主机名 | ip | 进程 |
---|---|---|
nn.hadoop.data.example.net | 172.16.156.220 | NameNode、Master、ResourceManager、SecondaryNameNode、JobHistoryServer |
dn1.hadoop.data.example.net | 172.16.156.221 | NodeManager、DataNode、Worker |
dn2.hadoop.data.example.net | 172.16.156.222 | NodeManager、DataNode、Worker |
yum install pcre-devel openssl openssl-devel openssh-clients htop gcc zlib lrzsz zip unzip vim telnet-server ncurses wget net-tools
systemctl stop firewalld.service
systemctl disable firewalld.service
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.156.220 nn.hadoop.data.example.net
172.16.156.221 dn1.hadoop.data.example.net
172.16.156.222 dn2.hadoop.data.example.net
mkdir /app/java
mkdir /app/scala
下载JDK
wget http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz
如果失效,点这里下载 并上传至服务器
下载Scala
wget http://downloads.lightbend.com/scala/2.12.1/scala-2.12.1.tgz
mv jdk-8u121-linux-x64.tar.gz /app/java
tar -zxvf jdk-8u121-linux-x64.tar.gz
mv scala-2.12.1.tgz /app/scala
tar -zxvf scala-2.12.1.tgz
chmod -R 775 /app/
chown -R hadoop /app/
useradd hadoop
passwd hadoop
如无特殊说明 以后均为hadoop用户操作
生成秘钥:~/.ssh/id_rsa和~/.ssh/id_rsa.pub
ssh-keygen -t rsa
拷贝公钥到其他机器上
ssh-copy-id -i nn.hadoop.data.example.net
ssh-copy-id -i dn1.hadoop.data.example.net
ssh-copy-id -i dn2.hadoop.data.example.net
mkdir /app/hadoop/data
mkdir /app/hadoop/name
mkdir /app/hadoop/tmp
wget http://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz
mv hadoop-2.7.3.tar.gz /app/hadoop
tar -zxvf hadoop-2.7.3.tar.gz
/etc/profile (root权限)
HADOOP_HOME=/app/hadoop/hadoop-2.7.3
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
slaves
dn1.hadoop.data.example.net
dn2.hadoop.data.example.net
hadoop-env.sh
# export JAVA_HOME=${JAVA_HOME}
改为
export JAVA_HOME=/app/java/jdk1.8.0_121/
core-site.xml
<configuration>
<property>
<name>fs.defaultFSname>
<value>hdfs://nn.hadoop.data.example.net:9000value>
property>
<property>
<name>hadoop.tmp.dirname>
<value>/app/hadoop/tmpvalue>
property>
configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-addressname>
<value>nn.hadoop.data.example.net:50090value>
property>
<property>
<name>dfs.namenode.name.dirname>
<value>/app/hadoop/namevalue>
property>
<property>
<name>dfs.replicationname>
<value>1value>
property>
<property>
<name>dfs.datanode.data.dirname>
<value>/app/hadoop/datavalue>
property>
configuration>
mapred-site.xml
cp mapred-site.xml.template mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>mapreduce.jobhistory.addressname>
<value>nn.hadoop.data.example.net:10020value>
property>
<property>
<name>mapreduce.jobhistory.webapp.addressname>
<value>nn.hadoop.data.example.net:19888value>
property>
configuration>
yarn-site.xml
<configuration>
<property>
<name>yarn.resourcemanager.hostnamename>
<value>nn.hadoop.data.example.netvalue>
property>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.classname>
<value>org.apache.hadoop.mapred.ShuffleHandlervalue>
property>
configuration>
hadoop namenode -format
将/app/hadoop(包括data、name、tmp和配置好的hadoop)复制到其他机器。
start-dfs.sh
start-yarn.sh
mr-jobhistory-daemon.sh start historyserver
mkdir /app/spark
wget http://www.apache.org/dyn/closer.lua/spark/spark-2.1.0/spark-2.1.0-bin-hadoop2.7.tgz
mv spark-2.1.0-bin-hadoop2.7.tgz /app/spark
tar -zxvf spark-2.1.0-bin-hadoop2.7.tgz
/etc/profile (root权限)
export SPARK_HOME=/app/spark/spark-2.1.0-bin-hadoop2.7
export PATH="$SPARK_HOME/bin:$PATH"
spark-env.sh
cp spark-env.sh.template spark-env.sh
export SCALA_HOME=/app/scala/scala-2.12.1
export JAVA_HOME=/app/java/jdk1.8.0_121
export SPARK_MASTER_IP=nn.hadoop.data.easydebug.net
export SPARK_WORKER_MEMORY=1g
export HADOOP_CONF_DIR=/app/hadoop/hadoop-2.7.3/etc/hadoop
slaves
dn1.hadoop.data.example.net
dn2.hadoop.data.example.net
将/app/spark复制到其他机器。
/app/spark/spark-2.1.0-bin-hadoop2.7/sbin/start-all.sh
export JAVA_HOME=/app/java/jdk1.8.0_121
export SCALA_HOME=/app/scala/scala-2.12.1
export PATH=$JAVA_HOME/bin:$SCALA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
HADOOP_HOME=/app/hadoop/hadoop-2.7.3
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
export SPARK_HOME=/app/spark/spark-2.1.0-bin-hadoop2.7
export PATH="$SPARK_HOME/bin:$PATH"
参考文章
CentOS 6.5 hadoop 2.7.3 集群环境搭建
http://blog.csdn.net/mxxlevel/article/details/52653086
Spark修炼之道(进阶篇)——Spark入门到精通:第一节 Spark 1.5.0集群搭建
https://yq.aliyun.com/articles/60309?spm=5176.8251999.569296.66.0H8Bal
Hadoop2.7.3+Spark2.1.0 完全分布式环境 搭建全过程
http://www.cnblogs.com/purstar/p/6293605.html