Ambari 2.4.2安装

一、前期准备工作

机器规划

  • 安装操作系统centos7
  • ambari001 装AmbariServer
  • ambari001,ambari002,ambari003 装AmbariAgent

开启网络

#开启网络
vi /etc/sysconfig/network-scripts/ifcfg-ens33
#修改最后一行
ONBOOT=yes

#立即生效
service network restart

配置HostName

#编辑此文件 加入ambari001(重启生效)
vi /etc/sysconfig/network

#立即生效
hostname ambari001

配置SSH免密登陆

#生成ssh公约私钥
ssh-keygen
#公钥拷贝到其他机器上
ssh-copy-id ambari001
#验证
ssh ambari001

配置NTP服务

#安装
yum install -y ntp
#检查是否已启动
systemctl is-enabled ntpd
#设为自启动
systemctl enable ntpd
#启动
systemctl start ntpd

禁用iptables

#取消开机启动
systemctl disable firewalld
#停止iptables服务
service firewalld stop

禁用SELinux和PackageKit 检查umask值

#禁用SELinux(立即生效)
setenforce 0
#禁用SELinux 编辑以下文件 修改SELINUX=disabled (永久生效)
/etc/selinux/config

#禁用PackageKit
vim /etc/yum/pluginconf.d/refresh-packagekit.conf

#设置umask(立即生效)
umask 0022
#设置umask(永久生效)
echo umask 0022 >> /etc/profile

安装JDK

cd /usr
wget wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
tar -zxvf jdk-8u131-linux-x64.tar.gz
#/usr/jdk1.8.0_131 这就是我们的JAVA_HOME
#拷贝到其他机器上
scp -r /usr/jdk1.8.0_131/ ambari002:/usr
scp -r /usr/jdk1.8.0_131/ ambari003:/usr

二、配置Yum源

准备

#安装Apache服务器
yum install -y httpd
#开启Apache服务器
service httpd start
#安装wget
yum install -y wget

#创建相关目录
mkdir -p /var/www/html/Ambari-2.4.2.0/centos7
mkdir -p /var/www/html/hdp/HDP/centos7/2.x/updates/2.5.3.0
mkdir -p /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7

#从网络下载或从其他机器拷贝yum源安装包
#从网络下载
cd /var/www/html/Ambari-2.4.2.0/centos7;wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.4.2.0/ambari-2.4.2.0-centos7.tar.gz
cd /var/www/html/hdp/HDP/centos7/2.x/updates/2.5.3.0;wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.5.3.0/HDP-2.5.3.0-centos7-rpm.tar.gz
cd /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7;wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz

#或从其他地方拷贝
scp ambari-2.4.2.0-centos7.tar.gz root@ambari001:/var/www/html/Ambari-2.4.2.0/centos7
scp HDP-2.5.3.0-centos7-rpm.tar.gz  root@ambari001:/var/www/html/hdp/HDP/centos7/2.x/updates/2.5.3.0
scp HDP-UTILS-1.1.0.21-centos7.tar.gz   root@ambari001:/var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7

