Ambari部署hadoop集群
1、基本工具
yum、scp、curl、wget、pdsh、ssh
2、环境准备
2.1、系统环境
Centos6.5 64bit
Ambari 1.4.3.38
2.2、ambari server 与 ambari agent 服务器root ssh无密互访
Ambari server服务器
Ssh-keygen 生产私钥公钥 id_rsa id_rsa.pub
Ambari agent服务器
将ambari server 服上root生成的id_rsa.pub上传到各个集群机器上。
cat id_rsa.pub >> authorized_keys
Ambar server
ssh root@ambariagent
2.3、所有集群机器时间同步
安装ntp服务
2.4、所有集群机器关闭selinux
setenforce 0
2.5、所有集群机器关闭防火墙
/etc/init.d/iptables stop
2.6、所有集群机器centos关闭packagekit
vim /etc/yum/pluginconf.d/refresh-packagekit.conf
enabled=0
3、安装准备
注:本节只需要在ambari server服务器上做
3.1、安装源
wget http://public-repo-1.hortonworks.com/ambari/centos6/1.x/GA/ambari.repo
cp ambari.repo /etc/yum.repos.d
这个源可能会非常慢,如果慢可以部署本地源(以下为可选,一般ambari源所需资源少,不需要部署本地源),步奏如下:
1、下载打包好的ambari源百度云盘
2、在ambari-server机器上部署源,将上面下载的文件解压到如/var/www/html/目录下
3、修改ambari.repo文件如下,注意黄色部分即可
[ambari-1.x]
name=Ambari 1.x
baseurl=file:///var/www/html/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.16]
name=Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.16
baseurl=file:///var/www/html/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[Updates-ambari-1.x]
name=ambari-1.x - Updates
baseurl=file:///var/www/html/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
3.2、Install the epel repository
yum install epel-release
yum repolist
3.3、安装ambari server
yum install ambari-server
3.4、设置ambari server
ambari-server setup
一路按确定即可,ambari-server会用到数据库,自行选择默认使用PostgreSQL,如果你选择使用mysql还需要把jdbc驱动放到/usr/lib/ambari-server目录下,会自动下载jdk-6u31-linux-x64.bin到/var/lib/ambari-server/resources你可以可以自己下载
安装好之后 启动ambari-server
ambari-server start
如果启动失败主义看几个日志文件/var/log/ambari-server
查看ambari-server状态
ambari-server status
注:如果不自己使用自己创建的源,一下步奏略过
ambari-server 会自己搭建一个web服务器根目录为/usr/lib/ambari-server/web端口号为8080我们可以通过 http://ambari-server-hostname:8080/访问到,我们要利用起来这个web服务器(也可以使用自己已有服务器)部署我们的ambari 和 hdp源,步骤如下:
1、将3.1中/var/www/html/ambari/复制到/usr/lib/ambari-server/web
cp -r /var/www/html/ambari/ /usr/lib/ambari-server/web
2、同时修改ambari.repo
[ambari-1.x]
name=Ambari 1.x
baseurl=http://ambari-server-hostname:8080/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.16]
name=Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.16
baseurl=http://ambari-server-hostname:8080/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[Updates-ambari-1.x]
name=ambari-1.x - Updates
baseurl=http://ambari-server-hostname:8080/ambari/
gpgcheck=0
gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
3、创建HDP源
将HDP源(我自己打包好的源)百度云盘下载并解压到/usr/lib/ambari-server/web下可以看到一个hdp文件夹
4、修改repoinfo.xml文件
cd /var/lib/ambari-server/resources/stacks/HDP/2.0.6/repos
修改如下部分,我使用的是centos6.5所以修改对应的。
<os type="centos6">
<repo>
<baseurl>http://ambari-server-hostname:8080/hdp/</baseurl>
<repoid>HDP-2.0.6</repoid>
<reponame>HDP</reponame>
</repo>
</os>
<os type="oraclelinux6">
<repo>
<baseurl>http://ambari-server-hostname:8080/hdp/</baseurl>
<repoid>HDP-2.0.6</repoid>
<reponame>HDP</reponame>
</repo>
</os>
<os type="redhat6">
<repo>
<baseurl>http://ambari-server-hostname:8080/hdp/</baseurl>
<repoid>HDP-2.0.6</repoid>
<reponame>HDP</reponame>
</repo>
</os>
在安装过程中,ambari会在集群机器上创建一个HDP.repo的源文件,文件的内容就是我们这里修改的相关信息。
4、安装
浏览器访问http://ambari-server-hostname:8080/
按照步奏一步步走在这一步时注意,选择自己对应得版本,我使用的是2.0.6前面章节中我也配置的是2.0.6版本,其他版本类似修改。
在安装中可能会出现多次失败,如果retry很多次还这样就要清理各个机器上的相关类库,用户,目录,配置等信息。所以建议最好在一个新安装的纯净系统上使用。
5、重新安装
注:以下来自网络,我在安装中也是这样做的,有些内容可能与实际不同,主要就是删除相关包、用户、以及配置
1、停止ambari
所有集群机器
ambari-agent stop
Ambari-server机器
ambari-server stop
2、删除安装包
#用yum list installed | grep HDP来检查安装的hadoop相关的包
yum remove -y sqoop.noarch
yum remove -y lzo-devel.x86_64
yum remove -y hadoop-libhdfs.x86_64
yum remove -y rrdtool.x86_64
yum remove -y hbase.noarch
yum remove -y pig.noarch
yum remove -y lzo.x86_64
yum remove -y ambari-log4j.noarch
yum remove -y oozie.noarch
yum remove -y oozie-client.noarch
yum remove -y gweb.noarch
yum remove -y snappy-devel.x86_64
yum remove -y hcatalog.noarch
yum remove -y python-rrdtool.x86_64
yum remove -y nagios.x86_64
yum remove -y webhcat-tar-pig.noarch
yum remove -y snappy.x86_64
yum remove -y libconfuse.x86_64
yum remove -y webhcat-tar-hive.noarch
yum remove -y ganglia-gmetad.x86_64
yum remove -y extjs.noarch
yum remove -y hive.noarch
yum remove -y hadoop-lzo.x86_64
yum remove -y hadoop-lzo-native.x86_64
yum remove -y hadoop-native.x86_64
yum remove -y hadoop-pipes.x86_64
yum remove -y nagios-plugins.x86_64
yum remove -y hadoop.x86_64
yum remove -y zookeeper.noarch
yum remove -y hadoop-sbin.x86_64
yum remove -y ganglia-gmond.x86_64
yum remove -y libganglia.x86_64
yum remove -y perl-rrdtool.x86_64
yum remove -y epel-release.noarch
yum remove -y compat-readline5*
yum remove -y fping.x86_64
yum remove -y perl-Crypt-DES.x86_64
yum remove -y exim.x86_64
yum remove -y ganglia-web.noarch
yum remove -y perl-Digest-HMAC.noarch
yum remove -y perl-Digest-SHA1.x86_64
3.删除用户
userdel nagios
userdel hive
userdel ambari-qa
userdel hbase
userdel oozie
userdel hcat
userdel mapred
userdel hdfs
userdel rrdcached
userdel zookeeper
userdel sqoop
userdel puppet
4.删除快捷方式
cd /etc/alternatives
rm -rf hadoop-etc
rm -rf zookeeper-conf
rm -rf hbase-conf
rm -rf hadoop-log
rm -rf hadoop-lib
rm -rf hadoop-default
rm -rf oozie-conf
rm -rf hcatalog-conf
rm -rf hive-conf
rm -rf hadoop-man
rm -rf sqoop-conf
rm -rf hadoop-conf
5.删除文件夹
rm -rf /var/lib/pgsql
rm -rf /hadoop
rm -rf /etc/hadoop
rm -rf /etc/hbase
rm -rf /etc/hcatalog
rm -rf /etc/hive
rm -rf /etc/ganglia
rm -rf /etc/nagios
rm -rf /etc/oozie
rm -rf /etc/sqoop
rm -rf /etc/zookeeper
rm -rf /var/run/hadoop
rm -rf /var/run/hbase
rm -rf /var/run/hive
rm -rf /var/run/ganglia
rm -rf /var/run/nagios
rm -rf /var/run/oozie
rm -rf /var/run/zookeeper
rm -rf /var/log/hadoop
rm -rf /var/log/hbase
rm -rf /var/log/hive
rm -rf /var/log/nagios
rm -rf /var/log/oozie
rm -rf /var/log/zookeeper
rm -rf /usr/lib/hadoop
rm -rf /usr/lib/hbase
rm -rf /usr/lib/hcatalog
rm -rf /usr/lib/hive
rm -rf /usr/lib/oozie
rm -rf /usr/lib/sqoop
rm -rf /usr/lib/zookeeper
rm -rf /var/lib/hive
rm -rf /var/lib/ganglia
rm -rf /var/lib/oozie
rm -rf /var/lib/zookeeper
rm -rf /var/tmp/oozie
rm -rf /tmp/hive
rm -rf /tmp/nagios
rm -rf /tmp/ambari-qa
rm -rf /tmp/sqoop-ambari-qa
rm -rf /var/nagios
rm -rf /hadoop/oozie
rm -rf /hadoop/zookeeper
rm -rf /hadoop/mapred
rm -rf /hadoop/hdfs
rm -rf /tmp/hadoop-hive
rm -rf /tmp/hadoop-nagios
rm -rf /tmp/hadoop-hcat
rm -rf /tmp/hadoop-ambari-qa
rm -rf /tmp/hsperfdata_hbase
rm -rf /tmp/hsperfdata_hive
rm -rf /tmp/hsperfdata_nagios
rm -rf /tmp/hsperfdata_oozie
rm -rf /tmp/hsperfdata_zookeeper
rm -rf /tmp/hsperfdata_mapred
rm -rf /tmp/hsperfdata_hdfs
rm -rf /tmp/hsperfdata_hcat
rm -rf /tmp/hsperfdata_ambari-qa
6.删除ambari包
#采用这句命令来检查yum list installed | grep ambari
yum remove -y ambari-*
yum remove -y postgresql
rm -rf /var/lib/ambari*
rm -rf /var/log/ambari*
rm -rf /etc/ambari*
7.删除HDP.repo和amabari.repo
cd /etc/yum.repos.d/
rm -rf HDP*
rm -rf ambari*