centos6.5 && ambari2.4.1.0安装Demo:

centos6.5 && ambari2.4.1.0安装Demo:
我的机器是本地搭的虚拟机(3台),由于电脑配置限制(8g),只能分给直节点2g,两从节点各1.5g;

原文链接:http://blog.csdn.net/haoxiaoyan/article/details/72723270

本文综合借鉴了其他播客,整理出适合自己的这套ambari环境体系:
1.先下载本地源(压缩包)
Ambari-2.4.1.0 压缩包地址:
http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.4.1.0/ambari-2.4.1.0-centos7.tar.gz
http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.4.1.0/ambari-2.4.1.0-centos6.tar.gz
 
HDP-2.5.0.0压缩包地址:
http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.5.0.0/HDP-2.5.0.0-centos7-rpm.tar.gz
http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.5.0.0/HDP-2.5.0.0-centos6-rpm.tar.gz


HDP UTILS压缩包下载地址:
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos6/HDP-UTILS-1.1.0.21-centos6.tar.gz


其他版本,下载地址请参考:
Ambari:
http://docs.hortonworks.com/HDPDocuments/Ambari-2.4.1.0/bk_ambari-installation/content/ambari_repositories.html
HDP和HDP UTILS:
http://docs.hortonworks.com/HDPDocuments/Ambari-2.4.1.0/bk_ambari-installation/content/hdp_stack_repositories.html


2.改ip这块结合这个播客看,有详细介绍,我只不过是总结了下:http://blog.csdn.net/wanz2/article/details/52820876
配置静态IP:
静态IP地址配置主要用到以下三个文件: 
/etc/sysconfig/network-scripts/ifcfg-eth0 
/etc/sysconfig/network 
/etc/resolv.conf 

1).[root@ambari-server3 ~]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ambari-server3
NTPSERVERARGS=iburst
GATEWAY=192.168.182.2

2).[root@ambari-server3 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
UUID=55d620df-ca54-4907-bac5-f8f6fb6bb2f1
ONBOOT=yes
NM_CONTROLLED=yes
HWADDR=00:0C:29:DD:52:B6
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
LAST_CONNECT=1515859956
#这几个除了dhcp改为static外,下面几个都是加上去的,这个因人而异
BOOTPROTO=static
IPADDR=192.168.182.132
NETMASK=255.255.255.0
GATEWAY=192.168.182.2
DNS1=192.168.182.2
DNS2=8.8.8.8

3).上一步配置完成后,系统会在/etc/resolv.conf文件中自动写入DNS服务器地址
[root@ambari-server3 ~]# more /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.182.2
nameserver 8.8.8.8


重启网络服务:
[root@ambari-server3 ~]# service network restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
                                                           [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0: 活跃连接状态:激活的
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/4 [确定]


打开ssh服务:
[root@ambari-server3 ~]# service sshd status
openssh-daemon (pid  1685) 正在运行...
[root@ambari-server3 ~]# service sshd start
[root@ambari-server3 ~]# chkconfig sshd on   #设置开机运行ssh
[root@ambari-server3 ~]# chkconfig --list sshd
sshd            0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

这台节点就算完事了,有几台节点,就对应的改几次、

3.各三台机器做免密钥:
我这里ambari-server3是主节点:
1).先配置三台机器的hosts文件:三台都要做,一样的;
[root@ambari-server3 .ssh]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.182.130 ambari-server1
192.168.182.131 ambari-server2
192.168.182.132 ambari-server3
[root@ambari-server1 .ssh]# vim /etc/hosts
[root@ambari-server2 .ssh]# vim /etc/hosts

2).需求:准备安装ambari-server3(192.168.182.132)机器,需要到所有的机器都免密,包括本机。
在准备安装ambari-server3(192.168.182.132)的机器上生成秘钥
[root@ambari-server3 source]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
33:21:02:fd:00:3a:d8:61:97:25:55:83:64:19:bb:52 root@ambari-server3
The key's randomart image is:
+--[ RSA 2048]----+
|  =oo=*=o        |
|.+ ++oo. .       |
|+ . .oE .        |
| .   o.o .       |
|    . . S        |
|     .   o       |
|                 |
|                 |
|                 |
+-----------------+
3).配置ambari-server3(192.168.182.132)机器到所有机器的免密
包括自己本身
ssh-copy-id root@192.168.182.130
ssh-copy-id root@192.168.182.131
ssh-copy-id root@192.168.182.132

