Redhat6.6安装Ambari2.0.1

来源:互联网 发布:on淘宝旗舰店 编辑:程序博客网 时间:2024/05/21 15:06

RedHat6.6 64位下载地址 链接:https://pan.baidu.com/s/1o6FkKkE(密码:1aah)

ambari官网:http://ambari.apache.org/


Ambari是什么:

Ambari跟Hadoop等开源软件一样,也是Apache Software Foundation中的一个项目,并且是顶级项目。就Ambari的作用来说,就是创建、管理、监视Hadoop的集群,但是这里的Hadoop是广义指的是Hadoop整个生态圈(例如Hive,Hbase,Sqoop,Zookeeper 等),而并不仅是特指Hadoop。用一句话来说,Ambari就是为了让Hadoop以及相关的大数据软件更容易使用的一个工具。
说到这里,大家就应该明白什么人最需要Ambari了。那些苦苦花费好几天去安装、调试Hadoop的初学者是最能体会到Ambari的方便之处的。而且,Ambari现在所支持的平台组件也越来越多,例如流行的Spark,Storm等计算框架,以及资源调度平台YARN等,我们都能轻松地通过Ambari来进行部署。
Ambari自身也是一个分布式架构的软件,主要由两部分组成:Ambari Server和 Ambari Agent。简单来说,用户通过Ambari Server通知Ambari Agent安装对应的软件;Agent会定时地发送各个机器每个软件模块的状态给Ambari Server,最终这些状态信息会呈现在Ambari的GUI,方便用户了解到集群的各种状态,并进行相应的维护。


安装准备:
关于Ambari的安装,目前网上能找到两个发行版,一个是Apache的Ambari,另一个是Hortonworks的,两者区别不大。这里就以Apache的Ambari 2.0.1作为示例。本文使用三台Redhat 6.6作为安装环境(目前测试验证结果为Ambari在Redhat 6.6的版本上运行比较稳定),三台机器分别为192.168.205.149、192.168.205.150/192.168.205.151计划安装为Ambari的Server,另外两台为Ambari Agent。
安装Ambari最方便的方式就是使用公共的库源(public repository)。有兴趣的朋友可以自己研究一下搭建一个本地库(local repository)进行安装。这个不是重点,所以不在此赘述。在进行具体的安装之前,需要做几个准备工作。
1.SSH的无密码登录;
Ambari的Server会SSH到Agent的机器,拷贝并执行一些命令。因此我们需要配置Ambari Server到Agent的SSH无密码登录。在这个例子里,192.168.205.149可以SSH无密码登录192.168.205.150和192.168.205.151。
2.确保Yum可以正常工作;
通过公共库(public repository),安装Hadoop这些软件,背后其实就是应用Yum在安装公共库里面的rpm包。所以这里需要您的机器都能访问Internet。
3.确保home目录的写权限:
Ambari会创建一些OS用户。
4.确保机器的Python版本大于或等于 2.6.(Redhat6.6,默认就是 2.6 的):
以上的准备工作完成后,便可以真正的开始安装Ambari了。


安装过程:
首先需要获取Ambari的公共库文件(public repository)。登录到Linux主机并执行下面的命令(也可以自己手工下载):
[root@localhost ~]# wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.0.1/ambari.repo


将下载的ambari.repo文件移动到Linux的系统目录/etc/yum.repos.d/。拷贝完后,我们需要获取该公共库的所有的源文件列表。依次执行以下命令。
[root@localhost ~]# mv ambari.repo /etc/yum.repos.d/
[root@localhost ~]# yum clean all
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: Updates-ambari-2.0.1
Cleaning up Everything


[root@localhost ~]# yum list|grep ambari (获取公共库源文件列表)
ambari-agent.x86_64                       2.0.1-45                            Updates-ambari-2.0.1
ambari-log4j.noarch                       2.0.1.45-1                          Updates-ambari-2.0.1
ambari-metrics-collector.x86_64           2.0.1-45                            Updates-ambari-2.0.1
ambari-metrics-common.noarch              2.0.1-45                            Updates-ambari-2.0.1
ambari-metrics-hadoop-sink.x86_64         2.0.1-45                            Updates-ambari-2.0.1
ambari-metrics-monitor.x86_64             2.0.1-45                            Updates-ambari-2.0.1
ambari-server.noarch                      2.0.1-45                            Updates-ambari-2.0.1
hdp_mon_ganglia_addons.noarch             2.0.1.45-1.el6                      Updates-ambari-2.0.1
hdp_mon_nagios_addons.noarch              2.0.1.45-1.el6                      Updates-ambari-2.0.1


如果可以看到Ambari的对应版本的安装包列表,说明公共库已配置成功。然后就可以安装Ambari的package了。执行下面的命令安装Ambari Server到该机器。
[root@localhost ~]# yum install ambari-server
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ambari-server.noarch 0:2.0.1-45 will be installed
--> Processing Dependency: postgresql-server >= 8.1 for package: ambari-server-2.0.1-45.noarch
--> Finished Dependency Resolution
Error: Package: ambari-server-2.0.1-45.noarch (Updates-ambari-2.0.1)
           Requires: postgresql-server >= 8.1
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest


