CentOS7初始化配置

操作系统安装
略……
操作系统配置
  1. 网络配置
    图形界面配置工具

     nmtui(centos7之前版本的setup)

    配置文件

    [root@bluse]#cat /etc/sysconfig/network-scripts/ifcfg-eth0
    NAME=eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    BOOTPROTO=none
    DEFROUTE=yes
    IPADDR=172.16.90.22
    NETMASK=255.255.255.0
    GATEWAY=172.16.90.254
    IPV4_FAILURE_FATAL=no
    DNS1=172.16.90.53
    DNS2=114.114.114.114
  2. 确认ssh远程登陆
    确认是否安装,并随机启动

     yum list installed | grep openssh-server
     systemctl status sshd

    配置文件路径/etc/ssh/sshd_config,可按需配置

  3. 关闭selinux、关闭防火墙、关闭postfix

    sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl stop postfix
    systemctl disable postfix
  4. 修改最大文件打开数

    echo -e '* soft nofile 65535\n* hard nofile 65535\n* soft nproc 65535\n* hard nproc 65535' >> /etc/security/limits.conf

    修改完后重启系统,然后ulimit -n确认

  5. 安装常用工具

    yum install -y vim wget lrzsz lsof zip unzip telnet net-tools bash-completion
  6. 更换yum源

    mkdir /etc/yum.repos.d/backup
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/backup
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum clean all
    yum makecache
  7. 修改主机名

    hostnamectl set-hostname [IP]
  8. 配置history格式
    /etc/profile添加以下变量用于显示命令执行时间用户名执行者IP

    USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`  
    export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}]"

    /etc/profile中HISTSIZE=1000(默认值)可按需修改

    source /etc/profile

  9. 时间同步

    # 安装
    yum install -y chrony
    # 启用
    systemctl start chronyd
    systemctl enable chronyd
    # 设置时区
    timedatectl set-timezone Asia/Shanghai
    # 启用NTP同步
    timedatectl set-ntp yes

    #查看同步源
    chronyc  sources
    同步server可在配置文件中修改/etc/chrony.conf

附:关于分区

 /boot 分配300M
 swap  根据物理内存大小分配,物理内存n≤4G时分2*n,4G≤n≤16G分n,n>16G分4G即可
 /home 分配20G
 /     分配20G
 /data 剩余

你可能感兴趣的:(linux,centos7,初始化,操作系统)