本文以 ambari-2.7.3.0 、 HDP-3.1.0.0 、 HDP-UTILS-1.1.0.22 、HDP-GPL-3.1.0.0为例搭建ambari集群。
一、下载对应版本的镜像包
wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari-2.7.3.0-centos7.tar.gz
wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/hdp.repo
wget http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/HDP-3.1.0.0-centos7-rpm.tar.gz
wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.1.0.0/HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
二、安装httpd服务
yum install -y httpd
systemctl start httpd
systemctl enable httpd
三、配置yum源
# 创建文件夹
mkdir -p /var/www/html/ambari
# 解压至文件夹
tar -zxvf ambari-2.7.3.0-centos7.tar.gz -C /var/www/html/ambari
tar -zxvf HDP-GPL-3.1.0.0-centos7-gpl.tar.gz -C /var/www/html/ambari
tar -zxvf HDP-3.1.0.0-centos7-rpm.tar.gz -C /var/www/html/ambari
tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/ambari
# 复制ambari.repo、hdp.repo到yum
cp ambari.repo /etc/yum.repos.d/
cp hdp.repo /etc/yum.repos.d/
# 修改ambari.repo(ip为httpd主机ip)
################################################################
[ambari-2.7.3.0]
#json.url = http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
name=ambari Version - ambari-2.7.3.0
baseurl=http://192.168.2.101/ambari/ambari/centos7/2.7.3.0-139/
gpgcheck=1
gpgkey=http://192.168.2.101/ambari/ambari/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
################################################################
# 修改hdp.repo(ip为httpd主机ip)
################################################################
[HDP-3.1.0.0]
name=HDP Version - HDP-3.1.0.0
baseurl=http://192.168.2.101/ambari/HDP/centos7/3.1.0.0-78/
gpgcheck=1
gpgkey=http://192.168.2.101/ambari/HDP/centos7/3.1.0.0-78/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
[HDP-UTILS-1.1.0.22]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
baseurl=http://192.168.2.101/ambari/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=1
gpgkey=http://192.168.2.101/ambari/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
################################################################
# 将repo复制到其他节点(所有节点)
scp /etc/yum.repos.d/ambari.repo server2:/etc/yum.repos.d/
scp /etc/yum.repos.d/hdp.repo server2:/etc/yum.repos.d/
# 更新yum(所有节点)
yum clean all
yum makecache
yum update
四、安装jdk8
五、配置服务器之间ssh免密
六、安装ntp时间同步服务器
- 服务端
# 安装
yum -y install ntp
# 配置
vi /etc/ntp.conf
##############################################################
//将这行给注释
#restrict default nomodify notrap nopeer noquery
//然后添加这两行 ,意思是 允许IPV4 IPV6 查询 拒绝修改
restrict -4 default kod notrap nomodify
restrict -6 default kod notrap nomodify
//添加修改上层时间服务器,如果能联通外网,则不需要修改,
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
//如果联不通外网,则把上面几行注释,然后添加下面两行,意思是设置成时间服务器是自己
server 127.127.1.0
fudge 127.127.1.0 stratum 8
##############################################################
# 启动
systemctl start ntpd
- 客户端
# 安装
yum -y install ntp
# 加入定时器
crontab -e
#############################################
0 * * * * /usr/sbin/ntpdate 192.168.2.101
#############################################
七、安装mysql
- 下载
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-1. el7.x86_64.rpm-bundle.tar
- 解压并安装
tar -xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
(备注:如遇包冲突,需删除 rpm -e 包名 --nodeps)
- 启动
systemctl start mysqld
- 查看密码(cat /var/log/mysqld.log)
- 修改密码策略
# 登录
mysql -uroot -p
# 修改密码策略
set global validate_password_policy=LOW;
set global validate_password_length=4;
- 修改root密码
/usr/bin/mysql_secure_installation
- 创建用户以及赋权
# 登录
mysql -uroot -p
# 赋权
create database ambari character set utf8;
Create user 'ambari' identified by 'ambari';
grant all privileges on *.* to 'ambari';
Flush privileges;
create database hive character set utf8;
create user 'hive' identified by 'hive';
grant all privileges on *.* to 'hive';
flush privileges;
八、安装ambari
yum install ambari-server
九、配置ambari
ambari-server setup
十、导入初始化数据
使用ambari用户登录:mysql -uambari -p
十一、导入Mysql驱动
yum install mysql-connector-java
cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/mysql-connector-java.jar
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
十二、启动服务
ambari-server start
十三、访问ambari
在浏览器中打开
http://192.168.2.101:8080
账号:admin
密码:admin
十四、服务安装
常见报错:
1. hbase启动后,运行报错:
Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /atsv2-hbase- unsecure/hbaseid
修改:ZooKeeper Znode Parent 的value为正确路径
2. hbase启动后,运行报错:
ServerNotRunningYetException: Server is not running yet
解决方案:
1)hdfs退出安全模式:sudo -u hdfs hadoop dfsadmin -safemode leave
3..hbase启动后,运行报错:
PleaseHoldException: Master is initializing
解决方案:
1)HBase root directory : 修改为hdfs路径(hdfs://namenode-ha:8020/hbase)