CentOS安装操作系统级初始优化
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.SSH 连接速度慢优化
1>.关闭DNS PTR反向查询
UseDNS 选项打开状态下,当客户端试图登录SSH服务器时,服务器端先根据客户端的IP地址进行DNS PTR反向查询出客户端的主机名,然后根据查询出的客户端主机名进行DNS正向A记录查询,验证与其原始IP地址是否一致,这是防止客户端欺骗的一种措施,但一般我们的是动态IP不会有PTR记录,打开这个选项不过是在白白浪费时间而已,不如将其关闭。
[root@node101 ~]# [root@node101 ~]# grep UseDNS /etc/ssh/sshd_config #UseDNS yes [root@node101 ~]# [root@node101 ~]# sed -i 's@#UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config [root@node101 ~]# [root@node101 ~]# grep UseDNS /etc/ssh/sshd_config UseDNS no [root@node101 ~]#
2>.关闭GSSAPI身份验证
GSSAPIAuthentication 当这个参数开启( GSSAPIAuthentication yes )的时候,通过SSH登陆服务器时候会有些会很慢!这是由于服务器端启用了GSSAPI。登陆的时候客户端需要对服务器端的IP地址进行反解析,如果服务器的IP地址没有配置PTR记录,那么就容易在这里卡住了。
[root@node101 ~]# grep GSSAPIAuthentication /etc/ssh/sshd_config GSSAPIAuthentication yes [root@node101 ~]# [root@node101 ~]# sed -i 's@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config [root@node101 ~]# [root@node101 ~]# grep GSSAPIAuthentication /etc/ssh/sshd_config GSSAPIAuthentication no [root@node101 ~]# [root@node101 ~]# systemctl restart sshd [root@node101 ~]#
二.更换yum源
1>.创建备份目录
[root@node102 ~]# ll /etc/yum.repos.d/ total 28 -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo -rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo -rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# mkdir -p /etc/yum.repos.d/{default,back} [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 28 drwxr-xr-x. 2 root root 6 Mar 3 05:34 back -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo -rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo -rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo drwxr-xr-x. 2 root root 6 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]#
2>.备份所有默认的配置文件
[root@node102 ~]# ll /etc/yum.repos.d/ total 28 drwxr-xr-x. 2 root root 6 Mar 3 05:34 back -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo -rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo -rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo drwxr-xr-x. 2 root root 6 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]# mv /etc/yum.repos.d/*repo /etc/yum.repos.d/default/ [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 4 drwxr-xr-x. 2 root root 6 Mar 3 05:34 back drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]#
3>.获取yum 源
[root@node102 ~]# ll /etc/yum.repos.d/ total 4 drwxr-xr-x. 2 root root 6 Mar 3 05:34 back drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2523 100 2523 0 0 15349 0 --:--:-- --:--:-- --:--:-- 15478 [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 8 drwxr-xr-x. 2 root root 6 Mar 3 05:34 back -rw-r--r--. 1 root root 2523 Mar 3 05:35 CentOS-Base.repo drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]#
4>.生成缓存
[root@node102 ~]# yum makecache Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/8): extras/7/x86_64/filelists_db | 231 kB 00:00:00 extras/7/x86_64/other_db FAILED http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/repodata/d072100fade170a6b781b00657e1a6c116f84b59b35c21b98a280e598512508c-other.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known" Trying other mirror. (2/8): updates/7/x86_64/filelists_db | 1.9 MB 00:00:00 (3/8): updates/7/x86_64/other_db | 344 kB 00:00:00 (4/8): extras/7/x86_64/other_db | 118 kB 00:00:00 (5/8): base/7/x86_64/filelists_db | 7.1 MB 00:00:01 base/7/x86_64/other_db FAILED http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/fbebcd3de05e22bd1cd526e594f235968401471d4a9aef3c1ad356b6d1965365-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" Trying other mirror. extras/7/x86_64/prestodelta FAILED http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/ea35765e72afae3e1539686da06393ce09fe26a04dbf576e218f994e4b7a706a-prestodelta.xml.gz: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" Trying other mirror. (6/8): extras/7/x86_64/prestodelta | 47 kB 00:00:00 (7/8): base/7/x86_64/other_db | 2.6 MB 00:00:00 updates/7/x86_64/prestodelta FAILED http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/fd2186bbf3d231d441dc73bc0d0a3f2b79d5c212d14ceadf9a878fb2a5808de3-prestodelta.xml.gz: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused" Trying other mirror. (8/8): updates/7/x86_64/prestodelta | 343 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Metadata Cache Created [root@node102 ~]# [root@node102 ~]#
5>.备份yum 源
[root@node102 ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/back/ [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/back/ total 4 -rw-r--r--. 1 root root 2523 Mar 3 05:37 CentOS-Base.repo [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/default/ total 28 -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo -rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo -rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 8 drwxr-xr-x. 2 root root 29 Mar 3 05:37 back -rw-r--r--. 1 root root 2523 Mar 3 05:35 CentOS-Base.repo drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]#
三.yum基础软件安装
1>.安装Linux常用工具
[root@node102 ~]# yum -y install wget net-tools vim tree htop iftop iotop lrzsz sl unzip telnet nmap nc psmisc dos2unix bash-completion nethogs glances Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No package htop available. No package iftop available. No package sl available. No package nethogs available. No package glances available. Resolving Dependencies --> Running transaction check ---> Package bash-completion.noarch 1:2.1-6.el7 will be installed ---> Package dos2unix.x86_64 0:6.0.3-7.el7 will be installed ---> Package iotop.noarch 0:0.6-4.el7 will be installed ---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed ---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed ---> Package nmap.x86_64 2:6.40-16.el7 will be installed ---> Package nmap-ncat.x86_64 2:6.40-16.el7 will be installed ---> Package psmisc.x86_64 0:22.20-15.el7 will be installed ---> Package telnet.x86_64 1:0.17-64.el7 will be installed ---> Package tree.x86_64 0:1.6.0-10.el7 will be installed ---> Package unzip.x86_64 0:6.0-19.el7 will be installed ---> Package vim-enhanced.x86_64 2:7.4.160-5.el7 will be installed --> Processing Dependency: vim-common = 2:7.4.160-5.el7 for package: 2:vim-enhanced-7.4.160-5.el7.x86_64 --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64 --> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64 --> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64 ---> Package wget.x86_64 0:1.14-18.el7 will be installed --> Running transaction check ---> Package gpm-libs.x86_64 0:1.20.7-5.el7 will be installed ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64 ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed ---> Package vim-common.x86_64 2:7.4.160-5.el7 will be installed --> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.160-5.el7.x86_64 --> Running transaction check ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed ---> Package vim-filesystem.x86_64 2:7.4.160-5.el7 will be installed --> Running transaction check ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed --> Running transaction check ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed --> Running transaction check ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================== Package Arch Version Repository Size ========================================================================================================================================================================================================================== Installing: bash-completion noarch 1:2.1-6.el7 base 85 k dos2unix x86_64 6.0.3-7.el7 base 74 k iotop noarch 0.6-4.el7 base 52 k lrzsz x86_64 0.12.20-36.el7 base 78 k net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k nmap x86_64 2:6.40-16.el7 base 3.9 M nmap-ncat x86_64 2:6.40-16.el7 base 206 k psmisc x86_64 22.20-15.el7 base 141 k telnet x86_64 1:0.17-64.el7 base 64 k tree x86_64 1.6.0-10.el7 base 46 k unzip x86_64 6.0-19.el7 base 170 k vim-enhanced x86_64 2:7.4.160-5.el7 base 1.0 M wget x86_64 1.14-18.el7 base 547 k Installing for dependencies: gpm-libs x86_64 1.20.7-5.el7 base 32 k perl x86_64 4:5.16.3-294.el7_6 updates 8.0 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Encode x86_64 2.51-7.el7 base 1.5 M perl-Exporter noarch 5.68-3.el7 base 28 k perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter x86_64 1.49-3.el7 base 76 k perl-Getopt-Long noarch 2.40-3.el7 base 56 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-PathTools x86_64 3.40-5.el7 base 82 k perl-Pod-Escapes noarch 1:1.04-294.el7_6 updates 51 k perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 27 k perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k perl-Socket x86_64 2.010-4.el7 base 49 k perl-Storable x86_64 2.45-3.el7 base 77 k perl-Text-ParseWords noarch 3.29-4.el7 base 14 k perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 19 k perl-libs x86_64 4:5.16.3-294.el7_6 updates 688 k perl-macros x86_64 4:5.16.3-294.el7_6 updates 44 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 112 k perl-threads x86_64 1.87-4.el7 base 49 k perl-threads-shared x86_64 1.43-6.el7 base 39 k vim-common x86_64 2:7.4.160-5.el7 base 5.9 M vim-filesystem x86_64 2:7.4.160-5.el7 base 10 k Transaction Summary ========================================================================================================================================================================================================================== Install 13 Packages (+30 Dependent packages) Total download size: 24 M Installed size: 81 M Downloading packages: (1/43): bash-completion-2.1-6.el7.noarch.rpm | 85 kB 00:00:00 (2/43): gpm-libs-1.20.7-5.el7.x86_64.rpm | 32 kB 00:00:00 (3/43): iotop-0.6-4.el7.noarch.rpm | 52 kB 00:00:00 (4/43): lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00 (5/43): dos2unix-6.0.3-7.el7.x86_64.rpm | 74 kB 00:00:00 (6/43): net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00:00 (7/43): nmap-ncat-6.40-16.el7.x86_64.rpm | 206 kB 00:00:00 (8/43): perl-Carp-1.26-244.el7.noarch.rpm | 19 kB 00:00:00 (9/43): perl-Encode-2.51-7.el7.x86_64.rpm | 1.5 MB 00:00:00 (10/43): perl-Exporter-5.68-3.el7.noarch.rpm | 28 kB 00:00:00 (11/43): perl-File-Path-2.09-2.el7.noarch.rpm | 26 kB 00:00:00 (12/43): perl-File-Temp-0.23.01-3.el7.noarch.rpm | 56 kB 00:00:00 (13/43): perl-Filter-1.49-3.el7.x86_64.rpm | 76 kB 00:00:00 (14/43): perl-Getopt-Long-2.40-3.el7.noarch.rpm | 56 kB 00:00:00 (15/43): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm | 38 kB 00:00:00 (16/43): perl-PathTools-3.40-5.el7.x86_64.rpm | 82 kB 00:00:00 (17/43): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm | 87 kB 00:00:00 (18/43): perl-Pod-Simple-3.28-4.el7.noarch.rpm | 216 kB 00:00:00 (19/43): perl-Pod-Escapes-1.04-294.el7_6.noarch.rpm | 51 kB 00:00:00 (20/43): perl-Pod-Usage-1.63-3.el7.noarch.rpm | 27 kB 00:00:00 (21/43): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm | 36 kB 00:00:00 (22/43): perl-Socket-2.010-4.el7.x86_64.rpm | 49 kB 00:00:00 (23/43): perl-Storable-2.45-3.el7.x86_64.rpm | 77 kB 00:00:00 (24/43): perl-Text-ParseWords-3.29-4.el7.noarch.rpm | 14 kB 00:00:00 (25/43): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm | 45 kB 00:00:00 (26/43): perl-Time-Local-1.2300-2.el7.noarch.rpm | 24 kB 00:00:00 (27/43): perl-constant-1.27-2.el7.noarch.rpm | 19 kB 00:00:00 (28/43): nmap-6.40-16.el7.x86_64.rpm | 3.9 MB 00:00:01 (29/43): perl-libs-5.16.3-294.el7_6.x86_64.rpm | 688 kB 00:00:00 (30/43): perl-macros-5.16.3-294.el7_6.x86_64.rpm | 44 kB 00:00:00 (31/43): perl-parent-0.225-244.el7.noarch.rpm | 12 kB 00:00:00 (32/43): perl-podlators-2.5.1-3.el7.noarch.rpm | 112 kB 00:00:00 (33/43): perl-threads-1.87-4.el7.x86_64.rpm | 49 kB 00:00:00 (34/43): perl-threads-shared-1.43-6.el7.x86_64.rpm | 39 kB 00:00:00 (35/43): telnet-0.17-64.el7.x86_64.rpm | 64 kB 00:00:00 (36/43): psmisc-22.20-15.el7.x86_64.rpm | 141 kB 00:00:00 (37/43): tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 (38/43): unzip-6.0-19.el7.x86_64.rpm | 170 kB 00:00:00 (39/43): vim-enhanced-7.4.160-5.el7.x86_64.rpm | 1.0 MB 00:00:00 (40/43): vim-filesystem-7.4.160-5.el7.x86_64.rpm | 10 kB 00:00:00 (41/43): perl-5.16.3-294.el7_6.x86_64.rpm | 8.0 MB 00:00:02 (42/43): wget-1.14-18.el7.x86_64.rpm | 547 kB 00:00:00 (43/43): vim-common-7.4.160-5.el7.x86_64.rpm | 5.9 MB 00:00:01 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 7.0 MB/s | 24 MB 00:00:03 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:perl-parent-0.225-244.el7.noarch 1/43 Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 2/43 Installing : perl-podlators-2.5.1-3.el7.noarch 3/43 Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 4/43 Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 5/43 Installing : perl-Text-ParseWords-3.29-4.el7.noarch 6/43 Installing : perl-Encode-2.51-7.el7.x86_64 7/43 Installing : perl-Pod-Usage-1.63-3.el7.noarch 8/43 Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64 9/43 Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64 10/43 Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 11/43 Installing : perl-Exporter-5.68-3.el7.noarch 12/43 Installing : perl-constant-1.27-2.el7.noarch 13/43 Installing : perl-Time-Local-1.2300-2.el7.noarch 14/43 Installing : perl-Socket-2.010-4.el7.x86_64 15/43 Installing : perl-Carp-1.26-244.el7.noarch 16/43 Installing : perl-PathTools-3.40-5.el7.x86_64 17/43 Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 18/43 Installing : perl-Storable-2.45-3.el7.x86_64 19/43 Installing : perl-File-Temp-0.23.01-3.el7.noarch 20/43 Installing : perl-File-Path-2.09-2.el7.noarch 21/43 Installing : perl-threads-shared-1.43-6.el7.x86_64 22/43 Installing : perl-threads-1.87-4.el7.x86_64 23/43 Installing : perl-Filter-1.49-3.el7.x86_64 24/43 Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 25/43 Installing : perl-Getopt-Long-2.40-3.el7.noarch 26/43 Installing : 4:perl-5.16.3-294.el7_6.x86_64 27/43 Installing : 2:vim-filesystem-7.4.160-5.el7.x86_64 28/43 Installing : 2:vim-common-7.4.160-5.el7.x86_64 29/43 Installing : 2:nmap-ncat-6.40-16.el7.x86_64 30/43 Installing : gpm-libs-1.20.7-5.el7.x86_64 31/43 Installing : 2:vim-enhanced-7.4.160-5.el7.x86_64 32/43 Installing : 2:nmap-6.40-16.el7.x86_64 33/43 Installing : lrzsz-0.12.20-36.el7.x86_64 34/43 Installing : unzip-6.0-19.el7.x86_64 35/43 Installing : wget-1.14-18.el7.x86_64 36/43 Installing : net-tools-2.0-0.24.20131004git.el7.x86_64 37/43 Installing : psmisc-22.20-15.el7.x86_64 38/43 Installing : tree-1.6.0-10.el7.x86_64 39/43 Installing : 1:bash-completion-2.1-6.el7.noarch 40/43 Installing : 1:telnet-0.17-64.el7.x86_64 41/43 Installing : iotop-0.6-4.el7.noarch 42/43 Installing : dos2unix-6.0.3-7.el7.x86_64 43/43 Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/43 Verifying : 2:nmap-6.40-16.el7.x86_64 2/43 Verifying : dos2unix-6.0.3-7.el7.x86_64 3/43 Verifying : iotop-0.6-4.el7.noarch 4/43 Verifying : 2:vim-enhanced-7.4.160-5.el7.x86_64 5/43 Verifying : perl-threads-shared-1.43-6.el7.x86_64 6/43 Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 7/43 Verifying : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 8/43 Verifying : perl-Exporter-5.68-3.el7.noarch 9/43 Verifying : perl-constant-1.27-2.el7.noarch 10/43 Verifying : perl-PathTools-3.40-5.el7.x86_64 11/43 Verifying : 1:telnet-0.17-64.el7.x86_64 12/43 Verifying : 1:perl-parent-0.225-244.el7.noarch 13/43 Verifying : 4:perl-5.16.3-294.el7_6.x86_64 14/43 Verifying : 1:bash-completion-2.1-6.el7.noarch 15/43 Verifying : 4:perl-libs-5.16.3-294.el7_6.x86_64 16/43 Verifying : perl-File-Temp-0.23.01-3.el7.noarch 17/43 Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 18/43 Verifying : tree-1.6.0-10.el7.x86_64 19/43 Verifying : perl-Time-Local-1.2300-2.el7.noarch 20/43 Verifying : gpm-libs-1.20.7-5.el7.x86_64 21/43 Verifying : psmisc-22.20-15.el7.x86_64 22/43 Verifying : 2:vim-common-7.4.160-5.el7.x86_64 23/43 Verifying : 4:perl-macros-5.16.3-294.el7_6.x86_64 24/43 Verifying : perl-Socket-2.010-4.el7.x86_64 25/43 Verifying : perl-Carp-1.26-244.el7.noarch 26/43 Verifying : net-tools-2.0-0.24.20131004git.el7.x86_64 27/43 Verifying : wget-1.14-18.el7.x86_64 28/43 Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 29/43 Verifying : 2:nmap-ncat-6.40-16.el7.x86_64 30/43 Verifying : perl-Pod-Usage-1.63-3.el7.noarch 31/43 Verifying : perl-Encode-2.51-7.el7.x86_64 32/43 Verifying : perl-Storable-2.45-3.el7.x86_64 33/43 Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 34/43 Verifying : perl-podlators-2.5.1-3.el7.noarch 35/43 Verifying : perl-File-Path-2.09-2.el7.noarch 36/43 Verifying : perl-threads-1.87-4.el7.x86_64 37/43 Verifying : perl-Filter-1.49-3.el7.x86_64 38/43 Verifying : perl-Getopt-Long-2.40-3.el7.noarch 39/43 Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 40/43 Verifying : unzip-6.0-19.el7.x86_64 41/43 Verifying : lrzsz-0.12.20-36.el7.x86_64 42/43 Verifying : 2:vim-filesystem-7.4.160-5.el7.x86_64 43/43 Installed: bash-completion.noarch 1:2.1-6.el7 dos2unix.x86_64 0:6.0.3-7.el7 iotop.noarch 0:0.6-4.el7 lrzsz.x86_64 0:0.12.20-36.el7 net-tools.x86_64 0:2.0-0.24.20131004git.el7 nmap.x86_64 2:6.40-16.el7 nmap-ncat.x86_64 2:6.40-16.el7 psmisc.x86_64 0:22.20-15.el7 telnet.x86_64 1:0.17-64.el7 tree.x86_64 0:1.6.0-10.el7 unzip.x86_64 0:6.0-19.el7 vim-enhanced.x86_64 2:7.4.160-5.el7 wget.x86_64 0:1.14-18.el7 Dependency Installed: gpm-libs.x86_64 0:1.20.7-5.el7 perl.x86_64 4:5.16.3-294.el7_6 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-294.el7_6 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-294.el7_6 perl-macros.x86_64 4:5.16.3-294.el7_6 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 vim-common.x86_64 2:7.4.160-5.el7 vim-filesystem.x86_64 2:7.4.160-5.el7 Complete! [root@node102 ~]#
2>.检查某个命令属于哪个安装包(比如检查ifconfig属于哪个安装包)
[root@node102 ~]# yum provides ifconfig Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools Repo : @base Matched from: Filename : /usr/sbin/ifconfig [root@node102 ~]#
3>.安装yum-config-manager工具
[root@node102 ~]# yum provides yum-config-manager Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com yum-utils-1.1.31-50.el7.noarch : Utilities based around the yum package manager Repo : base Matched from: Filename : /usr/bin/yum-config-manager [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# yum -y install yum-utils Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package yum-utils.noarch 0:1.1.31-50.el7 will be installed --> Processing Dependency: yum >= 3.4.3-143 for package: yum-utils-1.1.31-50.el7.noarch --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-50.el7.noarch --> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-50.el7.noarch --> Running transaction check ---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed --> Processing Dependency: libxml2 = 2.9.1-6.el7_2.3 for package: libxml2-python-2.9.1-6.el7_2.3.x86_64 ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch ---> Package yum.noarch 0:3.4.3-132.el7.centos.0.1 will be updated ---> Package yum.noarch 0:3.4.3-161.el7.centos will be an update --> Processing Dependency: rpm >= 4.11.3-22 for package: yum-3.4.3-161.el7.centos.noarch --> Processing Dependency: python-urlgrabber >= 3.10-8 for package: yum-3.4.3-161.el7.centos.noarch --> Running transaction check ---> Package libxml2.x86_64 0:2.9.1-5.el7_1.2 will be updated ---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be an update ---> Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed ---> Package python-urlgrabber.noarch 0:3.10-7.el7 will be updated ---> Package python-urlgrabber.noarch 0:3.10-9.el7 will be an update ---> Package rpm.x86_64 0:4.11.3-17.el7 will be updated --> Processing Dependency: rpm = 4.11.3-17.el7 for package: rpm-libs-4.11.3-17.el7.x86_64 --> Processing Dependency: rpm = 4.11.3-17.el7 for package: rpm-python-4.11.3-17.el7.x86_64 ---> Package rpm.x86_64 0:4.11.3-35.el7 will be an update --> Running transaction check ---> Package rpm-libs.x86_64 0:4.11.3-17.el7 will be updated --> Processing Dependency: rpm-libs(x86-64) = 4.11.3-17.el7 for package: rpm-build-libs-4.11.3-17.el7.x86_64 ---> Package rpm-libs.x86_64 0:4.11.3-35.el7 will be an update ---> Package rpm-python.x86_64 0:4.11.3-17.el7 will be updated ---> Package rpm-python.x86_64 0:4.11.3-35.el7 will be an update --> Running transaction check ---> Package rpm-build-libs.x86_64 0:4.11.3-17.el7 will be updated ---> Package rpm-build-libs.x86_64 0:4.11.3-35.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================== Package Arch Version Repository Size ========================================================================================================================================================================================================================== Installing: yum-utils noarch 1.1.31-50.el7 base 121 k Installing for dependencies: libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k python-chardet noarch 2.2.1-1.el7_1 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k Updating for dependencies: libxml2 x86_64 2.9.1-6.el7_2.3 base 668 k python-urlgrabber noarch 3.10-9.el7 base 108 k rpm x86_64 4.11.3-35.el7 base 1.2 M rpm-build-libs x86_64 4.11.3-35.el7 base 106 k rpm-libs x86_64 4.11.3-35.el7 base 277 k rpm-python x86_64 4.11.3-35.el7 base 83 k yum noarch 3.4.3-161.el7.centos base 1.2 M Transaction Summary ========================================================================================================================================================================================================================== Install 1 Package (+3 Dependent packages) Upgrade ( 7 Dependent packages) Total download size: 4.5 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/11): libxml2-2.9.1-6.el7_2.3.x86_64.rpm | 668 kB 00:00:00 (2/11): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm | 247 kB 00:00:00 (3/11): python-chardet-2.2.1-1.el7_1.noarch.rpm | 227 kB 00:00:00 (4/11): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00 (5/11): python-urlgrabber-3.10-9.el7.noarch.rpm | 108 kB 00:00:00 (6/11): rpm-build-libs-4.11.3-35.el7.x86_64.rpm | 106 kB 00:00:00 (7/11): rpm-libs-4.11.3-35.el7.x86_64.rpm | 277 kB 00:00:00 (8/11): rpm-python-4.11.3-35.el7.x86_64.rpm | 83 kB 00:00:00 (9/11): rpm-4.11.3-35.el7.x86_64.rpm | 1.2 MB 00:00:00 (10/11): yum-utils-1.1.31-50.el7.noarch.rpm | 121 kB 00:00:00 (11/11): yum-3.4.3-161.el7.centos.noarch.rpm | 1.2 MB 00:00:00 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 3.2 MB/s | 4.5 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : rpm-4.11.3-35.el7.x86_64 1/18 Updating : rpm-libs-4.11.3-35.el7.x86_64 2/18 Updating : rpm-build-libs-4.11.3-35.el7.x86_64 3/18 Updating : rpm-python-4.11.3-35.el7.x86_64 4/18 Installing : python-chardet-2.2.1-1.el7_1.noarch 5/18 Installing : python-kitchen-1.1.1-5.el7.noarch 6/18 Updating : libxml2-2.9.1-6.el7_2.3.x86_64 7/18 Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64 8/18 Updating : python-urlgrabber-3.10-9.el7.noarch 9/18 Updating : yum-3.4.3-161.el7.centos.noarch 10/18 Installing : yum-utils-1.1.31-50.el7.noarch 11/18 Cleanup : yum-3.4.3-132.el7.centos.0.1.noarch 12/18 Cleanup : rpm-python-4.11.3-17.el7.x86_64 13/18 Cleanup : python-urlgrabber-3.10-7.el7.noarch 14/18 Cleanup : rpm-build-libs-4.11.3-17.el7.x86_64 15/18 Cleanup : rpm-libs-4.11.3-17.el7.x86_64 16/18 Cleanup : rpm-4.11.3-17.el7.x86_64 17/18 Cleanup : libxml2-2.9.1-5.el7_1.2.x86_64 18/18 Verifying : python-urlgrabber-3.10-9.el7.noarch 1/18 Verifying : rpm-python-4.11.3-35.el7.x86_64 2/18 Verifying : rpm-libs-4.11.3-35.el7.x86_64 3/18 Verifying : yum-utils-1.1.31-50.el7.noarch 4/18 Verifying : rpm-4.11.3-35.el7.x86_64 5/18 Verifying : libxml2-2.9.1-6.el7_2.3.x86_64 6/18 Verifying : libxml2-python-2.9.1-6.el7_2.3.x86_64 7/18 Verifying : python-chardet-2.2.1-1.el7_1.noarch 8/18 Verifying : python-kitchen-1.1.1-5.el7.noarch 9/18 Verifying : yum-3.4.3-161.el7.centos.noarch 10/18 Verifying : rpm-build-libs-4.11.3-35.el7.x86_64 11/18 Verifying : rpm-libs-4.11.3-17.el7.x86_64 12/18 Verifying : libxml2-2.9.1-5.el7_1.2.x86_64 13/18 Verifying : rpm-4.11.3-17.el7.x86_64 14/18 Verifying : rpm-build-libs-4.11.3-17.el7.x86_64 15/18 Verifying : yum-3.4.3-132.el7.centos.0.1.noarch 16/18 Verifying : rpm-python-4.11.3-17.el7.x86_64 17/18 Verifying : python-urlgrabber-3.10-7.el7.noarch 18/18 Installed: yum-utils.noarch 0:1.1.31-50.el7 Dependency Installed: libxml2-python.x86_64 0:2.9.1-6.el7_2.3 python-chardet.noarch 0:2.2.1-1.el7_1 python-kitchen.noarch 0:1.1.1-5.el7 Dependency Updated: libxml2.x86_64 0:2.9.1-6.el7_2.3 python-urlgrabber.noarch 0:3.10-9.el7 rpm.x86_64 0:4.11.3-35.el7 rpm-build-libs.x86_64 0:4.11.3-35.el7 rpm-libs.x86_64 0:4.11.3-35.el7 rpm-python.x86_64 0:4.11.3-35.el7 yum.noarch 0:3.4.3-161.el7.centos Complete! [root@node102 ~]#
4>.显示仓库信息
[root@node102 ~]# yum-config-manager Loaded plugins: fastestmirror ========================================================================================================== main ========================================================================================================== [main] alwaysprompt = True assumeno = False assumeyes = False autocheck_running_kernel = True autosavets = True bandwidth = 0 bugtracker_url = http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum cache = 0 cachedir = /var/cache/yum/x86_64/7 check_config_file_age = True clean_requirements_on_remove = False color = auto color_list_available_downgrade = dim,cyan color_list_available_install = normal color_list_available_reinstall = bold,underline,green color_list_available_running_kernel = bold,underline color_list_available_upgrade = bold,blue color_list_installed_extra = bold,red color_list_installed_newer = bold,yellow color_list_installed_older = bold color_list_installed_reinstall = normal color_list_installed_running_kernel = bold,underline color_search_match = bold color_update_installed = normal color_update_local = bold color_update_remote = normal commands = debuglevel = 2 deltarpm = 2 deltarpm_metadata_percentage = 100 deltarpm_percentage = 75 depsolve_loop_limit = 100 disable_includes = diskspacecheck = True distroverpkg = centos-release downloaddir = downloadonly = enable_group_conditionals = True enabled = True enablegroups = True errorlevel = 2 exactarch = True exactarchlist = exclude = exit_on_lock = False failovermethod = priority fssnap_abort_on_errors = any fssnap_automatic_keep = 1 fssnap_automatic_post = False fssnap_automatic_pre = False fssnap_devices = !*/swap, !*/lv_swap fssnap_percentage = 100 ftp_disable_epsv = False gaftonmode = False gpgcheck = True group_command = objects group_package_types = mandatory, default groupremove_leaf_only = False history_list_view = single-user-commands history_record = True history_record_packages = yum, rpm http_caching = all installonly_limit = 5 installonlypkgs = kernel, kernel-bigmem, installonlypkg(kernel), installonlypkg(kernel-module), installonlypkg(vm), kernel-enterprise, kernel-smp, kernel-debug, kernel-unsupported, kernel-source, kernel-devel, kernel-PAE, kernel-PAE-debug installroot = / ip_resolve = keepalive = True keepcache = False kernelpkgnames = kernel, kernel-smp, kernel-enterprise, kernel-bigmem, kernel-BOOT, kernel-PAE, kernel-PAE-debug loadts_ignoremissing = False loadts_ignorenewrpm = False loadts_ignorerpm = False localpkg_gpgcheck = False logfile = /var/log/yum.log max_connections = 0 mddownloadpolicy = sqlite mdpolicy = group:small metadata_expire = 21600 metadata_expire_filter = read-only:present minrate = 0 mirrorlist_expire = 86400 multilib_policy = best obsoletes = True override_install_langs = overwrite_groups = False password = payload_gpgcheck = False persistdir = /var/lib/yum pluginconfpath = /etc/yum/pluginconf.d pluginpath = /usr/share/yum-plugins, /usr/lib/yum-plugins plugins = True progess_obj = protected_multilib = True protected_packages = yum, systemd proxy = False proxy_password = proxy_username = query_install_excludes = False recent = 7 recheck_installed_requires = True remove_leaf_only = False repo_gpgcheck = False repopkgsremove_leaf_only = False reposdir = /etc/yum/repos.d, /etc/yum.repos.d reset_nice = True retries = 10 rpm_check_debug = True rpmverbosity = info shell_exit_status = 0 showdupesfromrepos = False skip_broken = False skip_missing_names_on_install = True skip_missing_names_on_update = True ssl_check_cert_permissions = True sslcacert = sslclientcert = sslclientkey = sslverify = True syslog_device = /dev/log syslog_facility = LOG_USER syslog_ident = throttle = 0 timeout = 30.0 tolerant = True tsflags = ui_repoid_vars = releasever, basearch upgrade_group_objects_upgrade = True upgrade_requirements_on_install = False usercache = True username = usr_w_check = True ======================================================================================================= repo: base ======================================================================================================= [base] async = True bandwidth = 0 base_persistdir = /var/lib/yum/repos/x86_64/7 baseurl = http://mirrors.aliyun.com/centos/7/os/x86_64/, http://mirrors.aliyuncs.com/centos/7/os/x86_64/, http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/ cache = 0 cachedir = /var/cache/yum/x86_64/7/base check_config_file_age = True compare_providers_priority = 80 cost = 1000 deltarpm_metadata_percentage = 100 deltarpm_percentage = enabled = True enablegroups = True exclude = failovermethod = priority ftp_disable_epsv = False gpgcadir = /var/lib/yum/repos/x86_64/7/base/gpgcadir gpgcakey = gpgcheck = True gpgdir = /var/lib/yum/repos/x86_64/7/base/gpgdir gpgkey = http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 hdrdir = /var/cache/yum/x86_64/7/base/headers http_caching = all includepkgs = ip_resolve = keepalive = True keepcache = False mddownloadpolicy = sqlite mdpolicy = group:small mediaid = metadata_expire = 21600 metadata_expire_filter = read-only:present metalink = minrate = 0 mirrorlist = mirrorlist_expire = 86400 name = CentOS-7 - Base - mirrors.aliyun.com old_base_cache_dir = password = persistdir = /var/lib/yum/repos/x86_64/7/base pkgdir = /var/cache/yum/x86_64/7/base/packages proxy = False proxy_dict = proxy_password = proxy_username = repo_gpgcheck = False retries = 10 skip_if_unavailable = False ssl_check_cert_permissions = True sslcacert = sslclientcert = sslclientkey = sslverify = True throttle = 0 timeout = 30.0 ui_id = base/7/x86_64 ui_repoid_vars = releasever, basearch username = ====================================================================================================== repo: extras ====================================================================================================== [extras] async = True bandwidth = 0 base_persistdir = /var/lib/yum/repos/x86_64/7 baseurl = http://mirrors.aliyun.com/centos/7/extras/x86_64/, http://mirrors.aliyuncs.com/centos/7/extras/x86_64/, http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/ cache = 0 cachedir = /var/cache/yum/x86_64/7/extras check_config_file_age = True compare_providers_priority = 80 cost = 1000 deltarpm_metadata_percentage = 100 deltarpm_percentage = enabled = True enablegroups = True exclude = failovermethod = priority ftp_disable_epsv = False gpgcadir = /var/lib/yum/repos/x86_64/7/extras/gpgcadir gpgcakey = gpgcheck = True gpgdir = /var/lib/yum/repos/x86_64/7/extras/gpgdir gpgkey = http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 hdrdir = /var/cache/yum/x86_64/7/extras/headers http_caching = all includepkgs = ip_resolve = keepalive = True keepcache = False mddownloadpolicy = sqlite mdpolicy = group:small mediaid = metadata_expire = 21600 metadata_expire_filter = read-only:present metalink = minrate = 0 mirrorlist = mirrorlist_expire = 86400 name = CentOS-7 - Extras - mirrors.aliyun.com old_base_cache_dir = password = persistdir = /var/lib/yum/repos/x86_64/7/extras pkgdir = /var/cache/yum/x86_64/7/extras/packages proxy = False proxy_dict = proxy_password = proxy_username = repo_gpgcheck = False retries = 10 skip_if_unavailable = False ssl_check_cert_permissions = True sslcacert = sslclientcert = sslclientkey = sslverify = True throttle = 0 timeout = 30.0 ui_id = extras/7/x86_64 ui_repoid_vars = releasever, basearch username = ===================================================================================================== repo: updates ====================================================================================================== [updates] async = True bandwidth = 0 base_persistdir = /var/lib/yum/repos/x86_64/7 baseurl = http://mirrors.aliyun.com/centos/7/updates/x86_64/, http://mirrors.aliyuncs.com/centos/7/updates/x86_64/, http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/ cache = 0 cachedir = /var/cache/yum/x86_64/7/updates check_config_file_age = True compare_providers_priority = 80 cost = 1000 deltarpm_metadata_percentage = 100 deltarpm_percentage = enabled = True enablegroups = True exclude = failovermethod = priority ftp_disable_epsv = False gpgcadir = /var/lib/yum/repos/x86_64/7/updates/gpgcadir gpgcakey = gpgcheck = True gpgdir = /var/lib/yum/repos/x86_64/7/updates/gpgdir gpgkey = http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 hdrdir = /var/cache/yum/x86_64/7/updates/headers http_caching = all includepkgs = ip_resolve = keepalive = True keepcache = False mddownloadpolicy = sqlite mdpolicy = group:small mediaid = metadata_expire = 21600 metadata_expire_filter = read-only:present metalink = minrate = 0 mirrorlist = mirrorlist_expire = 86400 name = CentOS-7 - Updates - mirrors.aliyun.com old_base_cache_dir = password = persistdir = /var/lib/yum/repos/x86_64/7/updates pkgdir = /var/cache/yum/x86_64/7/updates/packages proxy = False proxy_dict = proxy_password = proxy_username = repo_gpgcheck = False retries = 10 skip_if_unavailable = False ssl_check_cert_permissions = True sslcacert = sslclientcert = sslclientkey = sslverify = True throttle = 0 timeout = 30.0 ui_id = updates/7/x86_64 ui_repoid_vars = releasever, basearch username = [root@node102 ~]#
5>.yum 本地仓库创建repo 仓库
[root@node102 ~]# ll /yinzhengjie/ total 0 drwxr-xr-x. 3 root root 60 Mar 2 07:01 softwares [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# yum-config-manager --add-repo="file:///yinzhengjie" Loaded plugins: fastestmirror adding repo from: file:///yinzhengjie [yinzhengjie] name=added from: file:///yinzhengjie baseurl=file:///yinzhengjie enabled=1 [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# ll /yinzhengjie/ total 0 drwxr-xr-x. 3 root root 60 Mar 2 07:01 softwares [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 12 drwxr-xr-x. 2 root root 29 Mar 3 05:37 back -rw-r--r--. 1 root root 2523 Mar 3 05:35 CentOS-Base.repo drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default -rw-r--r--. 1 root root 91 Mar 3 05:47 yinzhengjie.repo [root@node102 ~]# [root@node102 ~]# cat /etc/yum.repos.d/yinzhengjie.repo [yinzhengjie] name=added from: file:///yinzhengjie baseurl=file:///yinzhengjie enabled=1 [root@node102 ~]# [root@node102 ~]#
6>.删除指定的yum配置文件(比如删除掉“/etc/yu.repos.d/yinzhengjie.repo”)
[root@node102 ~]# ll /etc/yum.repos.d/ total 12 drwxr-xr-x. 2 root root 29 Mar 3 05:37 back -rw-r--r--. 1 root root 2523 Mar 3 05:35 CentOS-Base.repo drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default -rw-r--r--. 1 root root 91 Mar 3 05:47 yinzhengjie.repo [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# rm -f /etc/yum.repos.d/yinzhengjie.repo [root@node102 ~]# [root@node102 ~]# ll /etc/yum.repos.d/ total 8 drwxr-xr-x. 2 root root 29 Mar 3 05:37 back -rw-r--r--. 1 root root 2523 Mar 3 05:35 CentOS-Base.repo drwxr-xr-x. 2 root root 4096 Mar 3 05:34 default [root@node102 ~]# [root@node102 ~]#
四.优化ulimit
[root@node102 ~]# echo '* - nofile 65535' >> /etc/security/limits.conf [root@node102 ~]# [root@node102 ~]# cat /etc/security/limits.conf |egrep -v "^#|^$" * - nofile 65535 [root@node102 ~]# [root@node102 ~]#
五.显示优化
1.设置ps1变量的显示 PS1(是数字1而不是字母l),每个版本bash的PS1变量内的特殊符号可能有些小的差异,你可以先man bash 一下。下面是FC4环境下默认的特殊符号所代表的意义: d :代表日期,格式为weekday month date,例如:"Mon Aug 1" H :完整的主机名称。例如:我的机器名称为:fc4.linux,则这个名称就是fc4.linux h :仅取主机的第一个名字,如上例,则为fc4,.linux则被省略 :显示时间为24小时格式,如:HH:MM:SS T :显示时间为12小时格式 A :显示时间为24小时格式:HH:MM u :当前用户的账号名称 v :BASH的版本信息 w :完整的工作目录名称。家目录会以 ~代替 W :利用basename取得工作目录名称,所以只会列出最后一个目录 # :下达的第几个命令 $ :提示字符,如果是root时,提示符为:# ,普通用户则为:$ 默认的PS1内容为: PS1='[u@h W]$ ' ,所以默认的提示符就是: [root@linux ~]#。
设置ps1变量的颜色 我们能够通过配置PS1变量使提示符成为彩色。在PS1中配置字符序列颜色的格式为: [e[F;Bm] 基本上是夹在 "e["(转义开方括号)和 "m" 之间数字值。假如指定一个以上的数字代码,则用分号将他们分开。 其中 F 为字体颜色,编号30~37; B 为背景色,编号40~47。 可通过 e[0m 关闭颜色输出;特别的,当B为1时,将显示加亮加粗的文字,请看下面的颜色表和代码表。 颜色表 前景 背景 颜色 --------------------------------------- 30 40 黑色 31 41 红色 32 42 绿色 33 43 黄色 34 44 蓝色 35 45 紫色 36 46 青色 37 47 白色
[ "$PS1" = "\s-\v\$ " ] && PS1="[[e[34;1m]u@[e[0m][e[32;1m]H[e[0m] [e[31;1m]w[e[0m]]\$ "
添加到/etc/bashrc,注释掉原有的PS1,然后生效source /etc/bashrc,并将连接段的字符集改成UTF-8,我们以Xshell为例,如下:
六.修改网卡名称
1>.查看网卡信息
[root@node102 ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.1.102 netmask 255.255.255.0 broadcast 172.30.1.255 inet6 fe80::20c:29ff:fedc:1634 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:dc:16:34 txqueuelen 1000 (Ethernet) RX packets 34389 bytes 45135951 (43.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16107 bytes 1579825 (1.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node102 ~]# [root@node102 ~]#
2>.修改网卡配置文件的名字
[root@node102 ~]# cd /etc/sysconfig/network-scripts/ [root@node102 network-scripts]# [root@node102 network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0 [root@node102 network-scripts]#
3>.修改网卡配置文件里面的内容
[root@node102 network-scripts]# pwd /etc/sysconfig/network-scripts [root@node102 network-scripts]# [root@node102 network-scripts]# cat ifcfg-eth0 TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=172.30.1.102 NETMASK=255.255.255.0 GATEWAY=172.30.1.254 DNS1=172.30.1.254 [root@node102 network-scripts]# [root@node102 network-scripts]#
4>.GRUB 添加kernel 参数
[root@node102 ~]# cat /etc/sysconfig/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="crashkernel=auto rhgb net.ifnames=0 biosdevname=0 quiet" GRUB_DISABLE_RECOVERY="true" [root@node102 ~]#
5>.使配置生效
[root@node102 ~]# 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-d1667a8e7e71407d8b380ec3588d6c19 Found initrd image: /boot/initramfs-0-rescue-d1667a8e7e71407d8b380ec3588d6c19.img done [root@node102 ~]#
6>.重启之前检查配置是否生效
[root@node102 ~]# nmcli connection NAME UUID TYPE DEVICE System eno16777736 13756690-ac77-b776-4fc1-f5535cee6f16 802-3-ethernet eno16777736 [root@node102 ~]# [root@node102 ~]# [root@node102 ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.1.102 netmask 255.255.255.0 broadcast 172.30.1.255 inet6 fe80::20c:29ff:fedc:1634 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:dc:16:34 txqueuelen 1000 (Ethernet) RX packets 35013 bytes 45196240 (43.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16608 bytes 1663225 (1.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node102 ~]# [root@node102 ~]#
7>.重启服务器
[root@node102 ~]# init 6 Connection closed by foreign host. Disconnected from remote host(node102.yinzhengjie.org.cn) at 22:05:45. Type `help' to learn how to use Xshell prompt. [c:~]$
8>.重启之后发现配置已经生效
[root@node102.yinzhengjie.org.cn ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.1.102 netmask 255.255.255.0 broadcast 172.30.1.255 inet6 fe80::20c:29ff:fedc:1634 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:dc:16:34 txqueuelen 1000 (Ethernet) RX packets 67 bytes 7690 (7.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 85 bytes 11524 (11.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# nmcli connection NAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0 [root@node102.yinzhengjie.org.cn ~]#