官方升级文档:http://docs.hortonworks.com/HDPDocuments/Ambari-2.4.0.1/bk_ambari-upgrade/content/adding_grafana_to_ambari_metrics.html

0、升级mysql到5.6

1、停止服务。

   停止ambari-server、所有ambari-agent

   ambari-server stop    ambari-agent stop

2、备份ambari 数据库。

   mkdir -p /root/tmp/ambariUpgrate

   mysqlhotcopy --user=ambari --password=gotop123 ambari /root/tmp/ambariUpgrate

3、备份配置文件。

   cp /etc/ambari-server/conf/ambari.properties /root/tmp/ambariUpgrate

4、备份并解压安装包

   tar -zxf ambari-2.4.1.0-centos6.tar.gz

5、更新ambari.repo

   备份旧的ambari.repo

   将新的ambari.repo文件添加到/etc/yum.repos.d/目录下,所有机器都添加

   yum clean all

   yum info ambari-server

   确认新的配置生效

6、停止Ambari-Metrics

7、更新ambari-server

   yum -y upgrade ambari-server

8、所有机器更新agent

   yum -y upgrade ambari-agent

   检查是否安装

   rpm -qa | grep ambari-agent

9、设置mysql驱动

   拷贝mysql-connector-Java-5.1.37.jar到/usr/lib/ambari-server/目录下

   cp /usr/share/java/mysql-connector-java-5.1.37.jar /usr/lib/ambari-server/

10、更新数据库

   ambari-server upgrade

11、修改表的存储引擎

    SELECT CONCAT('ALTER TABLE ',table_name,' ENGINE=InnoDB;') FROM information_schema.tables

WHERE table_schema='ambari' AND ENGINE='MyISAM';

12、启动server

   ambari-server start

13、启动所有agent(我的机器自动启动)

   ambari-agent start

14、若安装了hive则执行

    设置hive存在的mysql库

    jdbc:mysql://wp/hive?createdatabaseIfNotExist=true&characterEncoding=UTF-8

    ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java-5.1.37.jar

15、更新ambari-Metrics

    确保服务停止

    在所有机器上执行

    yum clean all

    yum -y upgrade ambari-metrics-monitor ambari-metrics-hadoop-sink

    在安装了collector的主机上执行

    yum -y upgrade ambari-metrics-collector

16、在metrics-collector主机上安装Grafana

    curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST http://192.168.137.123:8080/api/v1/clusters/gotop/services/AMBARI_METRICS/components/METRICS_GRAFANA

    curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST -d '{"host_components":[{"HostRoles":{"component_name":"METRICS_GRAFANA"}}]}' http://192.168.137.123:8080/api/v1/clusters/gotop/hosts?Hosts/host_name=wp43

    备注:host_name=必须是主机名称不能是IP地址

17、再次在ambari上的主机页面组件上re-install一下Grafana

    Hosts > host.name > Re-install

18、配置Grafana密码

    Services > Ambari Metrics > Configs 配置密码

vi /var/lib/ambari-agent/cache/common-services/HIVE/0.12.0.2.0/package/scripts/hive_metastore.py

import sys

reload(sys)

sys.setdefaultencoding('utf-8')