#解压并放在合适的位置
cd /var/www/html/Ambari-2.4.2.0/centos7;tar -zxvf ambari-2.4.2.0-centos7.tar.gz;mv AMBARI-2.4.2.0/centos7/2.4.2.0-136/* ./;rm -rf AMBARI-2.4.2.0/;rm -rf ambari-2.4.2.0-centos7.tar.gz
cd /var/www/html/hdp/HDP/centos7/2.x/updates/2.5.3.0;tar -zxvf HDP-2.5.3.0-centos7-rpm.tar.gz;mv HDP/centos7/* ./;rm -rf HDP;rm -rf HDP-2.5.3.0-centos7-rpm.tar.gz
cd /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7;tar -zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz;rm -rf HDP-UTILS-1.1.0.21-centos7.tar.gz

编辑/etc/yum.repos.d/ambari.repo文件

#VERSION_NUMBER=2.4.2.0-136

[Updates-ambari-2.4.2.0]
name=ambari-2.4.2.0 - Updates
baseurl=http://ambari001/Ambari-2.4.2.0/centos7
gpgcheck=1
gpgkey=http://ambari001/Ambari-2.4.2.0/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

编辑/etc/yum.repos.d/hdp.repo文件

#VERSION_NUMBER=2.5.3.0-37
[HDP-2.5.3.0]
name=HDP Version - HDP-2.5.3.0
baseurl=http://ambari001/hdp/HDP/centos7/2.x/updates/2.5.3.0
gpgcheck=1
gpgkey=http://ambari001/hdp/HDP/centos7/2.x/updates/2.5.3.0/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://ambari001/hdp/HDP-UTILS-1.1.0.21/repos/centos7
gpgcheck=1
gpgkey=http://ambari001/hdp/HDP/centos7/2.x/updates/2.5.3.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

repo文件拷贝到其他机器上

scp /etc/yum.repos.d/ambari.repo ambari002:/etc/yum.repos.d;scp /etc/yum.repos.d/hdp.repo ambari002:/etc/yum.repos.d
scp /etc/yum.repos.d/ambari.repo ambari003:/etc/yum.repos.d;scp /etc/yum.repos.d/hdp.repo ambari003:/etc/yum.repos.d

验证本地yum源可用性

#在每台机器上执行如下命令:
yum clean all; yum repolist

三、安装Ambari-Server

yum install -y ambari-server

#进行AmbariServer设置
ambari-server setup
#1.SELinux检测 (直接按回车)
#2.选择使用的用户 (默认root,直接按回车)
#3.检查iptables
#4.指定JDK (输入3,然后将我们刚才的JAVA_HOME粘贴进去 /usr/jdk1.8.0_131)
#5.配置AmbariServer使用的元数据库 (使用默认的PostgreSQL,直接按回车)
#6.完成AmbariServer的配置

#启动AmbariServer
ambari-server start
#检查AmbariServer状态
ambari-server status

安装AmbariAgent和HDP服务

至此 AmbariServer已经安装完了 我们剩下的工作都是通过AmbariWeb来完成
访问 http://ambari001:8080 用户admin 密码admin

升级Ambari2.5

一、准备升级

  • 您必须有root权限
  • 您必须备份AmbariServer数据库
  • 必须备份/etc/ambari-server/conf/ambari.properties文件
  • 停止Ambari Metrics服务
  • 备份/var/lib/ambari-server/ambari-env.sh
  • ambari-server stop
  • ambari-agent stop

二、配置yum源

准备

#创建相关目录
mkdir -p /var/www/html/Ambari-2.5.1.0/centos7
mkdir -p /var/www/html/hdp/HDP/centos7/2.x/updates/2.6.1.0
mkdir -p /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7

#从网络下载或从其他机器拷贝yum源安装包
#从网络下载
cd /var/www/html/Ambari-2.5.1.0/centos7;wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz
cd /var/www/html/hdp/HDP/centos7/2.x/updates/2.6.1.0;wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz
cd /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7;wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz

#或从其他地方拷贝
scp ambari-2.5.1.0-centos7.tar.gz root@ambari001:/var/www/html/Ambari-2.5.1.0/centos7
scp HDP-2.6.1.0-centos7-rpm.tar.gz  root@ambari001:/var/www/html/hdp/HDP/centos7/2.x/updates/2.6.1.0
scp HDP-UTILS-1.1.0.21-centos7.tar.gz   root@ambari001:/var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7

#解压并放在合适的位置
cd /var/www/html/Ambari-2.5.1.0/centos7;tar -zxvf ambari-2.5.1.0-centos7.tar.gz;mv ambari ambari1;mv ambari1/centos7/* ./;rm -rf ambari-2.5.1.0-centos7.tar.gz
cd /var/www/html/hdp/HDP/centos7/2.x/updates/2.6.1.0;tar -zxvf HDP-2.6.1.0-centos7-rpm.tar.gz;mv HDP/centos7/* ./;rm -rf HDP-2.6.1.0-centos7-rpm.tar.gz
cd /var/www/html/hdp/HDP-UTILS-1.1.0.21/repos/centos7;tar -zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz;rm -rf HDP-UTILS-1.1.0.21-centos7.tar.gz

编辑/etc/yum.repos.d/ambari.repo文件

#VERSION_NUMBER=2.5.1.0-159
[ambari-2.5.1.0]
name=ambari Version - ambari-2.5.1.0
baseurl=http://ambari001:/Ambari-2.5.1.0/centos7
gpgcheck=1
gpgkey=http://ambari001:/Ambari-2.5.1.0/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

编辑/etc/yum.repos.d/hdp.repo文件

#VERSION_NUMBER=2.6.1.0-129
[HDP-2.6.1.0]
name=HDP Version - HDP-2.6.1.0
baseurl=http://ambari001/hdp/HDP/centos7/2.x/updates/2.6.1.0
gpgcheck=1
gpgkey=http://ambari001/hdp/HDP/centos7/2.x/updates/2.6.1.0/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://ambari001/hdp/HDP-UTILS-1.1.0.21/repos/centos7
gpgcheck=1
gpgkey=http://ambari001/hdp/HDP/centos7/2.x/updates/2.5.3.0/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

repo文件拷贝到其他机器上

scp /etc/yum.repos.d/ambari.repo ambari002:/etc/yum.repos.d;scp /etc/yum.repos.d/hdp.repo ambari002:/etc/yum.repos.d
scp /etc/yum.repos.d/ambari.repo ambari003:/etc/yum.repos.d;scp /etc/yum.repos.d/hdp.repo ambari003:/etc/yum.repos.d

验证本地Yum源可用性

yum clean all; yum repolist

三、准备升级AmbariServer-备份

mkdir -p /data/ambaribak
cp /var/lib/pgsql/data/pg_hba.conf /data/ambaribak/
cp /var/lib/ambari-server/ambari-env.sh /data/ambaribak
ambari-server stop
mkdir -p /data/ambaribak/dbdumps
#默认用户名ambari密码bigdata
pg_dump -U ambari -f /data/ambaribak/dbdumps/ambari.sql

四、升级AmbariServer、Agent、Metrics

#在AmbariServer节点执行
ambari-server stop

#在AmbariAgent节点执行
ambari-agent stop

#在AmbariServer节点执行
yum clean all
yum info ambari-server
yum upgrade ambari-server

#在AmbariAgent节点执行
yum upgrade ambari-agent
rpm -qa | grep ambari-agent

#升级AmbariServer元数据库(为了方便后续回滚 请一定保存此过程输出的控制台log!)
ambari-server upgrade

#更新完毕 启动服务
ambari-server start
ambari-agent start

#在所有MetricsMonitor HadoopSink使用的机器上 更新
yum upgrade ambari-metrics-monitor ambari-metrics-hadoop-sink
#在MetricsCollector节点上执行
yum upgrade ambari-metrics-collector
在Grafana节点上执行
yum upgrade ambari-metrics-grafana

五、AmbariServer、Agent、Metrics回滚方案

#在AmbariServer上执行
ambari-server stop

#在每个AmbariAgent上执行
ambari-agent stop

#在AmbariServer节点执行
HISTORY_ID=`yum history list ambari-server | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID

#恢复AmbariServer元数据库
su - postgres
psql
drop database ambari;
create database ambari;
\q
psql -d ambari -f /data/ambaribak/dbdumps/ambari.sql

#恢复配置文件(根据恢复时间不同 目录名也不同 请根据自己备份目录自行修改)
cp /data/ambaribak/pg_hba.conf /var/lib/pgsql/data
cp /data/ambaribak/ambari-env.sh /var/lib/pgsql/data
cp /etc/ambari-server/conf/ambari.properties.rpmsave /etc/ambari-server/conf/ambari.properties
cp /var/lib/ambari-server/ambari-env.sh.rpmsave /var/lib/ambari-server/ambari-env.sh
cp /etc/ambari-server/conf/krb5JAASLogin.conf.rpmsave /etc/ambari-server/conf/krb5JAASLogin.conf
#设置cp别名 方便使用cp -rf
unalias cp
cp -rf /var/lib/ambari-server/resources/stacks_22_06_17_20_48.old/* /var/lib/ambari-server/resources/stacks
cp -rf /var/lib/ambari-server/resources/common-services_22_06_17_20_48.old/* /var/lib/ambari-server/resources/common-services
cp /var/lib/ambari-server/resources/views/backups/*.jar /var/lib/ambari-server/resources/views
cp /usr/lib/ambari-server-backups/ambari-server-2.4.2.0.136.jar /usr/lib/ambari-server
#恢复cp别名
alias cp='cp -i'

#在AmbariAgent节点执行
HISTORY_ID=`yum history list ambari-agent | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID

ambari-server start
ambari-agent start
#AmbariServer、Agent回滚成功

#在所有MetricsMonitor HadoopSink的机器上执行
HISTORY_ID=`yum history list ambari-metrics-monitor | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID
HISTORY_ID=`yum history list ambari-metrics-hadoop-sink | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID
#在Collector节点上执行
HISTORY_ID=`yum history list ambari-metrics-collector | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID
#在Grafana节点上执行
HISTORY_ID=`yum history list yum upgrade ambari-metrics-grafana | awk '{print $1}' | grep -v [^0-9] | head -1`
yum history undo $HISTORY_ID
#AmbariMetrics回滚成功

六、备份HDFS元数据

sudo su hdfs
mkdir /data/ambaribak/hdfs
hdfs fsck / -files -blocks -locations > /data/ambaribak/hdfs/dfs-old-fsck-1.log
hdfs dfsadmin -report> /data/ambaribak/hdfs/dfs-old-report-1.log
hdfs dfs -ls -R /> /data/ambaribak/hdfs/dfs-old-lsr-1.log

hdfs dfsadmin -safemode
hdfs dfsadmin -saveNamespace
cp /data/hadoop/hdfs/namenode/current /data/ambaribak/hdfs
hdfs dfsadmin -safemode leave

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 87,467评论 13 122
  • Linux-Server-Notes PMS /home/softwareluke/图片/2017-09-11 0...
    IT诸葛亮阅读 188评论 0 0
  • 环境准备(单节点伪分布) 安装包下载 RedHat 6 / CentOS 6 / Oracle Linux 6 -...
    Pleb_King阅读 731评论 0 6
  • 1.关闭防火墙并关闭开机启动: systemctl stop firewalld.servicesystemctl...
    霂蔺阅读 864评论 0 0
  • 清明时节大雨汾分飞 呈现了这春天的阴冷与孤寂 伴着忧愁怀着相思奔异乡 春雨浇注 园了一生得梦 同样淋断 了了一世的...
    心在诉说她的痛阅读 56评论 0 0