ambari快速安装hadoop

资源下载http://www.cnblogs.com/bfmq/p/6027202.html

大家都知道hadoop包含很多的组件,虽然很多都是下载后解压简单配置下就可以用的,但是还是耐不住我是一个懒癌晚期患者,最重要的是,没有页面,不够酷炫啊,不酷炫怎么装X?so,apache官方也是很体谅我们这些装X达人,并且提供了一个十分简单的安装hadoop的工具,叫做ambari,官方出品必属精品,那么我们就拿来用吧。


ambari可以让你快速部署一套hadoop环境,不论你是要测试练习还是生产使用都ok,官网http://ambari.apache.org/。
ambari自身是一个分布式架构,主要由两部分组成:Ambari Server 和 Ambari Agent;显而易见由server控制agent来安装对应软件就好了,不过有一个更好的好处就是连安装agent都可以由server来指定自动安装,实在是杀人越货必备良药啊。

所有机器之间的ssh免密认证,这个大家自己做下

 1 [root@linux-node1 ~]# cat /etc/hosts
 2 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 3 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 4 192.168.56.11 linux-node1.example.com www.a.com linux-node1
 5 192.168.56.12 linux-node2.example.com linux-node2
 6 192.168.56.13 linux-node3.example.com linux-node3
 7 [root@linux-node1 ~]# ssh 192.168.56.11
 8 Last login: Wed Jan 24 14:40:13 2018 from 192.168.56.1
 9 [root@linux-node1 ~]# logout
10 Connection to 192.168.56.11 closed.
11 [root@linux-node1 ~]# ssh 192.168.56.12
12 Last login: Wed Jan 24 14:35:36 2018 from 192.168.56.13
13 [root@linux-node2 ~]# logout
14 Connection to 192.168.56.12 closed.
15 [root@linux-node1 ~]# ssh 192.168.56.13
16 Last login: Wed Jan 24 14:35:33 2018 from 192.168.56.13
17 [root@linux-node3 ~]# logout
18 Connection to 192.168.56.13 closed.

所有机器安装jdk,为了方便就安装自带的openjdk,生产环境要换成自己的jdk并设置环境变量哦

1 [root@linux-node1 ~]# yum install java-1.8.0-openjdk -y
2 [root@linux-node3 ~]# java -version
3 openjdk version "1.8.0_161"
4 OpenJDK Runtime Environment (build 1.8.0_161-b14)
5 OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

选择一台主机作为server端并安装,这里我萌用192.168.56.11,上吧!皮卡丘!

 1 [root@linux-node1 yum.repos.d]# cd /etc/yum.repos.d/
 2 [root@linux-node1 yum.repos.d]# vim ambari.repo
 3 [root@linux-node1 yum.repos.d]# cat ambari.repo 
 4 [Updates-ambari-2.2.0.0]
 5 name=ambari-2.2.0.0 - Updates
 6 baseurl=http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.0.0
 7 gpgcheck=0
 8 enabled=1
 9 [root@linux-node1 yum.repos.d]# yum install -y ambari-server                # 安装时间稍长请耐心等待,这个包有400M,姆Q
