Linux运维常用工具汇总
Ambari 是什么
Ambari 跟 Hadoop 等开源软件一样,也是 Apache Software Foundation 中的一个项目,并且是顶级项目。目前最新的发布版本是 2.0.1,未来不久将发布 2.1 版本。就 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 的安装
安装准备
关于 Ambari 的安装,目前网上能找到两个发行版,一个是 Apache 的 Ambari,另一个是 Hortonworks 的,两者区别不大。这里就以 Apache 的 Ambari 2.0.1 作为示例。本文使用两台 Redhat 6.6 作为安装环境(目前测试验证结果为 Ambari 在 Redhat 6.6 的版本上运行比较稳定),一台机器作为ambari-server,一台作为ambari-agent.
网络环境
主机名称 ip地址
ambariserver 192.168.199.152
ambariagent 192.168.199.199
安装 Ambari 最方便的方式就是使用公共的库源(public repository)。有兴趣的朋友可以自己研究一下搭建一个本地库(local repository)进行安装。这个不是重点,所以不在此赘述。在进行具体的安装之前,需要做几个准备工作。
SSH 的无密码登录;
Ambari 的 Server 会 SSH 到 Agent 的机器,拷贝并执行一些命令。因此我们需要配置 Ambari Server 到 Agent 的 SSH 无密码登录。关于SSH免密登陆,可以参考本站其他相关文章.确保 Yum 可以正常工作;
通过公共库(public repository),安装 Hadoop 这些软件,背后其实就是应用 Yum 在安装公共库里面的 rpm 包。所以这里需要您的机器都能访问 Internet。确保 home 目录的写权限。
Ambari 会创建一些 OS 用户。确保机器的 Python 版本大于或等于 2.6.(Redhat6.6,默认就是 2.6 的)。
以上的准备工作完成后,便可以真正的开始安装 Ambari 了。
安装过程
首先需要获取 Ambari 的公共库文件(public repository)。登录到 Linux 主机并执行下面的命令(也可以自己手工下载):
cd /etc/yum.repos.d/ #切换到yum源目录
wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.0.1/ambari.repo #下载yum源
yum clean #清理缓存
yum install -y ambari-server #安装
[root@ambariserver ~]# yum install ambari-server -yLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileUpdates-ambari-2.0.1 | 2.9 kB 00:00base | 3.7 kB 00:00extras | 3.4 kB 00:00updates | 3.4 kB 00:00Setting up Install ProcessResolving 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--> Running transaction check---> Package postgresql-server.x86_64 0:8.4.20-7.el6 will be installed--> Processing Dependency: postgresql-libs(x86-64) = 8.4.20-7.el6 for package: postgresql-server-8.4.20-7.el6.x86_64--> Processing Dependency: postgresql(x86-64) = 8.4.20-7.el6 for package: postgresql-server-8.4.20-7.el6.x86_64--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-8.4.20-7.el6.x86_64--> Running transaction check---> Package postgresql.x86_64 0:8.4.20-7.el6 will be installed---> Package postgresql-libs.x86_64 0:8.4.20-7.el6 will be installed--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================================================
Package Arch Version Repository Size =============================================================================================================================================================================================== Installing: ambari-server noarch 2.0.1-45 Updates-ambari-2.0.1 86 M Installing for dependencies: postgresql x86_64 8.4.20-7.el6 base 2.6 M postgresql-libs x86_64 8.4.20-7.el6 base 202 k postgresql-server x86_64 8.4.20-7.el6 base 3.4 MTransaction Summary
=============================================================================================================================================================================================== Install 4 Package(s)Total size: 92 M
Total download size: 86 M Installed size: 133 M Downloading Packages: ambari-server-2.0.1-45.noarch.rpm | 86 MB 03:21 warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 07513cad: NOKEY Retrieving key from http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins Importing GPG key 0x07513CAD: Userid: "Jenkins (HDP Builds) <jenkin@hortonworks.com>" From : http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : postgresql-libs-8.4.20-7.el6.x86_64 1/4 Installing : postgresql-8.4.20-7.el6.x86_64 2/4 Installing : postgresql-server-8.4.20-7.el6.x86_64 3/4 Installing : ambari-server-2.0.1-45.noarch 4/4 Verifying : postgresql-8.4.20-7.el6.x86_64 1/4 Verifying : ambari-server-2.0.1-45.noarch 2/4 Verifying : postgresql-libs-8.4.20-7.el6.x86_64 3/4 Verifying : postgresql-server-8.4.20-7.el6.x86_64 4/4Installed:
ambari-server.noarch 0:2.0.1-45Dependency Installed:
postgresql.x86_64 0:8.4.20-7.el6 postgresql-libs.x86_64 0:8.4.20-7.el6 postgresql-server.x86_64 0:8.4.20-7.el6Complete!
提示安装完成
[root@ambariserver ~]# ambari-server setup #开始初始化设置,测试环境一路回车确认即可
Using python /usr/bin/python2.6
Setup ambari-server Checking SELinux... SELinux status is 'enabled' SELinux mode is 'enforcing' Temporarily disabling SELinux WARNING: SELinux is set to 'permissive' mode and temporarily disabled. OK to continue [y/n] (y)? y Customize user account for ambari-server daemon [y/n] (n)? Adjusting ambari-server permissions and ownership... Checking iptables... Checking 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)? Downloading 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.gz jdk-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.gz Installing 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.zip UnlimitedJCEPolicyJDK7.zip... 100% Successfully downloaded JCE Policy archive to /var/lib/ambari-server/resources/UnlimitedJCEPolicyJDK7.zip Installing JCE policy... Completing setup... Configuring database... Enter advanced database configuration [y/n] (n)? Configuring database... Default properties detected. Using built-in database. Configuring ambari database... Checking PostgreSQL... Running initdb: This may take upto a minute. 正在初始化数据库:[确定]About to start PostgreSQL
Configuring local database... Connecting to local database...connection timed out...retrying (1) Connecting to local database...done. Configuring PostgreSQL... Extracting system views... ...ambari-admin-2.0.1.45.jarAdjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
设置成功,,数据库默认使用PostgreSQL,生产环境可根据需要自行修改.
[root@ambariserver ~]# ambari-server start #启动ambari-server服务
Using python /usr/bin/python2.6
Starting ambari-server Ambari Server running with administrator privileges. Running initdb: This may take upto a minute. About to start PostgreSQL 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端口,服务器如果有其他占用8080端口服务请提前关闭)[root@ambariserver ~]# netstat -an|grep 8080tcp 0 0 :::8080 :::* LISTEN
进行UI访问测试.
浏览器访问:http://192.168.199.152:8080
登录密码为 admin/admin。登入 Ambari 之后的页面如下图。
看到此页面,Ambari-Server 就算是安装成功了
精彩评论