zoukankan      html  css  js  c++  java
  • RHEL系统初始化步骤

    1.配置网络

    ##初始化网络(可在虚拟网络编辑器查看自己的网段)
    ##方法一:静态初始化
    read -p "输入你当前Linux的IP地址:"  ip
    ETH=` ifconfig -a | head -1 | awk -F ":| "  '{print $1}'`
    GATE="`echo $ip | awk -F "." '{print $1"."$2"."$3"."}'`.2"
    cat > /etc/sysconfig/network-scripts/ifcfg-$ETH <<EOF
    TYPE=Ethernet
    BOOTPROTO=static
    NAME=$ETH
    DEVICE=$ETH
    IPADDR="$ip"
    GATEWAY=$GATE
    ONBOOT=yes
    DNS1=8.8.8.8
    EOF
    ##方法2:dhcp分配
    cat > /etc/sysconfig/network-scripts/ifcfg-$ETH <<EOFTYPE=Ethernet
    BOOTPROTO=dhcp
    NAME=$ETH
    DEVICE=$ETH
    ONBOOT=yes
    EOF 
    

    2.更改主机名(设为ip号的后三位有利于日后使用)

    ##(RHEL6) 
    cat > /etc/sysconfig/network <<EOF 
    NETWORKING=yes 
    HOSTNAME=server-123 
    EOF 
    ##(RHEL7) 
    hostnamectl --static set-hostname server-123
    

    3.关闭防火墙

    ##关闭防火墙(RHEL6) 
    
    iptables -t filter -F 
    iptables -t nat -F 
    service iptables save 
    service iptables stop       
    chkconfig iptables off     
    chkconfig ip6tables off
    chkconfig ip6tables off
    
    ##关闭防火墙(RHEL7)
    
    iptables -t filter -F
    iptables -t nat -F
    systemctl save iptables 
    systemctl stop iptables 
    systemctl disabled iptables 
    sed -ir '/SELINUX/{s/enforcing/disabled/}' /etc/selinux/config 
    

    4.配置yum源

    ##将sr0永久性挂载
    mkdir /iso 
    chmod u+x /etc/rc.d/rc.local 
    echo "mount /dev/sr0 /iso" >> /etc/rc.d/rc.local
    
     ##配置yum源
     touch /etc/yum.repos.d/base.repo
     cat > /etc/yum.repos.d/base.repo << EOF
     [base]
     name=mybase
     baseurl=file:///iso/ 
     enabled=1 
     gpgcheck=0
     EOF

    5.重启虚拟机

    init 6
    

     总结:将适用于自己RHEL/CENTOS (6,7)版本的脚本代码复制执行即可 

  • 相关阅读:
    Docker 版本升级
    Docker Swarm 常用命令
    Docker Swarm 介绍 or 工作原理
    Docker OpenvSwitch 应用部署
    Docker OpenvSwitch 介绍 or 工作原理
    Solr配置与简单Demo[转]
    使用solrj操作solr索引库,solr是lucene服务器
    Apache Solr配置
    使用solr搭建你的全文检索
    [转]flume-ng+Kafka+Storm+HDFS 实时系统搭建
  • 原文地址:https://www.cnblogs.com/1312862978Hg/p/9692444.html
Copyright © 2011-2022 走看看