Ansible 一键安装HDP 3.1, 准备环境:
- 1. Centos 7.6
安装好OS及硬盘挂载,OS采用最小化安装,HDFS目录分配 - 2. 集群机器之间免密ssh
- 3. 安装Ansible环境
这里我们安装的是基于独立的 Python 环境,减少跟操作系统环境依赖。
--Install the required packages
sudo yum -y install gcc gcc-c++ python-virtualenv python-pip python-devel libffi-devel openssl-devel libyaml-devel sshpass git vim-enhanced
--Create and source the Python virtual environment
virtualenv ~/ansible; source ~/ansible/bin/activate
--Install the required Python packages inside the virtualenv
pip install setuptools --upgrade
pip install pip --upgrade
pip install ansible
--You may need to load the environment variables if this is a new session
source ~/ansible/bin/activate
- 4. 从github下载ansible安装HDP脚本
此代码本人基于官方版本做了适当修改,主要修改为基于离线安装方式,提前下载好安装文件,另外把Mariadb的安装源修改为国内源,加快安装速度,github地址:https://github.com/d0pang/ansible-hortonworks
--git clone
cd /root/
git config --global user.name "dylan pang"
git config --global user.email "dylan.pang@qq.com"
cd && git clone git@github.com:d0pang/ansible-hortonworks.git
--update git
cd /root/ansible-hortonworks
git pull
- 5. 根据自己集群服务器环境调整Ansible脚本配置
(1)修改服务器列表及角色
(1)vi /root/ansible-hortonworks/inventory/static
//这里有hdp-masternode-01,hdp-masternode-02,hdp-slave,hdp-edge 四种角色服务器,与/root/ansible-hortonworks/playbooks/group_vars/all 配置文件里面的host_group对应起来,这样每台机器安装哪些组件,哪些服务就对应起来了,默认Mariadb,KDC, HTTP repo, 都是和Ambari-server服务器一起,当然也可以自行修改:
[hdp-masternode-01]
hadoop1 ansible_host=192.168.10.21 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost12-rack
[hdp-masternode-02]
hadoop2 ansible_host=192.168.10.22 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost10-rack
[hdp-slave]
hadoop3 ansible_host=192.168.10.23 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost11-rack
hadoop4 ansible_host=192.168.10.24 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost11-rack
hadoop5 ansible_host=192.168.10.25 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost12-rack
[hdp-edge]
hadoop6 ansible_host=192.168.10.26 ansible_user=root ansible_ssh_private_key_file="~/.ssh/id_rsa" rack=/vhost10-rack
(2)vi /root/ansible-hortonworks/playbooks/group_vars/all
//这里有各种配置,安装JDK类型,后端数据库类型,kerberos认证类型,默认密码等
repo_base_url: 'http://hadoop1' # 修改为自己Ambari-server机器名
security: 'none' # can be set to 'none', 'mit-kdc' or 'active-directory'
(3)vi /root/ansible-hortonworks/playbooks/roles/ambari-blueprint/defaults/main.yml
//这里修改默认目录配置
# Common base dirs
base_log_dir: "/var/log"
base_metrics_dir: "/var/lib"
base_tmp_dir: "/tmp"
# Specific base data dirs
hadoop_base_dir: "/u/applic/hdfs/"
hadoop_datanode_dir: "/u1/applic/hdfs/"
kafka_base_dir: "/u/applic/hdfs/kafka-logs"
nifi_base_dir: "/var/lib/nifi"
nifi_registry_base_dir: "/var/lib/nifi-registry"
- 6. 下载离线安装包
(1)HDP 3.1.0.0 :
http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0/HDP-3.1.0.0-centos7-rpm.tar.gz
(2) Ambari 2.7.3.0 :
http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari-2.7.3.0-centos7.tar.gz
(3)HDP-UTILS 1.1.0.22
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz HDP-GPL 3.1.0.0
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
安装包下载后放到以下目录:
[root@hadoop1 HDP3.1.0]# pwd
/root/HDP3.1.0
[root@hadoop1 HDP3.1.0]# ll
total 10845152
-rw-r--r--. 1 root root 1947685893 Jan 5 09:33 ambari-2.7.3.0-centos7.tar.gz
-rw-r--r--. 1 root root 486 Jan 5 09:48 download.txt
-rw-r--r--. 1 root root 9066967592 Jan 5 08:54 HDP-3.1.0.0-centos7-rpm.tar.gz
-rw-r--r--. 1 root root 162100 Jan 5 09:02 HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
-rw-r--r--. 1 root root 90606616 Jan 5 09:17 HDP-UTILS-1.1.0.22-centos7.tar.gz
- 7. 开始安装
注意以Ambari-server 所在机器作为Ansible主控节点,下载好的安装包也要放在这台机器指定目录
--You may need to load the environment variables if this is a new session
source ~/ansible/bin/activate
--List the inventory:
ansible -i inventory/static all --list-hosts
--Confirm access to hosts in the inventory:
ansible -i inventory/static all -m setup
--start install
export CLOUD_TO_USE=static
cd ~/ansible-hortonworks*/ && bash install_cluster.sh
- 8. 遇见美好
不出意外,从环境配置,集群角色安装,Kerberos认证2个小时左右就安装好了,有问题就要看具体什么问题,处理问题后,还是按上面第7步命令重复安装即可。
当然如果前面一些步骤已经安装成功了,则重装时可以跳过,修改文件注释掉一些步骤, 特别是解压安装包过程特别久可以跳过:
vi /root/ansible-hortonworks/playbooks/install_cluster.yml
Leave a Reply