10 [root@linux-node1 ~]# ambari-server setup                                    # 开始安装
11 Using python  /usr/bin/python2
12 Setup ambari-server
13 Checking SELinux...                                                            # 检测SELinux状态
14 SELinux status is 'disabled'
15 Customize user account for ambari-server daemon [y/n] (n)?                     # 是否自定义用户,不需要
16 Adjusting ambari-server permissions and ownership...
17 Checking firewall status...
18 Redirecting to /bin/systemctl status  iptables.service
19 
20 Checking JDK...
21 [1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
22 [2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
23 [3] Custom JDK
24 ==============================================================================
25 Enter choice (1): 3                                                            # 选择jdk版本,这里我们选3使用自己的jdk,不然他回去下载jdk很慢
26 WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
27 WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
28 Path to JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/            # 我们选择的jdk位置,openjdk在/usr/lib/jvm/下,你要找你的版本然后这么填写就可以了
29 Validating JDK on Ambari Server...done.
30 Completing setup...
31 Configuring database...
32 Enter advanced database configuration [y/n] (n)?                             # 是否打开高级的数据库配置
33 Configuring database...
34 Default properties detected. Using built-in database.
35 Configuring ambari database...
36 Checking PostgreSQL...
37 Running initdb: This may take upto a minute.
38 Initializing database ... OK
39 
40 
41 About to start PostgreSQL
42 Configuring local database...
43 Connecting to local database...done.
44 Configuring PostgreSQL...
45 Restarting PostgreSQL
46 Extracting system views...
47 ambari-admin-2.2.0.0.1310.jar
48 ......
49 Adjusting ambari-server permissions and ownership...
50 Ambari Server 'setup' completed successfully.

所以其实我们有在jdk的选择那里需要配置下,剩下的都使用默认就可以了,现在我们可以启动他了

 1 所以其实我们有在jdk的选择那里需要配置下,剩下的都使用默认就可以了,现在我们可以启动他了
 2 [root@linux-node1 ~]# ambari-server start
 3 Using python  /usr/bin/python2
 4 Starting ambari-server
 5 Ambari Server running with administrator privileges.
 6 Organizing resource files at /var/lib/ambari-server/resources...
 7 WARNING: setpgid(51389, 0) failed - [Errno 13] Permission denied
 8 Server PID at: /var/run/ambari-server/ambari-server.pid
 9 Server out at: /var/log/ambari-server/ambari-server.out
10 Server log at: /var/log/ambari-server/ambari-server.log
11 Waiting for server start....................
12 Ambari Server 'start' completed successfully.
13 [root@linux-node1 ~]# ss -tln
14 State      Recv-Q Send-Q                    Local Address:Port                                   Peer Address:Port              
15 LISTEN     0      128                                   *:111                                               *:*                  
16 LISTEN     0      128                                   *:22                                                *:*                  
17 LISTEN     0      128                                   *:5432                                              *:*                  
18 LISTEN     0      128                                   *:4505                                              *:*                  
19 LISTEN     0      128                                   *:4506                                              *:*                  
20 LISTEN     0      30                                    *:8000                                              *:*                  
21 LISTEN     0      128                                  :::111                                              :::*                  
22 LISTEN     0      50                                   :::8080                                             :::*             # 这里,如果没有请等待一会         
23 LISTEN     0      128                                  :::22                                               :::*                  
24 LISTEN     0      50                                   :::8440                                             :::*                  
25 LISTEN     0      128                                  :::5432                                             :::*                  
26 LISTEN     0      50                                   :::8441                                             :::*         

看到了8080端口,有经验的小伙伴已经感觉到了,又到了我们去页面上装X的时刻了!默认账号密码都是admin

给新集群起一个名字

默认使用最新版本的Stack

集群内受操作的主机列表,需要主机名并可以解析,还有你server端私钥,如果不是root用户也需要更改

它会在受控机器上安装agent包,之后我们也可以在这两个页面来增加删除集群机器

这时候已经没有问题了,但是可以看看他的警告信息,他说我得ntp没开,因为7的系统使用chronyd,还有他说我的服务器上有一些不应该安装的包是因为我的机器还测试了很多其他东西,如果是一个很干净的机器就不会有这个警告,但是不重要都可以忽略,因为我们只是测试

选择你要安装的组件,有很多,我选几个基本的

选择各个组件安装的所处机器,这个就是分的比较精细了,生产环境要好好规划哦

一个总结表

一些设置,这里要注意,有一些组件是需要你设置帐号密码的,这个你得给人家都填写了才能继续,当然,填写的帐号密码你得记下,别闹

再次验证下

开始安装,你可以看到安装进度

经过一个相当长的时间与无数次的失败后重试,因为要连国外的源,我萌终于成功了

任务结果汇总,有一个警告,没关系

然后就出现了总控制台,逼格满满

从这里可以回退到总页面上

 

然后可以对平台进行总设置,新加一些用户设定一些权限

三台机器出现对应服务的端口号

 1 [root@linux-node1 ~]# ss -tln
 2 State      Recv-Q Send-Q                                                                                          Local Address:Port                                                                                                         Peer Address:Port              
 3 LISTEN     0      128                                                                                                         *:111                                                                                                                     *:*                  
 4 LISTEN     0      128                                                                                             192.168.56.11:8020                                                                                                                    *:*                  
 5 LISTEN     0      128                                                                                             192.168.56.11:50070                                                                                                                   *:*                  
 6 LISTEN     0      128                                                                                                         *:22                                                                                                                      *:*                  
 7 LISTEN     0      128                                                                                                         *:5432                                                                                                                    *:*                  
 8 LISTEN     0      128                                                                                                         *:4505                                                                                                                    *:*                  
 9 LISTEN     0      50                                                                                                          *:50010                                                                                                                   *:*                  
10 LISTEN     0      128                                                                                                         *:4506                                                                                                                    *:*                  
11 LISTEN     0      128                                                                                                         *:50075                                                                                                                   *:*                  
12 LISTEN     0      1                                                                                                           *:8670                                                                                                                    *:*                  
13 LISTEN     0      30                                                                                                          *:8000                                                                                                                    *:*                  
14 LISTEN     0      128                                                                                                 127.0.0.1:34823                                                                                                                   *:*                  
15 LISTEN     0      128                                                                                                         *:8010                                                                                                                    *:*                  
16 LISTEN     0      128                                                                                                        :::45454                                                                                                                  :::*                  
17 LISTEN     0      128                                                                                                        :::111                                                                                                                    :::*                  
18 LISTEN     0      50                                                                                       ::ffff:192.168.56.11:3888                                                                                                                   :::*                  
19 LISTEN     0      50                                                                                                         :::8080                                                                                                                   :::*                  
20 LISTEN     0      128                                                                                      ::ffff:192.168.56.11:16020                                                                                                                  :::*                  
21 LISTEN     0      50                                                                                                         :::37046                                                                                                                  :::*                  
22 LISTEN     0      128                                                                                                        :::22                                                                                                                     :::*                  
23 LISTEN     0      50                                                                                                         :::8440                                                                                                                   :::*                  
24 LISTEN     0      128                                                                                                        :::5432                                                                                                                   :::*                  
25 LISTEN     0      50                                                                                                         :::8441                                                                                                                   :::*                  
26 LISTEN     0      50                                                                                                         :::13562                                                                                                                  :::*                  
27 LISTEN     0      128                                                                                                        :::16030                                                                                                                  :::*                  
28 LISTEN     0      128                                                                                      ::ffff:192.168.56.11:16000                                                                                                                  :::*                  
29 LISTEN     0      50                                                                                                         :::2181                                                                                                                   :::*                  
30 LISTEN     0      128                                                                                                        :::8040                                                                                                                   :::*                  
31 LISTEN     0      128                                                                                                        :::8042                                                                                                                   :::*                  
32 LISTEN     0      128                                                                                                        :::16010                                                                                                                  :::*                  
33 [root@linux-node2 ~]# ss -tln
34 State      Recv-Q Send-Q                                                                                          Local Address:Port                                                                                                         Peer Address:Port              
35 LISTEN     0      128                                                                                                         *:111                                                                                                                     *:*                  
36 LISTEN     0      128                                                                                                         *:19888                                                                                                                   *:*                  
37 LISTEN     0      128                                                                                                         *:10033                                                                                                                   *:*                  
38 LISTEN     0      128                                                                                                         *:22                                                                                                                      *:*                  
39 LISTEN     0      128                                                                                                 127.0.0.1:35642                                                                                                                   *:*                  
40 LISTEN     0      50                                                                                                          *:50010                                                                                                                   *:*                  
41 LISTEN     0      128                                                                                                         *:50075                                                                                                                   *:*                  
42 LISTEN     0      1                                                                                                           *:8670                                                                                                                    *:*                  
43 LISTEN     0      128                                                                                                         *:10020                                                                                                                   *:*                  
44 LISTEN     0      128                                                                                             192.168.56.12:50090                                                                                                                   *:*                  
45 LISTEN     0      128                                                                                                         *:8010                                                                                                                    *:*                  
46 LISTEN     0      128                                                                                                        :::8141                                                                                                                   :::*                  
47 LISTEN     0      128                                                                                                        :::45454                                                                                                                  :::*                  
48 LISTEN     0      128                                                                                                        :::111                                                                                                                    :::*                  
49 LISTEN     0      50                                                                                       ::ffff:192.168.56.12:3888                                                                                                                   :::*                  
50 LISTEN     0      128                                                                                                        :::8050                                                                                                                   :::*                  
51 LISTEN     0      128                                                                                      ::ffff:192.168.56.12:16020                                                                                                                  :::*                  
52 LISTEN     0      128                                                                                                        :::22                                                                                                                     :::*                  
53 LISTEN     0      128                                                                                                        :::8088                                                                                                                   :::*                  
54 LISTEN     0      128                                                                                                        :::10200                                                                                                                  :::*                  
55 LISTEN     0      128                                                                                                        :::8025                                                                                                                   :::*                  
56 LISTEN     0      50                                                                                                         :::13562                                                                                                                  :::*                  
57 LISTEN     0      128                                                                                                        :::8188                                                                                                                   :::*                  
58 LISTEN     0      50                                                                                                         :::35037                                                                                                                  :::*                  
59 LISTEN     0      128                                                                                                        :::16030                                                                                                                  :::*                  
60 LISTEN     0      128                                                                                                        :::8030                                                                                                                   :::*                  
61 LISTEN     0      50                                                                                                         :::2181                                                                                                                   :::*                  
62 LISTEN     0      128                                                                                                        :::8040                                                                                                                   :::*                  
63 LISTEN     0      128                                                                                                        :::8042                                                                                                                   :::*                  
64 [root@linux-node3 rpm]# ss -tln
65 State      Recv-Q Send-Q                                                                                          Local Address:Port                                                                                                         Peer Address:Port              
66 LISTEN     0      128                                                                                                         *:111                                                                                                                     *:*                  
67 LISTEN     0      128                                                                                                         *:22                                                                                                                      *:*                  
68 LISTEN     0      50                                                                                                          *:50010                                                                                                                   *:*                  
69 LISTEN     0      128                                                                                                         *:50075                                                                                                                   *:*                  
70 LISTEN     0      1                                                                                                           *:8670                                                                                                                    *:*                  
71 LISTEN     0      128                                                                                                 127.0.0.1:45185                                                                                                                   *:*                  
72 LISTEN     0      128                                                                                                         *:8010                                                                                                                    *:*                  
73 LISTEN     0      128                                                                                                        :::45454                                                                                                                  :::*                  
74 LISTEN     0      128                                                                                                        :::111                                                                                                                    :::*                  
75 LISTEN     0      50                                                                                       ::ffff:192.168.56.13:3888                                                                                                                   :::*                  
76 LISTEN     0      50                                                                                                         :::39568                                                                                                                  :::*                  
77 LISTEN     0      128                                                                                      ::ffff:192.168.56.13:16020                                                                                                                  :::*                  
78 LISTEN     0      128                                                                                                        :::22                                                                                                                     :::*                  
79 LISTEN     0      50                                                                                                         :::13562                                                                                                                  :::*                  
80 LISTEN     0      128                                                                                                        :::16030                                                                                                                  :::*                  
81 LISTEN     0      50                                                                                                         :::2181                                                                                                                   :::*                  
82 LISTEN     0      128                                                                                                        :::8040                                                                                                                   :::*                  
83 LISTEN     0      50                                                                                       ::ffff:192.168.56.13:2888                                                                                                                   :::*                  
84 LISTEN     0      128                                                                                                        :::8042                                                                                                                   :::*       

 最后还有一个小Bug,那就是如果你是直接yum没有ambari.repo文件在ssh的时候是验证通不过的哦,所以你需要在server端的/etc/yum.repos.d/下有一个ambari.repo

原文地址:https://www.cnblogs.com/bfmq/p/8342229.html