[root@ambari-server3 .ssh]# ssh-copy-id root@192.168.182.130
root@192.168.182.130's password: 
Now try logging into the machine, with "ssh 'root@192.168.182.130'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.

出现这个不影响免密登陆,刚测试了

[root@ambari-server3 .ssh]# ssh 192.168.182.130
Last login: Sun Jan 14 11:49:22 2018 from ambari-server3
[root@ambari-server1 ~]# hostname
ambari-server1
[root@ambari-server1 ~]# exit
logout
Connection to 192.168.182.130 closed.
[root@ambari-server3 .ssh]# hostname
ambari-server3
[root@ambari-server3 .ssh]# ssh-copy-id root@192.168.182.131
root@192.168.182.131's password: 
Now try logging into the machine, with "ssh 'root@192.168.182.131'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.


[root@ambari-server3 .ssh]# ssh-copy-id root@192.168.182.132
The authenticity of host '192.168.182.132 (192.168.182.132)' can't be established.
RSA key fingerprint is ad:4f:3d:d2:02:6d:6f:5b:44:97:b7:a1:1c:e3:5e:ff.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.182.132' (RSA) to the list of known hosts.
root@192.168.182.132's password: 
Now try logging into the machine, with "ssh 'root@192.168.182.132'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.

[root@ambari-server3 .ssh]# ssh 192.168.182.131
Last login: Sun Jan 14 11:51:14 2018 from ambari-server3
[root@ambari-server2 ~]# exit
logout
Connection to 192.168.182.131 closed.
[root@ambari-server3 .ssh]# ssh 192.168.182.132
Last login: Sun Jan 14 10:22:37 2018 from 192.168.182.1
[root@ambari-server3 ~]# exit
logout
Connection to 192.168.182.132 closed.
到这里主节点到各台子节点的面密就做完了

4.装ambari必须要的组件:jdk、mysql
1).jdk好装,就不做详细介绍了;
[root@ambari-server3 source]#  rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@ambari-server3 source]# clear
[root@ambari-server3 source]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@ambari-server3 source]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

[root@ambari-server3 source]# tar -zxvf jdk-8u73-linux-x64.gz -C /usr/java/
[root@ambari-server3 source]# vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_73
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@ambari-server3 source]# source /etc/profile
[root@ambari-server3 source]# java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
[root@ambari-server3 source]# java
用法: java [-options] class [args...]
...

2).着重讲下mysql的安装:
ambari安装后面会用到mysql作为原数据库,这块出问题是最多啊,myql搞错了,后面还不好卸载,所以在装mysql时候一定要小心;
自己玩测试机,密码啥的最好设置一个一样的,简单好记的:
[root@ambari-server3 java]# rpm -qa | grep mysql*
mysql-libs-5.1.71-1.el6.x86_64
[root@ambari-server3 java]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

命令安装mysql:
[root@ambari-server3 java]# yum install mysql mysql-server mysql-devel -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
....
Complete!
[root@ambari-server3 java]# chkconfig --list | grep mysql
mysqld          0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@ambari-server3 java]# service myqld status
myqld: 未被识别的服务
#注意上面这个报错:

[root@ambari-server3 java]# service mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h ambari-server3 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
                                                           [确定]
正在启动 mysqld:                                          [确定]
[root@ambari-server3 java]# 
现在就可以测试这几个命令了:
[root@ambari-server3 java]# chkconfig --list mysql
在 mysql 服务中读取信息时出错:没有那个文件或目录
[root@ambari-server3 java]# chkconfig --list mysqld
mysqld          0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@ambari-server3 java]# chkconfig --list | grep mysqld
mysqld          0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@ambari-server3 java]# chkconfig --list | grep mysql
mysqld          0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

