部署环境:
CentOS 6.4 64bit
Hadoop2.7.1、Mysql5.5、Hive1.2.1、Scala2.11.7、Spark1.5.0
jdk1.7.0_79
主机IP:
master(namenode):10.10.4.115
slave1(datanode):10.10.4.116
slave2(datanode):10.10.4.117
一、环境准备及Hadoop部署:
(1)环境准备(host配置必须一致,否则可能导致错误):
[root@master ~]#vi /etc/hosts
127.0.0.1 localhost
10.10.4.115 master.hadoop
10.10.4.116 slave1.hadoop
10.10.4.117 slave2.hadoop
(2)设置主机名:
[root@master ~]#vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=master.hadoop
(3)使其hostname即时生效:
可重启系统;
或者使用命令:
[root@master ~]#hostname master.hadoop
或者
[root@master ~]#echo master.hadoop > /proc/sys/kernel/hostname
(4)关闭防火墙服务:
[root@master ~]#service iptables stop
避免重启系统后iptables启动:
[root@master ~]#chkconfig iptables off
确认已关闭
[root@master ~]#chkconfig --list|grep iptables
iptables 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
chkconfig关闭iptables并不能永久关闭iptables,在重启系统后,level3下会自动启动iptables,这时候我们可以将iptables规则清空后保存,间接达到永久关闭的需求:
echo "" > /etc/sysconfig/iptables
(5)关闭selinux
[root@master ~]#vi /etc/sysconfig/selinux
修改SELINUX=disabled
(6)卸载默认安装的openjdk(hadoop官方建议使用oracle版本jdk):
检查是否安装):
[root@master ~]#rpm -qa|grep openjdk
卸载安装的openjdk:
[root@master ~]#rpm -e openjdk
(7)下载并安装oracle jdk1.7.0_79:
[root@master ~]#rpm -ivh jdk-7u79-linux-x64.rpm
(8)设置环境变量:
[root@master ~]#vi /etc/profile
##############JAVA#############################
export JAVA_HOME=/usr/java/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
export PATH=/usr/local/mysql/bin:$JAVA_HOME/bin:$PATH
################END############################
(9)使其生效:
[root@master ~]#source /etc/profile
(10)测试:
[root@master ~]#echo $JAVA_HOME
/usr/java/jdk1.7.0_79
(11)创建hadoop用户及群组:
[root@master ~]#useradd hadoop -p mangocity
(12)配置master免密码登录slave:
启用免密码登录ssh配置:
[root@master ~]#vi /etc/ssh/sshd_config
RSAAuthentication yes # 启用 RSA 认证
PubkeyAuthentication yes # 启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys # 公钥文件路径(和上面生成的文件同)
(13)设置完之后记得重启SSH服务,才能使刚才设置有效:
[root@master ~]#service sshd restart
#######以上设置slave服务器设置类同master##########
(14)在master上切换到hadoop用户,生成公钥:
[root@master ~]#su - hadoop
(15)生成公钥:
[hadoop@master ~]$ssh-keygen �Ct rsa �CP ''
[hadoop@master ~]$more /home/hadoop/.ssh/id_rsa.pub
ssh-rsa AAAB3**************************************************7RbuPw== [email protected]
(16)把id_rsa.pub内容追加到授权的key:
[hadoop@master ~]$cat /home/hadoop/.ssh/id_rsa.pub >> /home/hadoop/.ssh/authorized_keys
(17)验证本地免密码登录:
验证之前确认/home/hadoop/.ssh/authorized_keys的权限为600,即只有hadoop用户拥有rw权限:
[hadoop@master ~]$ ll ./.ssh/authorized_keys
-rw-------. 1 hadoop hadoop 402 11月 18 01:53 ./.ssh/authorized_keys
如权限不对,则会导致免密码登录失败;如权限非600,则需要修改其权限为600:
[hadoop@master ~]$chmod 600 ~/.ssh/authorized_keys
(18)测试验证:
[hadoop@master ~]$ssh 127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is 31:45:00:ff:a7:80:23:f2:2a:86:7f:13:0d:bf:f0:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
[email protected]'s password:(第一次登录需要输入密码)
[hadoop@master ~]$exit
[hadoop@master ~]$ssh 127.0.0.1
Last login: Mon Nov 23 09:52:02 2015 from localhost(第二次登录不需要输入密码,说明本地登录验证成功)
[hadoop@master ~]$
(19)设置slave服务器ssh免密码登录:
此时slave服务器的hadoop的家目录下是没有.ssh目录和authorized_keys的,需要手动建立:
[hadoop@slave1 ~]#su -hadoop
[hadoop@slave1 ~]$ls -a
. .. .bash_history .bash_logout .bash_profile .bashrc .gnome2 .viminfo
(20)手动建立目录、修改权限:
[hadoop@slave1 ~]$mkdir ./.ssh
[hadoop@slave1 ~]$chmod 700 ./.ssh
(21)手动创建文件、修改文件权限:
[hadoop@slave1 ~]$touch ./.ssh/authorized_keys
[hadoop@slave1 ~]$chmod 600 ./.ssh/authorized_keys
[hadoop@slave1 ~]$ls -a
. .. .bash_history .bash_logout .bash_profile .bashrc .gnome2 .ssh .viminfo
(22)将master服务器上hadoop用户建立的公钥文件id_rsa.pub复制到slave服务器hadoop用户目录:
[hadoop@slave1 ~]$scp [email protected]:/home/hadoop/id_rsa.pub /home/hadoop/
(23)将master服务器hadoop用户的公钥id_rsa.pub内容追加到授权的authorized_keys文件中:
[hadoop@slave1 ~]$cat /home/hadoop/.ssh/id_rsa.pub >> /home/hadoop/.ssh/authorized_keys
以上步骤在slave2服务器重复操作一遍,更改/etc/ssh/sshd_config配置并重启sshd服务。
(24)测试验证master免密码登录slave服务器配置:
[hadoop@master ~]$ssh slave1.hadoop
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
[email protected]'s password:(第一次登录需要输入密码)
[hadoop@slave1 ~]$exit
logout
Connection to slave1.hadoop closed.
[hadoop@master ~]$ ssh slave1.hadoop
Last login: Mon Nov 23 19:25:05 2015 from master.hadoop(第二次登录不需要输入密码,且当前用户已切换到slave1的hadoop,说明无密码登录验证成功)
[hadoop@slave1 ~]$
验证master免密码登录slave2服务器的过程和slave1相同。
部署hadoop2.7.1到master:
(1)下载并解压源码包:
[root@master ~]#tar -xvf hadoop-2.7.1.tar.gz
[root@master ~]#cp -Rv ./hadoop-2.7.1 /usr/local/hadoop/
(2)/usr/local/hadoop建立一些需要用到的目录:
[root@master ~]#mkdir -p /usr/local/hadoop/tmp /usr/local/hadoop/dfs/data /usr/local/hadoop/dfs/name
[root@master ~]#chown -R hadoop:hadoop /usr/local/hadoop/
(3)设置环境变量(slave服务器与master一致):
vi /etc/profile
##############Hadoop###########################
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export PATH=/usr/local/mysql/bin:$HADOOP_HOME/bin:$PATH
################END############################
(4)使其生效:
source /etc/profile生效
(5)切换到hadoop用户,修改hadoop相关配置,相关文件存放在$HADOOP_HOME/etc/hadoop/下,主要配置core-site.xml、hdfs-site.xml、mapred-site.xml、yarn-site.xml这几个site文件:
[root@master ~]#su - hadoop
[hadoop@master ~]$ cd /usr/local/hadoop/etc/hadoop/[root@master ~]#su - hadoop
[hadoop@master ~]$ cd /usr/local/hadoop/etc/hadoop/
(6)修改env环境变量文件,将hadoop-env.sh,mapred-env.sh,yarn-env.sh末尾都添加上JAVA_HOME环境变量:
[hadoop@master hadoop]$vi hadoop-env.sh
export JAVA_HOME=/usr/java/jdk1.7.0_79 ###在文件末尾添加上这一行,另外2个文件相同方式修改
修改site文件,相关配置如下:
(7)core-site.xml:
[hadoop@master hadoop]$more core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master.hadoop:9000</value> #因后期需要整合hive,这里要用hostname
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/hadoop/tmp</value>
<description>Abasefor other temporary directories.</description>
</property>
</configuration>
(8)mapred-site.xml:
[hadoop@master hadoop]$more mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
(9)hdfs-site.xml:
[hadoop@master hadoop]$more hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>10.10.4.115:9001</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
(10)yarn-site.xml
[hadoop@master hadoop]$more yarn-site.xml
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>10.10.4.115</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>10.10.4.115:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>10.10.4.115:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>10.10.4.115:8035</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>10.10.4.115:8033</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>10.10.4.115:8088</value>
</property>
(11)添加datanode节点:
[root@master ~]#vi slaves
10.10.4.116 #可以填IP地址也可以填hostname
10.10.4.116
(12)部署datanode节点:
复制hadoop目录至slave1和slave2节点,并修改目录权限:
[root@master ~]#scp -r /usr/local/hadoop/ [email protected]:/usr/local/
[hadoop@slave1 ~]$chown -R hadoop:hadoop /usr/local/hadoop
[root@master ~]#scp -r /usr/local/hadoop/ [email protected]:/usr/local/
[hadoop@slave2 ~]$chown -R hadoop:hadoop /usr/local/hadoop
(13)格式化namenode:
[root@master ~]#su - hadoop
[hadoop@master ~]$cd /usr/local/hadoop
[hadoop@master hadoop]$./bin/hdfs namenode -format
当出现“successfully formatted”提示,说明格式化成功。
(14)启动hadoop:
[hadoop@master hadoop]$./sbin/start-all.sh
(15)检查master(namenode)进程状态:
[hadoop@master hadoop]$ jps
2697 Jps
7820 SecondaryNameNode
7985 ResourceManager
7614 NameNode
出现以上结果说明namenode节点服务正常运行
(16)检查slave(datanode)进程状态:
[hadoop@slave1 ~]$ jps
18342 DataNode
30450 Jps
18458 NodeManager
(17)显示以上结果说明datanode节点服务正常运行
还可以通过网页监控集群状态等信息:
http://master.hadoop:8088
http://master.hadoop:50070
至此,hadoop集群安装完成,接下来是和Hive的整合。
二、Hive和Hadoop的整合(hive安装在namenode节点上):
(1)安装mysql 5.5(也可以用yum安装,这里使用源码安装):
安装依赖包:
[root@master ~]#yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
(2)下载相应源码包:
[root@master ~]#wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.46.tar.gz
(3)添加mysql用户:
[root@master ~]#useradd -M -s /sbin/nologin mysql
(4)预编译:
[root@master ~]#tar -xzvf mysql-5.5.46.tar.gz
[root@master ~]#mkdir -p /data/mysql
[root@master ~]#cd mysql-5.5.46
[root@master mysql-5.5.46]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ ###mysql5.5版本之后,configura改成cmake
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1
(5)编译安装:
[root@master mysql-5.5.46]#make
[root@master mysql-5.5.46]#make install
(6)启动脚本,设置开机自启动:
[root@master mysql-5.5.46]#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@master mysql-5.5.46]#chmod +x /etc/init.d/mysqld
[root@master mysql-5.5.46]#chkconfig --add mysqld
[root@master mysql-5.5.46]#chkconfig mysqld on
(7)初始化数据库:
[root@master mysql-5.5.46]#/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
(8)设置密码:
[root@master mysql-5.5.46]#mysql -uroot -p #第一次执行时,会要求输入root账户密码
(9)建立hive数据库:
mysql>create database hive;
(10)建立hive账户并授权访问mysql权限:
mysql>grant all privileges on *.* to 'hive'@'%' identified by '123456' with grant option; #设置用户名密码及访问权限授权
mysql>flush privileges;
mysql>alter database hivemeta character set latin1; #更改字符集类型
mysql>flush privileges;
mysql>exit
(11)测试hive账户:
[root@master mysql-5.5.46]#mysql -uhive -pmangocity
mysql>
测试登录成功
安装Hive:
(1)设置全局环境变量(行首添加):
[root@master ~]#vi /etc/profile
#############Hive##############################
export HIVE_HOME=/usr/local/hive-1.2.1
export HIVE_CONF_DIR=$HIVE_HOME/conf
export HIVE_LIB=$HIVE_HOME/lib
export CLASSPATH=$CLASSPATH:$HIVE_LIB
export PATH=$HIVE_HOME/bin/:$PATH
###################END#########################
(2)使其生效:
[root@master ~]#source /etc/profile
(3)下载安装Hive:
[root@master ~]#tar -xzvf apache-hive-1.2.1-bin.tar.gz
[root@master ~#mv ./apache-hive-1.2.1 /usr/local/hive-1.2.1
(4)改变hive目录属组:
[root@master ~]#chown -R hadoop:hadoop /usr/local/hive-1.2.1
su - hadoop
[hadoop@master ~]$cd /usr/local/hive-1.2.1/
(5)将下载好的mysql-connector-java-5.1.6-bin.jar复制到hive 的lib下面:
[hadoop@master hive-1.2.1]$cp /home/hadoop/mysql-connector-java-5.1.37-bin.jar /usr/local/hive-1.2.1/lib/
(6)将$HIVE_HOME/lib下jline-2.12.jar复制到hadoop对应的目录中,替换掉低版本的jline-0.9.94.jar,看通过find查找出具体目录:
[hadoop@master hive-1.2.1]$find /usr/local/hadoop -name jline*.jar
[hadoop@master hive-1.2.1]$mv /usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.4.jar /usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.4.jar.bak #备份旧版本jar包
[hadoop@master hive-1.2.1]$cp /usr/local/hive-1.2.1/lib/jline-2.12.jar /usr/local/hadoop/share/hadoop/yarn/lib/
(8)hive环境变量设置:
编辑$HIVE_HOME/bin/hive-config.sh,页尾添加:
[hadoop@master hive-1.2.1]$vi /usr/local/hive-1.2.1/bin/hive-config.sh
export JAVA_HOME=/usr/java/jdk1.7.0_79
export HADOOP_HOME=/usr/local/hadoop
export HIVE_HOME=/usr/local/hive-1.2.1
(9)hive环境变量设置:
编辑$HADOOP_HOME/etc/hadoop/hadoop-env.sh,页尾添加:
[hadoop@master hive-1.2.1]$vi /usr/local/hadoop/etc/hadoop/hadoop-env.sh
export HIVE_HOME=/usr/local/hive-1.2.1
export HIVE_CONF_DIR=/usr/local/hive-1.2.1/conf
(10)设置hive与mysql连接等参数等文件的配置:
[hadoop@master hive-1.2.1]$vi /usr/local/hive-1.2.1/conf/hive-site.xml
<configuration>
<property>
<name>hive.metastore.local</name> #远程mysql还是本地mysql,这里是本地
<value>ture</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true</value> #JDBC相关参数
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description> #连接mysql所用账户
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description> #连接mysql所用账户密码
</property>
</configuration>
(11)启动Hive:
[hadoop@master hive-1.2.1]$./bin/hive --service metastore & #启动metastore,置于后台运行
[hadoop@master hive-1.2.1]$./bin/hive --service hiveserver & #启动hiveserver,置于后台运行
(12)测试Hive,执行jps,会查看到有一个Runjar进程在运行:
[hadoop@master hive-1.2.1]$jps
5640 NameNode
6013 ResourceManager
5847 SecondaryNameNode
6490 RunJar
13978 Jps
(13)测试hive和hadoop及MySQL的整合:
[hadoop@master hive-1.2.1]$ ./bin/hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/spark-1.5.0/lib/spark-assembly-1.5.0-hadoop2.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/spark-1.5.0/lib/spark-assembly-1.5.0-hadoop2.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
15/11/24 10:12:24 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
Logging initialized using configuration in jar:file:/usr/local/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
hive> show databases;
OK
default
Time taken: 1.878 seconds, Fetched: 1 row(s)
hive> show tables;
OK
Time taken: 2.025 seconds, Fetched: 1 row(s)
hive> create table test(name string, age int); #尝试建立一张表
OK
Time taken: 2.952 seconds
hive> desc test;
OK
name string
age int
Time taken: 0.225 seconds, Fetched: 2 row(s)
hive> exit;
至此,hadoop集群与hive的整合完成,接下来是和spark的整合。
三丶Spark和Hadoop的整合
安装Scala:
(1)将压缩包解压至/usr/scala 目录:
[root@master ~]#tar -zxvf .//scala-2.11.7.tgz
[root@master ~]#mv ./scala-2.11.7 /usr/local/scala-2.11.7
(2)目录授权给hadoop用户:
[root@master ~]#chown -R hadoop:hadoop /usr/local/scala-2.11.7
(3)设置环境变量:
[root@master ~]#vi /etc/profile
追加如下内容:
#############Scale#############################
export SCALA_HOME=/usr/local/scala-2.11.7
export PATH=$PATH:$SCALA_HOME/bin
####################END########################
(4)使其生效:
[root@master ~]#source /etc/profile
(5)测试Scala是否安装配置成功:
[hadoop@master ~]$ scala -version
Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL
安装Spark
官网下载spark1.5.0:spark-1.5.0-bin-hadoop2.6.tgz
(1)将压缩包解压至/usr/local目录:
[root@master ~]#tar -zxvf ./spark-1.5.0-bin-hadoop2.6.tgz
[root@master ~]#mv ./spark-1.5.0 /usr/local/spark-1.5.0
(2)目录授权给hadoop用户:
[root@master ~]#chown -R hadoop:hadoop /usr/local/spark-1.5.0
(3)设置环境变量:
[root@master ~]#vi /etc/profile
追加如下内容
############Spark##############################
export SPARK_HOME=/usr/local/spark-1.5.0
export PATH=$PATH:$SPARK_HOME/bin:$SPARK_HOME/sbin
#################END###########################
(4)使之生效
[root@master ~]#source /etc/profile
(5)测试Spark是否安装配置成功:
[root@master ~]#spark-shell --version
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.5.0
/_/
Type --help for more information.
(6)编辑/usr/local/hadoop/etc/hadoop/hadoop-env.sh,添加如下内容:
export SPARK_MASTER_IP=10.10.4.115
export SPARK_WORKER_MEMORY=1024m
(7)更改spark相关配置:
su - hadoop
cd /usr/local/spark.1.5.0
(8)复制模板并编辑spark-env.sh ,配置相关环境变量:
[hadoop@master spark-1.5.0]$mv ./conf/spark-env.sh.template ./conf/spark-env.sh
[hadoop@master spark-1.5.0]$vi ./conf/spark-env.sh
export HADOOP_CONF_DIR=/usr/local/hadoop/etc/hadoop
export SCALA_HOME=/usr/local/scala-2.11.7
export JAVA_HOME=/usr/java/jdk1.7.0_79
export SPARK_MASTER_IP=10.10.4.115
export SPARK_WORKER_MEMORY=1024m
(9)配置slave节点服务器:
[hadoop@master spark-1.5.0]$vi ./conf/slaves
# A Spark Worker will be started on each of the machines listed below.
slave1.hadoop
slave2.hadoop
(10)切换到root用户,将scala和spark以及相关环境变量配置复制到datanode节点,即salve1和slave2服务器:
[root@master ~]#scp -r /usr/local/scala-2.11.7 [email protected]:/usr/local/scala-2.11.7
[root@master ~]#scp -r /usr/local/spark.1.5.0 [email protected]:/usr/local/spark.1.5.0
登录到slave1服务器,将刚才复制的两个目录授权给hadoop:
chown -R hadoop:hadoop /usr/local/scala-2.11.7 /usr/local/spark.1.5.0
配置slave1服务器/etc/profile,/usr/local/hadoop/etc/hadoop/hadoop-env.sh,使其和master服务器保持一致,并使其生效。
[root@master ~]#scp -r /usr/local/scala-2.11.7 [email protected]:/usr/local/scala-2.11.7
[root@master ~]#scp -r /usr/local/spark.1.5.0 [email protected]:/usr/local/spark.1.5.0
登录到slave2服务器,将刚才复制的两个目录授权给hadoop:
chown -R hadoop:hadoop /usr/local/scala-2.11.7 /usr/local/spark.1.5.0
配置slave2服务器/etc/profile,/usr/local/hadoop/etc/hadoop/hadoop-env.sh,使其和master服务器保持一致,并使其生效。
(11)启动spark和测试:
[hadoop@master spark-1.5.0]$./sbin/start-all.sh
可以通过jps查看namenode节点,会有一个Master进程在运行:
[hadoop@master spark-1.5.0]$jps
5640 NameNode
6013 ResourceManager
5847 SecondaryNameNode
6897 Master
15164 Jps
6490 RunJar
过jps查看datanode节点,会有一个Worker进程在运行:
[hadoop@slave1 ~]$ jps
3982 Jps
31810 DataNode
32136 Worker
31928 NodeManager
也可以通过网页监控到相关信息:
http://master.hadoop:8080
至此,整个Hdoop、Hive、Spark集群环境部署完成。