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 [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]

[root@ambari-server3 .ssh]# ssh-copy-id [email protected]
[email protected]'s password: 
Now try logging into the machine, with "ssh '[email protected]'", 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 [email protected]
[email protected]'s password: 
Now try logging into the machine, with "ssh '[email protected]'", 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 [email protected]
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.
[email protected]'s password: 
Now try logging into the machine, with "ssh '[email protected]'", 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
分別改兩個環境變量:















發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章