Ambari-server 10.10.10.10 内网
hadoop-master1 10.10.10.1 内网hadoop-master2 10.10.10.2 内网
hadoop-slave1 10.10.10.3 内网
hadoop-slave2 10.10.10.4 内网
hadoop-slave3 10.10.10.5 内网

准备工作
(1)修改主机名Ambari-server、master1、master2、slave1、slave2、slave3
$ hostname XXX && echo XXX >/etc/hostname $ cat >> /etc/hosts << EOF 10.10.10.1 master1 10.10.10.2 master2 10.10.10.3 slave1 10.10.10.4 slave2 10.10.10.5 slave3 10.10.10.10 ambari-server 10.10.10.20 ambari-yumrepo EOF (2)关闭selinux和防火墙Ambari-server、master1、master2、slave1、slave2、slave3
$ setenforce 0 $ service iptables stop $ chkconfig iptables off (3)主从节点ssh互信slave1、slave2、slave3
$ echo sshd:10.64.8.1 10.64.8.2 >>/etc/hosts.allowmaster1、master2
$ ssh-keygen -t rsa $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave1 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave2 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave3 (4)安装jdkAmbari-server、master1、master2、slave1、slave2、slave3
$ wget http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.rpm $ rpm -ivh jdk-8u111-linux-x64.rpm (5)格式化硬盘Ambari-server、master1、master2、slave1、slave2、slave3
$ yes|mkfs.ext4 /dev/sdb $ mkdir /data $ mount /dev/sdb /data $ echo "mount /dev/sdb /data" >>/etc/rc.local(6) 系统参数调优
Ambari-server、master1、master2、slave1、slave2、slave3
$ cat >>/etc/sysctl.conf <<EOF net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_baklog = 8192 net.ipv4.tcp_max_tw_bukets = 5000 EOF 文件打开数 $ cat >> /etc/security/limits.conf <<EOF * soft nofile 65535* hard nofile 65535 EOF 重启二:搭建内网yum源
注意:因为考虑到hadoop集群的机器可能是内网机器,没有公网访问权限,那么选择搭建一个内网的yum源,这个yum源的机器需要有公网权限。如果你的机器都可以出公网,也可以跳过这一步。
(1)添加yum源Ambari-yumrepo
$ cd /opt $ wget http://public-repo-1.hortonworks.com/ambari/centos6/1.x/updates/1.4.1.25/ambari.repo $ cp ambari.repo /etc/yum.repos.d/
(2)同步yum源的包
Ambari-yumrepo
$ reposync -r HDP-UTILS-1.1.0.16 $ reposync -r Updates-ambari-1.4.1.25 $ reposync -r ambari-1.x会在当前目录生成三个目录。
(3)发布yum源
Ambari-yumrepo
需要一个web服务器来发布,已经安装了nginx,将上面下载包的三个目录移动到nginx发布目录下。
$ yum install nginx $ mkdir /usr/share/nginx/html/ambari $ cp -R ambari-1.x /usr/share/nginx/html/ambari/ $ cp -R HDP-UTILS-1.1.0.16 /usr/share/nginx/html/ambari/ $ cp -R Updates-ambari-1.4.1.25 /usr/share/nginx/html/ambari/
(4)创建repo
Ambari-yumrepo
安装createrepo命令
$ yum install createrepo $ cd /usr/share/nginx/html/ambari/ $ createrepo ./
(5)添加HDP源
Ambari-yumrepo
$ vim /etc/yum.repos.d/HDP.repo [HDP-2.0.6] name=HDP baseurl=http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0 enabled=1 gpgcheck=0
$ mkdir /usr/share/nginx/html/hdp $ cd /usr/share/nginx/html/hdp 同步网络源的包,1G左右。 $ reposync -r HDP-2.0.6 $ createrepo ./

这样就本地yum源就OK了!
(6)配置yum.repo配置文件,放在web目录下。
Ambari-yumrepo
注意:这个ambari.repo配置是给其他机器来使用的,不是本机的配置。
$ mkdir /usr/share/nginx/html/hadoop $ cd /usr/share/nginx/html/hadoop $ vim ambari.repo [ambari-1.x] name=Ambari 1.x baseurl=http://10.10.10.20/ambari/ gpgcheck=0 enabled=1 [HDP-UTILS-1.1.0.16] name=Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.16 baseurl=http://10.10.10.20/ambari/ gpgcheck=0 enabled=1 [Updates-ambari-1.4.1.25] name=ambari-1.4.1.25 - Updates baseurl=http://10.64.10.20/ambari/ gpgcheck= enabled=1 $ vim hdp.repo [HDP-2.0.6] name=HDP baseurl=http://10.10.10.20/hdp path=/ enabled=1 gpgcheck=0三:安装Ambari
(1)添加yum源Ambari-server、master1、master2、slave1、slave2、slave3
$ cd /etc/yum.repos.d/ $ wget http://10.10.10.20/hadoop/ambari.repo #上面搭建的内网yum源 $ wget http://10.10.10.20/hadoop/hdp.repo #上面搭建的内网yum源 (2)ambari主机ssh信任hadoop各机器master1、master2、slave1、slave2、slave3
$ echo sshd:10.10.10.10 >>/etc/hosts.allowAmbari-server
$ ssh-keygen -t rsa $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@master1 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@master2 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave1 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave2 $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@slave3 (3)安装ambari Ambari-server $ yum -y install ambari-server
(4)初始化ambari
Ambari-server
下载需要的jdk文件(必须用这个文件)
$ wget http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-6u31-linux-x64.bin $ mv jdk-6u31-linux-x64.bin /var/lib/ambari-server/resources/ $ ambari-server setup #初始化配置
(5)启动ambari
Ambari-server
$ ambari-server start
(6)给ambari配置本地的hadoop源
Ambari-server
$ cd /var/lib/ambari-server/resources/stacks/HDPLocal/2.0.6/repos/ $ vim repoinfo.xml 将centos6的 <baseurl>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0</baseurl> 替换成 <baseurl>http://10.10.10.20/hdp/centos6/2.x/updates/2.0.6.0</baseurl> (7)进入ambari访问:http://10.10.10.10:8080进入ambari,user:admin,passwd:admin

输入集群名
