关于linux:CentOS7初始化配置

5次阅读

共计 1595 个字符,预计需要花费 4 分钟才能阅读完成。

操作系统装置
略……
操作系统配置
  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 残余

正文完
 0