还得将镜像挂载才正常,将“已连接”勾选后,选择你镜像所存放的位置后修改rhel-source.repo文件,Redhat5.5是/etc/yum.repos.d/rhel-debuginfo.repo:
[root@localhost ~]# vi /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media/Server
enabled=1
gpgcheck=0


[root@localhost ~]# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only


[root@localhost ~]# yum install ambari-server (不知道网络为什么会下载的特别慢,令人心烦)


待安装完成后,便需要对Ambari Server做一个简单的配置。执行下面的命令。

[root@localhost ~]# ambari-server setupUsing python  /usr/bin/python2.6Setup ambari-serverChecking SELinux...SELinux status is 'enabled'SELinux mode is 'enforcing'Temporarily disabling SELinuxWARNING: SELinux is set to 'permissive' mode and temporarily disabled.OK to continue [y/n] (y)? yCustomize user account for ambari-server daemon [y/n] (n)? yEnter user account for ambari-server daemon (root):Adjusting ambari-server permissions and ownership...Checking iptables...WARNING: iptables is running. Confirm the necessary Ambari ports are accessible. Refer to the Ambari documentation for more details on ports.OK to continue [y/n] (y)? yChecking JDK...[1] Oracle JDK 1.7[2] Oracle JDK 1.6[3] - Custom JDK==============================================================================Enter choice (1): To download the Oracle JDK and the Java Cryptography Extension (JCE) Policy Files you must accept the license terms found at http://www.oracle.com/technetwork/java/javase/terms/license/index.html and not accepting will cancel the Ambari Server setup and you must install the JDK and JCE files manually.Do you accept the Oracle Binary Code License Agreement [y/n] (y)? yDownloading JDK from http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-7u67-linux-x64.tar.gz to /var/lib/ambari-server/resources/jdk-7u67-linux-x64.tar.gzjdk-7u67-linux-x64.tar.gz... 100% (135.8 MB of 135.8 MB)Successfully downloaded JDK distribution to /var/lib/ambari-server/resources/jdk-7u67-linux-x64.tar.gzInstalling JDK to /usr/jdk64/Successfully installed JDK to /usr/jdk64/Downloading JCE Policy archive from http://public-repo-1.hortonworks.com/ARTIFACTS/UnlimitedJCEPolicyJDK7.zip to /var/lib/ambari-server/resources/UnlimitedJCEPolicyJDK7.zipUnlimitedJCEPolicyJDK7.zip... 100%Successfully downloaded JCE Policy archive to /var/lib/ambari-server/resources/UnlimitedJCEPolicyJDK7.zipInstalling JCE policy...Completing setup...Configuring database...Enter advanced database configuration [y/n] (n)? yConfiguring database...==============================================================================Choose one of the following options:[1] - PostgreSQL (Embedded)[2] - Oracle[3] - MySQL[4] - PostgreSQL==============================================================================Enter choice (1): Database name (ambari): Postgres schema (ambari): Username (ambari): Enter Database Password (bigdata): Default properties detected. Using built-in database.Configuring ambari database...Checking PostgreSQL...Running initdb: This may take upto a minute.Initializing database: [  OK  ]About to start PostgreSQLConfiguring local database...Connecting to local database...done.Configuring PostgreSQL...Restarting PostgreSQLExtracting system views......ambari-admin-2.0.1.45.jarAdjusting ambari-server permissions and ownership...Ambari Server 'setup' completed successfully.
在这个交互式的设置中,采用默认配置即可。Ambari会使用Postgres数据库,默认会安装并使用Oracle的JDK。默认设置了Ambari GUI的登录用户为admin/admin。并且指定Ambari Server的运行用户为root。


简单的setup配置完成后。就可以启动Ambari了。运行下面的命令。
[root@localhost ~]# ambari-server start
Using python  /usr/bin/python2.6
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start....................
Ambari Server 'start' completed successfully.


当成功启动Ambari Server之后,便可以从浏览器登录,默认的端口为8080,在此之前先检查是否已关闭防火墙和selinux。以本文环境为例,在浏览器的地址栏输入http://192.168.205.149:8080,登录密码为admin/admin。
关闭防火墙和selinux(所有集群上节点)
service iptables stop
chkconfig iptables off(设置自动启动为关闭)

vi /etc/selinux/config
SELINUX=disabled


登入Ambari之后的页面如下图:


至此,Ambari Server 就安装完成了。


部署一个Hadoop2.x集群

到这一节,我们将可以真正地体验到Ambari的用武之地,以及它所能带来的方便之处。
登录Ambari之后,点击按钮“Launch Install Wizard”,就可以开始创建属于自己的大数据平台。


