MapR的分布式集群安装过程还是很艰难的,远远没有计划中的简单。本人总结安装配置,由于集群有很多机器,手动每台配置是很累的,编写了一个自动化配置脚本,下面以脚本为主线叙述(脚本并不完善,后续继续完善中)。 编写脚本需要shell基础的,还要掌握awk和sed等统计手段为佳。操作系统是CentOS7。 准备:安装CentOS操作系统并分区 分区: / 50G /home 50G /boot 500M /var 50G /swap 8G /disk 305G(剩余全部,用于MapR的文件管理系统使用。特别注意,后面需要去掉挂载,reboot后会进入紧急模式,需要在配置里删掉disk的挂载)
一 配置IP
根据公司网络代理配置Ip,这里注意使用awk,用=划分每一行,根据=前的变量修改=后的变量,输出到备份文件中;然后替换原有的Ip配置文件,最后重启网卡。ip在设置前一定要ping一下,不通才可以使用,否则会有ip冲突。function config_ip(){
NETWORK_PATH=/etc/sysconfig/network-scripts/
ENFILE=`ls $NETWORK_PATH/ifcfg-en*`
IPADDR="10.4.45.211"
NETMASK="255.255.255.0"
GATEWAY="10.4.45.1"
DNS1="210.83.210.155"
TEMP_FILE="ifcfg.temp"
cat $ENFILE | awk -F "=" '{
if($1=="BOOTPROTO"){
print $1"=static"
}
else if($1=="ONBOOT"){
print $1"=yes"
}
else{
print $1"="$2
}
}
' > $TEMP_FILE
echo "IPADDR="$IPADDR >> $TEMP_FILE
echo "NETMASK="$NETMASK >> $TEMP_FILE
echo "GATEWAY="$GATEWAY >> $TEMP_FILE
echo "DNS1="$DNS1 >> $TEMP_FILE
mv $TEMP_FILE $ENFILE
service network restart
}
二 配置host文件
本集群暂时有四台主机,分别为apm1,apm2,apm3和apm4。用相应名称代替ip,简化了机器间的通讯。function config_hosts(){
echo "10.4.45.210 apm1" >> /etc/hosts
echo "10.4.45.211 apm2" >> /etc/hosts
echo "10.4.45.212 apm3" >> /etc/hosts
echo "10.4.45.213 apm4" >> /etc/hosts
}
三 配置网络代理
/etc/profile文件中加入代理配置,但这里是追加到文件尾部了,需要替换到文件顶部。根据自己的代理配置账户和密码。 function config_proxy(){
echo "# add by user" >> /etc/profile
echo "setterm -blength 0" >> /etc/profile
echo "export http_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
echo "export https_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
echo "export ftp_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
source /etc/profile
#curl "www.baidu.com"
}
四 配置本地repo
repo配置成国内镜像,可以加快下载速度。function config_repo(){
WY_REPO=CentOS-163.com.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cp /mnt/usb/$WY_REPO /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
}
五 下载安装JDK
上一步配置好代理后,下面就可以yum下载安装JDK,vim,和createrepo。function config_software(){
yum install vim
yum install java-1.8.0-openjdk-devel.x86_64
yum install createrepo
}
六 安装MapR
使用MapR的repo,配置安装MapR相应的服务,包括fileserver,nfs,nodemanager,zookeeper,resourcemanager 和cldbfunction config_mapr(){
MAPR_REPO=CentOS-mapr.repo
cp /mnt/usb/$MAPR_REPO /etc/yum.repos.d/maprtech.repo
yum install mapr-fileserver
yum install mapr-nfs
yum install mapr-nodemanager
yum install mapr-zookeeper
yum install mapr-resourcemanager
#yum install mapr-cldb
}
七 配置env.sh
function config_env(){
bash /opt/mapr/conf/env.sh
} 以上为脚本的内容,可以完成MapR的大部分自动化配置安装。 八 格式化disk,配置结点 后续完善。。。。。。。 脚本源码为下:#!/bin/bash
# config ip address
function config_ip(){
NETWORK_PATH=/etc/sysconfig/network-scripts/
ENFILE=`ls $NETWORK_PATH/ifcfg-en*`
IPADDR="10.4.45.211"
NETMASK="255.255.255.0"
GATEWAY="10.4.45.1"
DNS1="210.83.210.155"
TEMP_FILE="ifcfg.temp"
cat $ENFILE | awk -F "=" '{
if($1=="BOOTPROTO"){
print $1"=static"
}
else if($1=="ONBOOT"){
print $1"=yes"
}
else{
print $1"="$2
}
}
' > $TEMP_FILE
echo "IPADDR="$IPADDR >> $TEMP_FILE
echo "NETMASK="$NETMASK >> $TEMP_FILE
echo "GATEWAY="$GATEWAY >> $TEMP_FILE
echo "DNS1="$DNS1 >> $TEMP_FILE
mv $TEMP_FILE $ENFILE
service network restart
}
# config hosts
function config_hosts(){
echo "10.4.45.210 apm1" >> /etc/hosts
echo "10.4.45.211 apm2" >> /etc/hosts
echo "10.4.45.212 apm3" >> /etc/hosts
echo "10.4.45.213 apm4" >> /etc/hosts
}
# config proxy
function config_proxy(){
echo "# add by user" >> /etc/profile
echo "setterm -blength 0" >> /etc/profile
echo "export http_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
echo "export https_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
echo "export ftp_proxy=http://sunyandong:Ulic2016@dl-proxy.neusoft.com:8080/" >> /etc/profile
source /etc/profile
#curl "www.baidu.com"
}
function config_repo(){
#cp -r /mnt/usb/mapr /home/
# config repo
WY_REPO=CentOS-163.com.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cp /mnt/usb/$WY_REPO /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
}
# config software
function config_software(){
yum install vim
yum install java-1.8.0-openjdk-devel.x86_64
yum install createrepo
}
# mapr repo
function config_mapr(){
#cp /mnt/usb/mapr/* /home/apm2/mapr
#createrepo /mnt/usb/mapr
MAPR_REPO=CentOS-mapr.repo
cp /mnt/usb/$MAPR_REPO /etc/yum.repos.d/maprtech.repo
#rpm --import http://package.mapr.com/releases/pub/maprgpg.key
yum install mapr-fileserver
yum install mapr-nfs
yum install mapr-nodemanager
yum install mapr-zookeeper
yum install mapr-resourcemanager
#yum install mapr-cldb
}
function config_env(){
bash /opt/mapr/conf/env.sh
}
# main
config_repo
config_software
config_mapr
#config_ip
#config_hosts
#config_proxy