基于apache ambari 的大数据平台搭建并运行WordCount
操作系统:3个 rhel 6.4,内存2g,动态硬盘20g。
虚拟机软件:virtualBox
注意:
1、yum可能要重新安装,可百度解决
1、确保三个host能互相ping通
每个host配置DNS
vi /etc/hosts
为host4安装http服务
yum install httpd
用Xftp4软件连接host4的文件系统
连接成功后显示
进入目录/var/www/html
将三个压缩包从windows传到host4的上面那个目录里,分别是:
HDP:HDP-2.6.0.3-centos6-rpm.tar.gz
HDP-UTILS:HDP-UTILS-1.1.0.21-centos6.tar.gz
Ambari 2.5.0 :ambari-2.5.0.3-centos6.tar.gz
解压
tar -zxvf ambari-2.5.0.3-centos6.tar.gz
tar -zxvf HDP-2.6.0.3-centos6-rpm.tar.gz
tar -zxvf HDP-UTILS-1.1.0.21-centos6.tar.gz
解压时注意空间不够的问题,最好先解压大的文件,解压完删除对应的压缩文件。
启动http服务
在浏览器上输入10.132.102.71/ambari/
在浏览器上输入http://10.132.102.71/HDP/centos6/
在浏览器上输入http://10.132.102.71/HDP-UTILS-1.1.0.21/
接下来配置host1到其它host能root免密码登录。
为每个host 执行
ssh-******
cd .ssh
touch authorized_keys
host1 执行
cat id_rsa.pub >> authorized_keys
把host1的authorized_keys拷贝到其它host的.ssh下
scp authorized_keys [email protected]:~/.ssh
scp authorized_keys [email protected]:~/.ssh
更改目录和文件的权限,每个host执行
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
每个host安装ntp
yum install -y ntp
设置ntp开机自启动
chkconfig ntpd on
启动ntp
service ntpd start
关闭防火墙
chkconfig iptables off
disable SELinux
setenforce 0
Setting the umask for your current login session:
umask 0022
Checking your current umask:
umask 0022
Permanently changing the umask for all interactive users:
echo umask 0022 >> /etc/profile
每个host下载ambari.repo
地址:
http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.5.0.3/ambari.repo
并将文件放到/etc/yum.repos.d/下
cp ambari.repo /etc/yum.repos.d/
执行
cat /sys/kernel/mm/transparent_hugepage/enabled
若中括号在always两侧,自行百度“如何将Transparent HugePages关闭”解决
选择host1安装ambari服务器
yum install ambari-server
将jdk-8u112-linux-x64.tar.gz放到/var/lib/ambari-server/resources/目录下,否则自动下载Java时会很慢。
ambari-server setup
setup第一次可能会失败,我试了三次就成功了。
启动ambari服务器
ambari-server start
在浏览器中输入10.132.102.61:8080
用户名和密码都是admin
点击Launch Install Wizard,随便起个名字
复制host1的私钥(id_rsa)到下面的编辑框
注册认证
由于内存不够,这里只示范两个host
注意检查红框里的警告
如没有警告,Next。
此处只选择HDFS和MapReduce服务,Next。
Next
DataNode都打钩,next
红色的数字都是要求设置密码的,设置好后next
Deploy
到这里,部署成功了,增加删除结点和服务都可以在此基础上操作。
接下来运行wordcount自带例程
自己在本地创建好word_test.txt,并通过copyfromlocal复制到hdfs下。
hadoop fs -cat /tmp/input/word_test.txt
sudo -u hdfs hadoop jar /usr/hdp/2.6.0.3-8/hadoop-mapreduce/hadoop-mapreduce-examples-2.7.3.2.6.0.3-8.jar wordcount /tmp/input/word_test.txt /tmp/output
hadoop fs -ls /tmp/output
hadoop fs -cat /tmp/output/part-r-00000
结束。