第一步,命名集群的名字。本环境为bigdata。



第二步,选择一个Stack,这个Stack 相当于一个Hadoop生态圈软件的集合。Stack的版本越高,里面的软件版本也就越高。这里我们选择HDP2.2,里面的对应的Hadoop版本为2.6.x。



第三步,指定Agent机器(如果配置了域,必须包含完整域名),这些机器会被安装Hadoop等软件包。还记得在安装章节中提到的SSH无密码登陆吗,这里需要指定当时在Ambari Server机器生成的私钥(ssh-keygen生成的,公钥已经拷贝到Ambari Agent的机器)。另外不要选择“Perform manual registration on hosts and do not use SSH“。因为我们需要Ambari Server自动去安装Ambari Agent。具体参见下图示例。

SSH无密码登录配置(在RedHat6.6中还必须按如下操作,如果按我的另一篇文章Ambari2.2.2安装部署(Centos7.2)中的方法操作的话则不好使),三台机器都做如下操作:

[root@localhost ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.(私钥保存地址,将此私钥文件下载到你的Windows本地,图五用的到)Your public key has been saved in /root/.ssh/id_rsa.pub.(公钥保存地址)The key fingerprint is:aa:45:2c:1d:53:7c:49:49:11:11:a0:46:fe:d5:26:fd root@localhost.localdomainThe key's randomart image is:+--[ RSA 2048]----+|      ..o+BB     ||     o o. +o     ||      *  .o +    ||     + + . o .   ||    . + S     E  ||     o .         ||      o          ||     o           ||    .            |+-----------------+[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.205.149The authenticity of host '192.168.205.149 (192.168.205.149)' can't be established.RSA key fingerprint is ae:3e:03:2b:64:70:9a:33:9c:6f:93:6b:fb:89:67:a3.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.205.149' (RSA) to the list of known hosts.root@192.168.205.149's password: Now try logging into the machine, with "ssh '192.168.205.149'", and check in:  .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.205.150[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.205.151
检查DNS和NSCD,所有节点都要设置,ambari在安装时需要配置全域名,所以需要检查DNS。否则会出现如下情况:


注意:如果你在出现了这个警告后修改主机名重启你的虚拟机后可能http://192.168.205.149:8080无法找到网页,这时候你需要再执行一遍ambari-server setup才行
为了减轻DNS的负担, 建议在节点里用Name Service Caching Daemon (NSCD)(不太懂这是啥)

[root@localhost ~]# vi /etc/hosts
192.168.205.149 HUI-001 HUI-001.hadoop
192.168.205.150 HUI-002 HUI-002.hadoop
192.168.205.151 HUI-003 HUI-003.hadoop
每台节点里配置FQDN,如下以主节点为例
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=HUI-001.hadoop
三台再重启机器
[root@localhost ~]# reboot



第四步,Ambari Server会自动安装Ambari Agent到刚才指定的机器列表。安装完成后,Agent会向Ambari Server注册。成功注册后,就可以继续Next到下一步。


检查后我这里有两个报错:


解决报错1:
所有集群上节点都需要操作

echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag


解决报错2:
开启NTP服务
所有集群上节点都需要操作
service ntpd start

再检查后一切正常


第五步,这里我们终于看到跟Hadoop有关的名词了。在这一步,我们需要选择要安装的软件名称。本文环境选择了Zoopkeeper,Storm(由于我内存有限,所以只能少选一些了,否则会报图十三的警告)。选的越多,就会需要越多的机器内存。选择之后就可以继续下一步了。这里需要注意某些Service是有依赖关系的。如果您选了一个需要依赖其他Service的一个Service,Ambari会提醒安装对应依赖的Service。参见下图。


注意:如果你不选择Ambari Metrics的话,点击下一步会弹出如下警告,如果你选了的话所需的内存还挺大的,最后又会报图十三的警告,你也可以点击“Proceed Anyway”而跳过不安装



第六步和第七步,分别是选择安装软件所指定的Master机器和Slave机器,以及Client机器。这里使用默认选择即可(真正在生产环境中,需要根据具体的机器配置选择)。




第八步,就是Service的配置。绝大部分配置已经有默认值,不需要修改。初学者,如果不需要进行调优是可以直接使用默认配置的。有些Service会有一些必须的手工配置项,则必须手动输入,才可以下一步。本文环境直接使用默认配置。


如果你在第五步选的太多的话会有这个警告:



第九步,Ambari会总结一个安装列表,供用户审阅。这里没问题,就直接下一步。



第十步,Ambari会开始安装选择的Service到Ambari Agent的机器(如下图)。这里可能需要等好一会,因为都是在线安装。安装完成之后,Ambari就会启动这些Service。

Service的安装进度:



安装成功


至此,您专属的bigdata集群已经安装完成。


参考:

https://www.ibm.com/developerworks/cn/opensource/os-cn-bigdata-ambari/