下载 CentOS 7 镜像
https://www.centos.org/download/
http://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso
配置 yum 国内源
替换国内源
1 | CentOS 7 清华源 |
注意其中的
*通配符,如果只需要替换一些文件中的源,请自行增删。
注意,如果需要启用其中一些 repo,需要将其中的enabled=0改为enabled=1。
更新软件包缓存
1 | sudo yum makecache |
升级内核
在线升级
3.10内核在大规模集群具有不稳定性,所以需要升级内核 。(所有机器都要升级到一样)
1 | 查看内核版本 |
离线升级
在本地浏览中打开以下URL,将列出可供下载的内核
https://elrepo.org/linux/kernel/el7/x86_64/RPMS/
下载当前最新长期支持版本,即以 kernel-lt 开头的文件
https://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-lt-5.4.234-1.el7.elrepo.x86_64.rpm
使用 sftp 工具把下载好的文件传输到 centos 主机 /root 目录
1 | 使用 rpm 命令安装新版内核 |
修改启动项使内核生效
1 | 查看系统可用内核 |
删除旧内核
1 | 查看系统中全部的内核 |
1 | 方法1:使用 rpm 删除内核 |
开启 BBR(可选)
1 | echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf && echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf |
离线安装常用软件
在线安装请使用
yum install lrzsz vim命令安装,此处不再赘述
安装 lrzsz
lrzsz 是一款程序,在linux中可以代替ftp的上传和下载
下载 rpm 安装包:
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/lrzsz-0.12.20-36.el7.x86_64.rpm
通过 sftp 将 rpm 包传输到 centos 主机 /root目录
1 | 执行以下命令安装 lrzsz |
安装 vim
Vim是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用,和Emacs并列成为类Unix系统用户最喜欢的文本编辑器。
下载 vim 安装包:
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/vim-common-7.4.629-7.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/vim-enhanced-7.4.629-7.el7.x86_64.rpm
下载 vim 依赖项 gpm-libs 包:
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/gpm-libs-1.20.7-6.el7.x86_64.rpm
下载 vim 依赖项 perl 包以及perl的依赖项(大概要下载下面那么多):
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-5.16.3-297.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-libs-5.16.3-297.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Carp-1.26-244.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-constant-1.27-2.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Encode-2.51-7.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Exporter-5.68-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-File-Path-2.09-2.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-File-Temp-0.23.01-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Filter-1.49-3.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Getopt-Long-2.40-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-HTTP-Tiny-0.033-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-macros-5.16.3-297.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-parent-0.225-244.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-PathTools-3.40-5.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Pod-Escapes-1.04-297.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-podlators-2.5.1-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Pod-Perldoc-3.20-4.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Pod-Simple-3.28-4.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Pod-Usage-1.63-3.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Socket-2.010-5.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Storable-2.45-3.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Text-ParseWords-3.29-4.el7.noarch.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-threads-1.87-4.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-threads-shared-1.43-6.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Time-HiRes-1.9725-3.el7.x86_64.rpm
https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/perl-Time-Local-1.2300-2.el7.noarch.rpm
将上面这些文件通过 sftp 或 rz 命令传输到 centos 主机的 同一个文件夹下,例:/root/vim/
1 | 执行以下命令进行安装,会自动解析依赖项进行安装 |
问题
Q:当完全内网使用时,在使用三方工具 ssh 连接时会比较慢,这是为什么?
A:这是由于ssh的服务端在连接时会自动检测dns环境是否一致,所以会发现Xshell连接虚拟机速度变慢了好多。
- 修改sshd_config
1
2
3
4
5
6 vi /etc/ssh/sshd_config
把
UseDNS yes
修改为
UseDNS no
- 重启服务
1 systemctl restart sshd