• 一键部署服务(DNS,DHCP,RAID)


    一键部署DNS

    #!/bin/bash
    rpm -q bind
    if [ $? -eq 0 ];then
    echo "DNS服务已安装,开始配置服务"
    else
    echo "DNS服务未安装,开始安装"
    fi
    yum install -y bind
    if [ $? -eq 0 ];then
    echo "DNS服务安装成功"
    else
    echo "DNS服务安装失败,请检查"
    fi
    systemctl stop firewalld
    systemctl disable firewalld
    setenforce 0
    ###################################################################主配置文件######################################################################
    read -p "请输入ip地址" a
    sed -i '/listen-on port 53/s/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/'$a'/' /etc/named.conf
    sed -i '/allow-query/s/localhost/any/g' /etc/named.conf
    ###################################################################区域配置文件###################################################################
    read -p "请输入域名" b
    sed -i '24azone "'$b'" IN {\n      type master;\n    file "'$b'.zone";\n    allow-update { none; };\n};' /etc/named.rfc 1912.zones
    ###################################################################修改区域数据配置文件############################################################
    cp -p /var/named/named.localhost /var/named/$b.zone
    sed '10awww    A    '$a'' /var/named/$b.zone
    echo "$a www.$b" >>/etc/hosts
    echo "nameserver $a" >>/etc/resolc.conf
     

    一键部署DHCP

    #!/bin/bash
    rpm -q dhcp
    if [ $? -eq 0 ];then
    echo "服务已安装"
    else
    echo "服务未安装,正在安装"
    yum install -y dhcp
    fi
    rpm -q dhcp
    if [ $? -eq 0 ];then
    echo "服务安装成功"
    else 
    echo "服务安装失败,请检查"
    fi
    systemctl stop firewalld
    systemctl disable firewalld
    setenforce 0
    cp -rpf/usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
    read -p "请输入ip地址" ip
    read -p "请输入dhcp服务网关ip" gw
    ip_conf="/etc/sysconfig/network-scripts/ifcfg-eth0"
    ipwd=$(echo $ip | awk -F. '{print $1"."$2"."$3}' )
    sed -i 's/IPADDR=.*/IPADDR='"$ip"'/' $ip_conf
    sed -i 's/GATEWAY=.*/GATWAY="$gw"' $ip_conf
    systemctl restart network
    dhcp_version=`rpm -qa dhcp | awk -F'-' '{print $2}'`
    cd /usr/share/doc/dhcp-"$dhcp_version"
    grep -v "#" dhcpd.conf.sample |grep -v "^$"|sed -e 's/192.168.0/'"$ipwd"'/g' > /etc/dhcpd.conf
    sed -i '/nis\-domain/d'  /etc/dhcpd.conf 
    sed -i '/domain-name/d'  /etc/dhcpd.conf
    sed -i 's/'"$ipwd"'.1\;$/'"$gw"'\;/g' /etc/dhcpd.conf
    systemctl start dhcp


    一键部署raid

    #!/bin/bash
    read -p "你要做RAID几?" a
    case $a in

    5)
    fdisk /dev/sdb << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdc << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdd << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sde << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    yum -y install mdadm

    mdadm -C -v /dev/md5 -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1

    mkdir /opt/GPW

    mkfs.xfs /dev/md5

    mount /dev/md5 /opt/GPW

    df -Th
    ;;


    1)
    fdisk /dev/sdb << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdc << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    yum -y install mdadm

    mdadm -Cv /dev/md1 -l1 -n2 /dev/sd[bc]1

    mkdir /opt/GPW

    mkfs.xfs /dev/md1

    mount /dev/md1 /opt/GPW

    df -Th
    ;;

    0)
    fdisk /dev/sdb << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdc << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdd << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sde << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    yum -y install mdadm

    mdadm -C -v /dev/md0 -l0 -n4 /dev/sd[bcde]1

    mkdir /opt/GPW

    mkfs.xfs /dev/md0

    mount /dev/md0 /opt/GPW

    df -Th
    ;;


    10)
    fdisk /dev/sdb << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdc << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sdd << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    fdisk /dev/sde << EOF
    n
    \n
    \n
    \n
    +5G
    t
    \nf
    fd
    w
    EOF

    yum -y install mdadm

    mdadm -C -v /dev/md0 -l0 -n2 /dev/sd[bc]1

    mdadm -C -v /dev/md1 -l1 -n2 /dev/sd[de]1

    mdadm -Cv /dev/md10 -l10 -n2 /dev/md0 /dev/md1

    mkdir /opt/GPW

    mkfs.xfs /dev/md10

    mount /dev/md10 /opt/GPW

    df -Th
    ;;

    *)
    echo "这个我不会,我只会5,0,1,10"

    esac
     

  • 相关阅读:
    Windows2019部署IIS后,浏览文件变成下载的问题解决过程
    Day07 待办事项功能页面设计
    从事前端真的没有后端工资高?
    流向算法(FDA)(Matlab代码实现)
    漏洞复现----48、Airflow dag中的命令注入(CVE-2020-11978)
    Swift--基本运算符与程序流程控制
    力扣贪心——跳跃游戏I和II
    分析2022年国内国际学校ib的分数
    知识图谱2(正则表达式语法)
    如何在启用Secure Boot的Ubuntu 22.04电脑中安装使用VirtualBox 6.1
  • 原文地址:https://blog.csdn.net/a_b_e_l_/article/details/126411974