设置mysqld随机启动
[root@ambari-server3 java]# chkconfig mysqld on
[root@ambari-server3 java]# chkconfig --list | grep mysqld
mysqld          0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
--------------------------------
[root@ambari-server3 java]# ps -ef | grep mysql
root      27394      1  0 12:40 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql     27496  27394  0 12:40 pts/1    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      27533  27081  0 12:45 pts/1    00:00:00 grep mysql
根据进程信息可以看到,mysql的数据库data目录是 /var/lib/mysql ,错误日志文件是  /var/log/mysqld.log
---------------------------------

跟据上面启动msyld服务时提供的设置管理员密码方法:
[root@ambari-server3 java]# /usr/bin/mysqladmin -u root password '123456'
[root@ambari-server3 java]# mysql #因为上面一步,我已经设置密码了;
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@ambari-server3 java]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
mysql> select Host,User,Password,Grant_priv from user;
+----------------+------+-------------------------------------------+------------+
| Host           | User | Password                                  | Grant_priv |
+----------------+------+-------------------------------------------+------------+
| localhost      | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| ambari-server3 | root |                                           | Y          |
| 127.0.0.1      | root |                                           | Y          |
| localhost      |      |                                           | N          |
| ambari-server3 |      |                                           | N          |
+----------------+------+-------------------------------------------+------------+
5 rows in set (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'ambari-server3' identified by '123456' with grant option;
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
mysql> flush privileges;
#这个% 是啥意思?----所有的主机

mysql>  select Host,User,Password,Grant_priv from user;
+----------------+------+-------------------------------------------+------------+
| Host           | User | Password                                  | Grant_priv |
+----------------+------+-------------------------------------------+------------+
| localhost      | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| ambari-server3 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| 127.0.0.1      | root |                                           | Y          |
| localhost      |      |                                           | N          |
| ambari-server3 |      |                                           | N          |
| %              | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
+----------------+------+-------------------------------------------+------------+
6 rows in set (0.00 sec)

这里还忘了一个步骤,就是关闭三台机器的 防火墙,设则会selinx=disabled
三台都要做
[root@ambari-server3 java]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

[root@ambari-server3 java]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
[root@ambari-server3 java]# ckconfig iptables off
-bash: ckconfig: command not found
[root@ambari-server3 java]# chkconfig iptables off
[root@ambari-server3 java]# vim /etc/selinux
[root@ambari-server3 java]# vim /etc/selinux/config 
[root@ambari-server3 java]# getenforce
Enforcing
重启在测试:
[root@ambari-server3 java]# reboot
[root@ambari-server3 ~]# getenforce
Disabled
[root@ambari-server3 ~]# chkconfig --list iptables
iptables        0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

下面开始搞ambari的安装了:
1).安装配置本地源需要的组件
yum install httpd
yum install yum-utils
yum repolist
yum install createrepo 

[root@ambari-server3 ~]# yum install httpd -y
[root@ambari-server3 ~]# yum install yum-utils -y
[root@ambari-server3 ~]# yum repolist
已加载插件:fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
仓库标识                                                           仓库名称                                                                     状态
base                                                               CentOS-6 - Base                                                              6,706
extras                                                             CentOS-6 - Extras                                                               47
updates                                                            CentOS-6 - Updates    
[root@ambari-server3 ~]# yum install createrepo -y

2).直接使用命令:yum install httpd;安装完成后,会生成 /var/www/html 目录
在/var/www/html目录下,分别建立ambari和hdp目录:
[root@ambari-server3 html]# mkdir /var/www/html/ambari
[root@ambari-server3 html]#  mkdir /var/www/html/hdp
[root@ambari-server3 source]#  tar -xf ambari-2.4.1.0-centos6.tar.gz -C /var/www/html/ambari/
[root@ambari-server3 source]#  tar -xf HDP-2.5.0.0-centos6-rpm.tar.gz -C /var/www/html/hdp/

