Centos 7装机优化

linux主机优化

1、配置hosts文件

[root@localhost ~]#  vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

2、更改yum源

[root@localhost ~]# curl -o /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3、关闭selinux

[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled

4、关闭iptables

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

5、时间同步

[root@localhost ~]# yum install ntpdate -y
[root@localhost ~]# echo '#time sync by dqforgive at 2021-6-23' >>/var/spool/cron/root
[root@localhost ~]# echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1' >>/var/spool/cron/root

6、加大文件描述

[root@localhost ~]# echo '*       -      nofile      65535' >>/etc/security/limits.conf

7、安装一些小软件

[root@localhost ~]# yum install lrzsz nmap tree dos2linux nc telnet lsof -y

8、ssh连接速度优化

[root@localhost ~]# sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/ssh_config
[root@localhost ~]# systemctl reload sshd

9、修改默认网卡名

(1)在安装操作系统时点击tab进入内核编辑界面,输入: net.ifnames=0 biosdevname=0 回车就ok(适用于安装操作系统时使用)

(2)编辑 网卡配置文件

//进入网卡目录
[root@ansheng network-scripts]# cd /etc/sysconfig/network-scripts/
//编辑网卡配置文件
[root@ansheng network-scripts]# vim ifcfg-ens33
//修改其中 DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
UUID=8a3eade8-005c-46df-81f2-6e2598457bac
#DEVICE=eno16777728
DEVICE=eth0
ONBOOT=yes
//重命名网卡名
[root@ansheng network-scripts]# mv ifcfg-ens33 ifcfg-eth0

因 CentOS7 采用 grub2 引导,还需要对 grub2 进行修改,编辑 /etc/default/grub 配置文件,在 GRUB_CMDLINE_LINUX 这个参数后面加入 net.ifnames=0  biosdevname=0   

[root@ansheng network-scripts]# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
用 grub2-mkconfig 命令重新生成GRUB配置并更新内核  

[root@ansheng network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-4dd6b54f74c94bff9e92c61d669fc195
Found initrd image: /boot/initramfs-0-rescue-4dd6b54f74c94bff9e92c61d669fc195.img
done
重启系统  

[root@ansheng network-scripts]# reboot
重启之后验证网卡名称:  

[root@ansheng ~]# ifconfig 

本文作者:dqforgive-sudo

本文链接:https://www.cnblogs.com/dqforgive-sudo/p/16165489.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   dqforgive-sudo  阅读(91)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.