大数据平台使用搭建脚本一键安装大数据平台使用搭建脚本一键安装OS
本文给大家分享的是如何在大数据平台使用脚本来实现一键安装定制OS,并给大家附上了脚本源码,有需要的小伙伴可以参考下
搭建脚本篇搭建脚本篇
脚本命名随便,只要能看懂就行
镜像包说明
os1.1.iso 用于安装服务端和客户端操作系统
hdp.iso 用于安装hdp服务
1.架构图:架构图:
服务端服务端
客户端客户端
2.原理分析原理分析
安装系统安装系统-安装本地安装本地yum源源-安装安装http源源-安装并配置安装并配置ntp服务服务-配置秘钥配置秘钥-安装安装jdk-安装安装mysql-编译安装编译安装ambari平台平台
3.服务端脚本分析
((1))create_local_yum.sh #安装本地安装本地yum 源源
#!/bin/bash
iso_path=/dev/sr0
echo "Iso file path is :" /dev/sr0
yum_path=/mnt/vrv/
echo 'Creating mount directory :' /mnt/vrv/
mkdir -p /mnt/vrv/
mount /dev/sr0 /mnt/vrv
echo 'Updating /etc/yum.repos.d/ files...'
rm -rf /etc/yum.repos.d/*
touch /etc/yum.repos.d/vrv.repo
echo "
[vrv-local]
name=vrv-local
baseurl=file:///mnt/vrv/
gpgcheck=0
enabled=1
" >> /etc/yum.repos.d/vrv.repo
yum clean all && echo 'yum repository has been updated!'
host_ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
echo "$host_ip os-manager" >>/usr/bin/os/hosts
#echo "$host_ip os-manager" >>/etc/hosts
((2))update_master.sh #安装安装http源,配置主节点,配置源,配置主节点,配置ntp
#!/bin/bash
#往本机/etc/hosts添加hosts文件内容#############
#cat hosts >> /etc/hosts;
#echo "添加hosts到/etc/hosts文件完成";
host_ip=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
suffix_ip=${host_ip%.*}
suffix_ip=${suffix_ip%.*}
cd /mnt/vrv/Packages/
#rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
yum -y install mkisofs vim httpd createrepo perl python bind-utils openssh-clients ntp vim wget unzip bind && chkconfig httpd on && mkdir -p /var/www/html/centos && mkdir -p /var/www/html/centos/Packages/Packages && mkdir -p /var/www/html/ambari/ && mkdir -p /var/www/html/vmp-extend/ && echo "拷贝文件中..." && cp -rf /mnt/vrv/Packages/* /var/www/html/centos/Packages/Packages/ && echo "拷贝文件完成,生成源中..." && createrepo /var/www/html/centos/Packages/Packages/ && rm -rf /etc/yum.repos.d/* && echo "http源拷贝完成,更新yum..."
cp -rf /mnt/vrv/system/* /var/www/html/
touch /etc/yum.repos.d/vrv-http.repo
echo "
[vrv-http]
name=vrv-http
baseurl=http://$host_ip/centos/Packages/Packages
gpgcheck=0
enabled=1
" >> /etc/yum.repos.d/vrv-http.repo
service httpd restart && chkconfig httpd on && yum clean all
echo "http 源已经配置完成"
echo "开始配置dns..."
echo "开始配置ntp..."
chkconfig ntpd on
#cp ntp.conf /etc/ntp.conf
# 写入ntp.conf文件
echo "
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict $suffix_ip.0.0 mask 255.255.0.0 nomodify notrap
restrict 0.vrv.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1.vrv.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.vrv.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
#server 210.72.145.44
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
" > /etc/ntp.conf
service ntpd restart && echo "ntp 配置完成!"
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc --localtime
## 配置 hdp yum####################
echo "开始配置ambari..."
mkdir -p /var/www/html/ambari/
mkdir -p /var/www/html/vmp-extend/
cp -rf /mnt/vrv/vrv/AMBARI-2.2.1.0/centos6/2.2.1.0-161/* /var/www/html/ambari/
cp -rf /mnt/vrv/vrv/vmp-extend-1.0/* /var/www/html/vmp-extend/
createrepo /var/www/html/vmp-extend/
createrepo /var/www/html/ambari/
# 写入文件
touch /etc/yum.repos.d/ambari.repo
touch /etc/yum.repos.d/vmp-extend.repo
echo "