启动httpd服务:
[root@ambari-server3 yum.repos.d]# server httpd status
-bash: server: command not found
[root@ambari-server3 yum.repos.d]# service httpd status
httpd 已停
[root@ambari-server3 yum.repos.d]# service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.182.132 for ServerName   [确定]
设置httpd服务开机自动启动:
[root@ambari-server3 yum.repos.d]# chkconfig httpd on

下载并修改ambrii.repo文件
[root@ambari-server3 yum.repos.d]# wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.4.1.0/ambari.repo -O/etc/yum.repos.d/ambari.repo
------------------------------------
[root@ambari-server3 yum.repos.d]# vim ambari.repo 
#VERSION_NUMBER=2.4.1.0-22
#[Updates-ambari-2.4.1.0]
#name=ambari-2.4.1.0 - Updates
#baseurl=http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.4.1.0
#gpgcheck=1
#gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
#enabled=1
#priority=1

[Updates-ambari-2.4.1.0]
name=ambari-2.4.1.0 - Updates
baseurl=http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/
gpgcheck=1
gpgkey=http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/2.4.1.0-22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

[HDP-2.5.0.0]
name=HDP Version - HDP-2.5.0.0
baseurl=http://192.168.182.132/hdp/HDP/centos6/
gpgcheck=1
gpgkey=http://192.168.182.132/hdp/HDP/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

[HDP-UTILS-1.1.0.21]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.21
baseurl=http://192.168.182.132/hdp/HDP-UTILS-1.1.0.21/
gpgcheck=1
gpgkey=http://192.168.182.132/hdp/HDP-UTILS-1.1.0.21/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
------------------------------------

生成本地源
使用createrepo命令,生成本地源
[root@ambari-server3 hdp]# mkdir -p /var/www/html/hdp/HDP-UTILS-1.1.0.21/
[root@namenode1 ~]# mkdir -p/var/www/html/hdp/HDP/centos6/
#目录有的话就不用创建了:
[root@ambari-server3 centos6]# createrepo /var/www/html/hdp/HDP/centos6/
[root@ambari-server3 centos6]# createrepo /var/www/html/hdp/HDP-UTILS-1.1.0.21/

关闭THP
在集群的每个节点,都要关闭。编辑/etc/grub.conf文件,在kernel 行后面加入
transparent_hugepage=never,保存退出,重启机器。

[root@ambari-server1 ~]# vim /etc/grub.conf
[root@ambari-server2 ~]# vim /etc/grub.conf
[root@ambari-server3 ~]# vim /etc/grub.conf

一个时间同步必须要做,:
主节点:
[root@ambari-server3 etc]#  cp ntp.conf ntp.conf_bak_20180114
[root@ambari-server3 etc]# vim ntp.conf
[root@ambari-server3 etc]# service ntpd status
ntpd 已停
[root@ambari-server3 etc]# service ntpd start
正在启动 ntpd:                                            [确定]
[root@ambari-server3 etc]# chkconfig --list ntpd
ntpd            0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
添加到自启动:
[root@ambari-server3 etc]# chkconfig --level 35 ntpd on
[root@ambari-server3 etc]# chkconfig --list ntpd
ntpd            0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关闭

客户端设置:
每台机器一定要做好备份工作:
[root@ambari-server1 etc]#  cp ntp.conf ntp.conf_bak_20180114
[root@ambari-server2 etc]# service ntpd start
Starting ntpd:                                             [  OK  ]
[root@ambari-server1 etc]# service ntpd start
Starting ntpd:                                             [  OK  ]

在从节点间同步时间
[root@ambari-server2 etc]# ntpdate 192.168.182.132
14 Jan 14:20:11 ntpdate[2050]: the NTP socket is in use, exiting
[root@ambari-server2 etc]# service ntpd stop
Shutting down ntpd:                                        [  OK  ]
[root@ambari-server2 etc]# 
[root@ambari-server2 etc]# 
[root@ambari-server2 etc]# ntpdate 192.168.182.132
14 Jan 14:21:10 ntpdate[2063]: adjust time server 192.168.182.132 offset -0.081440 sec
[root@ambari-server2 etc]# service ntpd start
Starting ntpd:                                             [  OK  ]
[root@ambari-server1 etc]# service ntpd stop
Shutting down ntpd:                                        [  OK  ]
[root@ambari-server1 etc]# ntpdate 192.168.182.132
14 Jan 14:21:31 ntpdate[2062]: adjust time server 192.168.182.132 offset -0.059192 sec
[root@ambari-server1 etc]# service ntpd start
Starting ntpd:                                             [  OK  ]

