redhat7的基本参数使用脚本配置

 

 使用pxe部署根据安装后业务需求撰写批量运行脚本

#!/bin/sh
#主机基本操作配置脚本,用于redhat7的操作系统

ntphost=10.25.210.1
manager_ip=10.25.210.1
FILENAME=hostinfo1.txt

###Solving the disorder problem (网卡乱序)
function init_network(){
neterrnum=`cat /etc/rc.d/rc.local|grep modprobe|wc -l`
if [[$neterrnum lt 2]];then
cat << __NETERR__ >> /etc/rc.d/rc.local
systemctl stop network 
modprobe -r igb
modprobe -r ixgbe
modprobe igb
modprobe ixgbe
systemctl start network 
__NETERR__
fi
}

###team network bonding IP(redhat7IP绑定)
function init_team(){
systemctl enable NetworkManager
systemctl start NetworkManager
nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
nmcli connection modify team0 ipv4.addresses 10.25.210.$1/24
nmcli connection add type team-slave con-name team0-port1 ifname eth4 master team0 connection.autoconnect on
nmcli connection add type team-slave con-name team0-port2 ifname eth6 master team0 connection.autoconnect on
teamdctl team0 state
}

###config manager IP(华为主机配置管理IP)
function init_ipmi(){
service ipmi start
ipmitool -I open lan print 1
ipmitool -I open lan set 1 ipsrc static
ipmitool -I open lan set 1 ipaddr 10.25.211.$1
ipmitool -I open lan set 1 netmask 255.255.255.0
ipmitool -I open lan set 1 defgw ipaddr $2
}

###config  hostname(修改主机名)
function init_hostname(){
hostnamectl set-hostname $1
}
 ###config ntpserver(修改NTPserver)
function init_ntp(){
systemctl start chronyd.service
sed -i 's/server 0.rhel.pool.ntp.org iburst/server $1 iburst/' /etc/chrony.conf 
sed -i '/server 1.rhel.pool.ntp.org iburst/d' /etc/chrony.conf 
sed -i '/server 2.rhel.pool.ntp.org iburst/d' /etc/chrony.conf 
sed -i '/server 3.rhel.pool.ntp.org iburst/d' /etc/chrony.conf 
systemctl restart chronyd.service
}
 ###config dns (停止DNS服务)
function init_dns(){
systemctl stop named 
systemctl disable named  
}

###creat user hadoop (创建用户)
function init_user(){
groupadd -g 501 hadoop
useradd -g hadoop -u 501 -md /home/hadoop -s /bin/bash hadoop
}

#####main()
grep $1 $FILENAME|while read key host ipnum
do
init_network 
init_team $ipnum
init_ipmi $ipnum
init_hostname $host
#init_ntp $ntphost
init_dns 
init_user
done

 

posted @ 2017-06-09 09:50  JonyQ  阅读(606)  评论(0编辑  收藏  举报