关于linux: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 残余

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理