[root@ambari-server2 etc]# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
[root@ambari-server2 etc]# chkconfig --level 35 crond on

[root@ambari-server1 etc]# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
[root@ambari-server1 etc]# chkconfig --level 35 crond on

[root@ambari-server3 etc]# clear
[root@ambari-server3 etc]# service crond status
crond (pid  1856) 正在运行...
[root@ambari-server3 etc]# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
[root@ambari-server3 etc]# chkconfig --level 35 crond on

MYSQL库下建库操作:
mysql>create database ambari DEFAULT CHARSET utf8;

GRANT ALL PRIVILEGES ON ambari.* TO root@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ambari.* TO root@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
mysql>  select Host,User,Password,Grant_priv from user;
+----------------+------+-------------------------------------------+------------+
| Host           | User | Password                                  | Grant_priv |
+----------------+------+-------------------------------------------+------------+
| localhost      | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| ambari-server3 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| 127.0.0.1      | root |                                           | Y          |
| localhost      |      |                                           | N          |
| ambari-server3 |      |                                           | N          |
| %              | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
+----------------+------+-------------------------------------------+------------+
6 rows in set (0.00 sec)

安装ambari-server
报错:
[root@ambari-server3 repodata]# yum install ambari-server -y
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.shu.edu.cn
 * updates: mirrors.shu.edu.cn
http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
尝试其他镜像。
To address this issue please refer to the below knowledge base article 
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
错误:Cannot retrieve repository metadata (repomd.xml) for repository: Updates-ambari-2.4.1.0. Please verify its path and try again

应该最先想到的是去检查ambari.repo文件
[Updates-ambari-2.4.1.0]
name=ambari-2.4.1.0 - Updates
baseurl=http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/
gpgcheck=1
gpgkey=http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/2.4.1.0-22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

在baseurl后面加上下一级子目录:
baseurl=http://192.168.182.132/ambari/AMBARI-2.4.1.0/centos6/2.4.1.0-22/

再次启动安装程序:一切正常:
[root@ambari-server3 repodata]# yum install ambari-server -y
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
...
完毕!

拷贝jdbc驱动:
[root@ambari-server3 source]# mv mysql-connector-java-5.1.32-bin.jar  /usr/share/java/
[root@ambari-server3 source]# cd /usr/share/java/
[root@ambari-server3 java]# ln -s  mysql-connector-java-5.1.32-bin.jar mysql-connector-java.jar

配置ambari server:
[root@ambari-server3 java]# ambari-server setup
Using python  /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'
Customize user account for ambari-server daemon [y/n] (n)? y
Enter user account for ambari-server daemon (root):
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
============================================================================
Enter choice (1): 3
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
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.
Path to JAVA_HOME: /usr/java/jdk1.8.0_73
Validating JDK on Ambari Server...done.
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? Y
Configuring database...
============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
============================================================================
Enter choice (1): 3
Hostname (localhost): ambari-server3
Port (3306): 
Database name (ambari): 
Username (ambari): root
Enter Database Password (bigdata): 
Re-enter password: 
Configuring ambari database...
Copying JDBC drivers to server resources...
Configuring remote database connection properties...
WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Proceed with configuring remote database connection properties [y/n] (y)? y
Extracting system views...
........ambari-admin-2.4.1.0.22.jar
...
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

可以监控日志查看状态:
[root@ambari-server3 ambari-server]# tail -f /var/log/ambari-server/ambari-server.log 
[root@ambari-server3 ambari-server]# tail -f /var/log/ambari-server/ambari-server-check-database.log

