zoukankan      html  css  js  c++  java
  • 最小化CentOS安装后的基础优化

    一、安装完成后基础配置

    1、修改IP地址

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
    
    TYPE=Ethernet
    BOOTPROTO=static
    NAME=eth0
    DEVICE=eth0
    ONBOOT=yes
    IPADDR=192.168.11.12
    NETMASK=255.255.255.0
    GATEWAY=192.168.11.2
    DNS1=180.76.76.76

    2、配置光盘自动挂载

    #虚拟机先连接光盘,再配置以下
    [root@localhost ~]# vim /etc/fstab 
    #添加以下行
    /dev/sr0                /mnt/cdrom              iso9660 defaults        0 0

    3、配置YUM源

    [root@localhost ~]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# mkdir bak
    [root@localhost yum.repos.d]# mv *.repo bak/
    [root@localhost yum.repos.d]# vi base.repo 
    #本地光盘yum源
    [development]
    name=dvdbase repo
    baseurl=file:///mnt/cdrom/
    enabled=1
    gpgcheck=1
    gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7
    
    #在线阿里云yum源
    [aliyun]
    name=aliyun repo
    baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
    enabled=1
    gpgchedk=1
    gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever
    
    #在线阿里云EPEL源
    [aliyunEpel]
    name=aliyun epel
    baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch
    enabled=1
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-$releasever

    4、安装基础命令

    [root@localhost ~]# yum install  -y vim iotop bc gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel zip unzip zlib-devel  net-tools lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel bc  systemd-devel bash-completion traceroute

    5、配置时间同步

    [root@localhost ~]# yum install -y chrony
    [root@localhost ~]# vim /etc/chrony.conf 
    #注释centos的时间同步节点,添加aliyun的
    #server 0.centos.pool.ntp.org iburst
    #server 1.centos.pool.ntp.org iburst
    #server 2.centos.pool.ntp.org iburst
    #server 3.centos.pool.ntp.org iburst
    server ntp1.aliyun.com iburst
    server ntp2.aliyun.com iburst
    #下面行的注释去掉
    local stratum 10
    
    [root@localhost ~]# systemctl start chronyd
    [root@localhost ~]# systemctl enable chronyd

    6、禁用SELinux

    [root@localhost ~]# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux 
    
    #或vim打开
    /etc/sysconfig/selinux修改 [root@localhost ~]# vim /etc/sysconfig/selinux #SELINUX=enforcing改为disabled,如下 SELINUX=disabled

    7、禁用防火墙

    [root@localhost ~]# systemctl stop firewalld
    [root@localhost ~]# systemctl disable firewalld

    8、关闭虚拟机、做快照

    [root@localhost ~]# shutdown -h now
  • 相关阅读:
    VS Code 调试 Angular 和 TypeScript 的配置
    如何在 ASP.NET Core 中发送邮件
    十二个 ASP.NET Core 例子
    ASP.NET Core MVC 源码学习:详解 Action 的激活
    10 分钟学会Linux常用 bash命令
    ASP.NET Core MVC 源码学习:详解 Action 的匹配
    ASP.NET Core MVC 源码学习:MVC 启动流程详解
    ASP.NET Core MVC 源码学习:Routing 路由
    多叉树查找
    《转》Ubuntu 12.04常用的快捷键
  • 原文地址:https://www.cnblogs.com/hovin/p/12925034.html
Copyright © 2011-2022 走看看