1.安装环境
注意:以下步骤均以root权限操作
1.1.1 虚拟机准备
克隆三台虚拟机(linux01、linux02、linux03),
修改虚拟机的网络配置
vi /etc/sysconfig/network-scripts/ifcfg-eth0
配置好对应主机的网络IP
vi /etc/udev/rules.d/70-persistent-net.rules
永久修改主机名
vi /etc/sysconfig/network
配置域名映射
vi /etc/hosts
关闭防火墙
service iptables stop
状态查看 -----status
1)linux01、linux02、linux03的主机对应内存分别是:10G、2G、2G
2)在linux01的/opt目录上创建apps和software目录
1.1.2 SSH免密登录
配置linux01对linux01、linux02、linux03三台主机的免密登陆。
(1)生成公钥和私钥:
[root@linux01 .ssh]$ ssh-keygen -t rsa
然后敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
(2)将公钥拷贝到要免密登录的目标机器上
[root@linux01 .ssh]$ ssh-copy-id linux01
[root@linux01 .ssh]$ ssh-copy-id linux02
[root@linux01 .ssh]$ ssh-copy-id linux03
1.1.3 关闭防火墙
先查看防火墙状态
service iptables status
永久关闭防火墙
chkconfig iptables off
1.1.4 安装JDK(三台)
1)在linux01的/opt目录下创建apps和software文件夹
[root@linux01 opt]# mkdir apps
[root@linux01 opt]# mkdir software
2)用SecureCRT将jdk-8u144-linux-x64.tar.gz导入到linux01的/opt/software目录下
3)在Linux系统下的opt目录中查看软件包是否导入成功
[root@linux01 software]$ ls
jdk-8u144-linux-x64.tar.gz
4)解压JDK到/opt/apps目录下
[root@linux01 software]$ tar -zxvf jdk-8u144-linux-x64.tar.gz -C /opt/apps/
5)配置JDK环境变量
(1)先获取JDK路径
[root@linux01 jdk1.8.0_144]$ pwd
/opt/apps/jdk1.8.0_144
(2)打开/etc/profile文件
[root@linux01 software]$ vi /etc/profile
在profile文件末尾添加JDK路径
#JAVA_HOME
export JAVA_HOME=/opt/apps/jdk1.8.0_144
export PATH=$PATH:$JAVA_HOME/bin
(3)保存后退出
:wq
(4)让修改后的文件生效
[root@linux01 jdk1.8.0_144]$ source /etc/profile
6)测试JDK是否安装成功
[root@linux01 jdk1.8.0_144]# java -version
java version "1.8.0_144"
7)将linux01中的JDK和环境变量分发到linux02、linux03两台主机
[root@linux01 opt]# xsync /opt/apps/
[root@linux01 opt]# xsync /etc/profile
分别在linux02、linux03上source一下
[root@linux02 ~]$ source /etc/profile
[root@linux03 ~]# source /etc/profile
1.1.5 时间同步
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum -y install ntp
[root@linux03 ~]# cd /usr/share/zoneinfo/Asia/
[root@linux03 Asia]# ntpdate pool.ntp.org
31 Mar 15:24:44 ntpdate[1474]: step time server 84.16.67.12 offset -28798.098623 sec
[root@linux03 Asia]# date
1.1.6 安装wget
yum install wget -y
1.1.7 关闭SELINUX
安全增强型Linux(Security-Enhanced Linux)简称SELinux,它是一个 Linux 内核模块,也是Linux的一个安全子系统。
SELinux的结构及配置非常复杂,所以为了避免出现各种错误,建议关闭,有如下两种关闭方法:
(1)临时关闭:
[root@linux01 ~]# setenforce 0
但是这种方式只对当次启动有效,重启机器后会失效,建议使用第二种方式。
(2)永久关闭
修改配置文件/etc/selinux/config
[root@linux01 ~]# vim /etc/selinux/config
vi /etc/selinux/config
将SELINUX=enforcing 改为SELINUX=disabled
SELINUX=disabled
(3)同步/etc/selinux/config配置文件
[root@linux01 ~]# xsync /etc/selinux/config
(4)重启linux01、linux02、linux03主机
[root@linux01 ~]# reboot
[root@linux02 ~]# reboot
[root@linux03 ~]# reboot
1.1.8 安装httpd服务 - 主服务器
[root@master ~]# yum -y install httpd
[root@master ~]# service httpd restart
Redirecting to /bin/systemctl restart httpd.service
[root@master ~]# chkconfig httpd on
Ambari存储库
http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.1.0
HDP 2.4储存库
http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.4.0.0
2.Ambari安装
2.1下载Ambari 的公共库文件(public repository)
wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.0.1/ambari.repo
2.2将下载的 ambari.repo 文件拷贝到 Linux 的系统目录/etc/yum.repos.d/
mv ambari.repo /etc/yum.repos.d/ambari.repo
2.3获取该公共库的所有的源文件列表
[root@hadoop1 hadoop]# cd /etc/yum.repos.d/
[root@hadoop1 yum.repos.d]# yum clean all
[root@hadoop1 ~]# yum list|grep ambari
ambari-server.noarch 2.0.1-45 @Updates-ambari-2.0.1
ambari-agent.x86_64 2.0.1-45 Updates-ambari-2.0.1
ambari-log4j.noarch 2.0.1.45-1 Updates-ambari-2.0.1
ambari-metrics-collector.x86_64 2.0.1-45 Updates-ambari-2.0.1
ambari-metrics-common.noarch 2.0.1-45 Updates-ambari-2.0.1
ambari-metrics-hadoop-sink.x86_64 2.0.1-45 Updates-ambari-2.0.1
ambari-metrics-monitor.x86_64 2.0.1-45 Updates-ambari-2.0.1
hdp_mon_ganglia_addons.noarch 2.0.1.45-1.el6 Updates-ambari-2.0.1
hdp_mon_nagios_addons.noarch 2.0.1.45-1.el6 Updates-ambari-2.0.1
2.4安装 Ambari Server
[root@hadoop1 ambari-server]# yum install ambari-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ambari-server.noarch 0:2.0.1-45 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================
Package Arch Version Repository Size
===========================================
Installing:
ambari-server noarch 2.0.1-45 Updates-ambari-2.0.1 86 M
Transaction Summary
===========================================
Install 1 Package(s)
Total download size: 86 M
Installed size: 104 M
Is this ok [y/N]: y
Downloading Packages:
ambari-server-2.0.1-45.noarch.rpm | 86 MB 18:34
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ambari-server-2.0.1-45.noarch 1/1
Verifying : ambari-server-2.0.1-45.noarch 1/1
Installed:
ambari-server.noarch 0:2.0.1-45
Complete!
[root@hadoop1 ambari-server]#
2.5配置 Ambari Server
[root@hadoop1 ambari-server]# ambari-server setup
Using python /usr/bin/python2.6
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):root
Adjusting ambari-server permissions and ownership...
Checking iptables...
Checking JDK...
[1] Oracle JDK 1.7
[2] Oracle JDK 1.6
[3] - Custom JDK
=========================
Enter choice (1): 1
To download the Oracle JDK and the Java Cryptography Extension (JCE) Policy Files you must accept the license terms found at http://www.oracle.com/technetwork/java/javase/terms/license/index.html and not accepting will cancel the Ambari Server setup and you must install the JDK and JCE files manually.
Do you accept the Oracle Binary Code License Agreement [y/n] (y)? y
Downloading JDK from http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-7u67-linux-x64.tar.gz to /var/lib/ambari-server/resources/jdk-7u67-linux-x64.tar.gz
jdk-7u67-linux-x64.tar.gz... 100% (135.8 MB of 135.8 MB)
Successfully downloaded JDK distribution to /var/lib/ambari-server/resources/jdk-7u67-linux-x64.tar.gz
Installing JDK to /usr/jdk64/
Successfully installed JDK to /usr/jdk64/
Downloading JCE Policy archive from http://public-repo-1.hortonworks.com/ARTIFACTS/UnlimitedJCEPolicyJDK7.zip to /var/lib/ambari-server/resources/UnlimitedJCEPolicyJDK7.zip
UnlimitedJCEPolicyJDK7.zip... 100%
Successfully downloaded JCE Policy archive to /var/lib/ambari-server/resources/UnlimitedJCEPolicyJDK7.zip
Installing JCE policy...
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? y
Configuring database...
=========================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL
[4] - PostgreSQL
=========================
Enter choice (1):
Database name (ambari):
Postgres schema (ambari):
Username (ambari):
Enter Database Password (bigdata):
Re-enter password:
Default properties detected. Using built-in database.
Configuring ambari database...
Checking PostgreSQL...
Running initdb: This may take upto a minute.
Initializing database: [ OK ]
About to start PostgreSQL
Configuring local database...
Connecting to local database...done.
Configuring PostgreSQL...
Restarting PostgreSQL
Extracting system views...
.ambari-admin-2.0.1.45.jar
..
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
[root@hadoop1 ambari-server]#
2.6 启动 Ambari
[root@hadoop1 ambari-server]# ambari-server start
Using python /usr/bin/python2.6
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start....................
Ambari Server 'start' completed successfully.
[root@hadoop1 ambari-server]#
2.7登录 Ambari server管理页面
登录URL:http://ip:8080/,
登录账号密码:admin/admin