在mysql中导入ambari的数据库:
mysql>use ambari
mysql>source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

176环境的:
mysql> select * from users;
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+---------------------------------------------------------------------------------------------------+
| user_id | principal_id | create_time         | ldap_user | user_type | user_name | user_password                                                                    | active | active_widget_layouts                                                                             |
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+---------------------------------------------------------------------------------------------------+
|       1 |            1 | 2017-06-13 09:05:03 |         0 | LOCAL     | admin     | 538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00 |      1 | [{"id":"8"},{"id":"9"},{"id":"10"},{"id":"11"},{"id":"12"},{"id":"51"},{"id":"101"},{"id":"152"}] |
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+---------------------------------------------------------------------------------------------------+
本机环境:
mysql> select  * from users;
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+-----------------------+
| user_id | principal_id | create_time         | ldap_user | user_type | user_name | user_password                                                                    | active | active_widget_layouts |
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+-----------------------+
|       1 |            1 | 2018-01-14 15:14:28 |         0 | LOCAL     | admin     | 538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00 |      1 | NULL                  |
+---------+--------------+---------------------+-----------+-----------+-----------+----------------------------------------------------------------------------------+--------+-----------------------+
1 row in set (0.00 sec)

启动Amabri:
这样如果直接启动服务的话,会报错的,上面有禁告:
WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Query OK, 0 rows affected (0.33 sec)
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
ERROR 1146 (42S02): Table 'ambari.users' doesn't exist

改库名:
GRANT ALL PRIVILEGES ON ambari.* TO ambari@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ambari.* TO ambari@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ambari.* TO ambari@'ambari-server3' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;

[root@ambari-server3 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 132
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select Host,User,Password,Grant_priv from user;
+----------------+--------+-------------------------------------------+------------+
| Host           | User   | Password                                  | Grant_priv |
+----------------+--------+-------------------------------------------+------------+
| localhost      | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| ambari-server3 | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| 127.0.0.1      | root   |                                           | Y          |
| localhost      |        |                                           | N          |
| ambari-server3 |        |                                           | N          |
| %              | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| %              | ambari | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          |
| localhost      | ambari | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          |
+----------------+--------+-------------------------------------------+------------+
8 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON ambari.* TO ambari@'ambari-server3' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select Host,User,Password,Grant_priv from user;
+----------------+--------+-------------------------------------------+------------+
| Host           | User   | Password                                  | Grant_priv |
+----------------+--------+-------------------------------------------+------------+
| localhost      | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| ambari-server3 | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| 127.0.0.1      | root   |                                           | Y          |
| localhost      |        |                                           | N          |
| ambari-server3 |        |                                           | N          |
| %              | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | Y          |
| %              | ambari | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          |
| localhost      | ambari | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          |
| ambari-server3 | ambari | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | N          |
+----------------+--------+-------------------------------------------+------------+
9 rows in set (0.00 sec)

[root@ambari-server3 ~]# mysql -uambari -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use ambari;
Database changed
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;

这一步是出错最多的地方:
[root@ambari-server3 java]# ambari-server start
Using python  /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
No errors were found.
Ambari database consistency check finished
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.

主页块结束是报错:因为从节点都要装jdk、
stderr:   /var/lib/ambari-agent/data/errors-11.txt
Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py", line 35, in <module>
    BeforeAnyHook().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 280, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py", line 32, in hook
    setup_java()
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py", line 181, in setup_java
    raise Fail(format("Unable to access {java_exec}. Confirm you have copied jdk to this host."))
resource_management.core.exceptions.Fail: Unable to access /usr/java/jdk1.8.0_73/bin/java. Confirm you have copied jdk to this host.
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py',

改错:
[root@ambari-server1 ~]#  mkdir -p /usr/java
[root@ambari-server2 ~]#  mkdir -p /usr/java
[root@ambari-server3 java]# scp -r jdk1.8.0_73/ root@ambari-server1:/usr/java
[root@ambari-server3 java]# scp -r jdk1.8.0_73/ root@ambari-server2:/usr/java
分别改两个环境变量:















  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值