学习是一个逐步发现自己无知的过程!

Centos7到底发生了那些变化呢?

Centos6与Centos7的区别

自动补全需要安装

yum install bash-completion -y

Centos7使用ifconfig命令

yum install net-tools -y

Cfntos7启动级别

SysVinit Systemd 
关闭系统          0 runlevel0.target, poweroff.target 
单用户模式        1 runlevel1.target, rescue.target 
多用户模式        2 runlevel2.target, multi-user.target 
多用户带网络模式  3 runlevel3.target, multi-user.target 
多用户图形化模式  5 runlevel5.target, graphical-user.target 
重启操作系统      6 runlevel6.target, reboot.target

Centos7开机默认系统启动目标target

multi-user.target: analogous to runlevel 3
graphical.target: analogous to runlevel 5

查看Centos7系统当前默认的运行级别(目标)

[root@oldboy-c7 ~]# systemctl get-default
multi-user.target

修改Centos7系统默认的运行级别(目标)

[root@oldboy-c7 ~]# systemctl set-default runlevel5.target

Centos6与Centos7系统文件目录的结构

centos6           cetos7
bin               usr/bin
sbin              usr/sbin
lib lib           usr/lib

Centos7 Systemd 服务管理

启动服务	/etc/init.d/crond start					systemctl start 		crond
停止服务	/etc/init.d/crond stop					systemctl stop		        crond
重启服务	/etc/init.d/crond restart				systemctl restart		crond
查看状态	/etc/init.d/crond status				systemctl status		crond
开机启动	chkconfig --level 35 crond on		                systemctl enable		crond
开机禁用	chkconfig crond off					systemctl disable		crond
禁止运行								systemctl umask		        crond

 

Centos 系统优化

调整yum源为阿里云

rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

调整yum源为清华大学

gzip /etc/yum.repos.d/*  #压缩原有yum源

========================================
/etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]# cat >>/etc/yum.repos.d/CentOS-Base.repo<< EOF
> # CentOS-Base.repo
> #
> # The mirror system uses the connecting IP address of the client and the
> # update status of each mirror to pick mirrors that are updated to and
> # geographically close to the client.  You should use this for CentOS updates
> # unless you are manually picking other mirrors.
> #
> # If the mirrorlist= does not work for you, as a fall back you can try the
> # remarked out baseurl= line instead.
> #
> #
> 
> [base]
> name=CentOS-$releasever - Base
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> 
> #released updates
> [updates]
> name=CentOS-$releasever - Updates
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> 
> #additional packages that may be useful
> [extras]
> name=CentOS-$releasever - Extras
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> 
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-$releasever - Plus
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
> #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
========================================

/etc/yum.repos.d/epel.repo

[root@localhost ~]# cat >>/etc/yum.repos.d/epel.repo<< EOF
> [epel]
> name=Extra Packages for Enterprise Linux 7 - $basearch
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
> #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
> failovermethod=priority
> enabled=1
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
> 
> [epel-debuginfo]
> name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
> #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
> failovermethod=priority
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
> gpgcheck=1
> 
> [epel-source]
> name=Extra Packages for Enterprise Linux 7 - $basearch - Source
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
> #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
> failovermethod=priority
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
> gpgcheck=1
> EOF

========================================

 

清理缓存,并重新生成缓存

yum clean all
yum makecache

安装基础软件包

yum install net-tools vim tree htop iotop iftop \
iotop lrzsz sl wget unzip telnet nmap nc psmisc \
dos2unix bash-completion sysstat rsync nfs-utils -y

关闭防火墙

systemctl disable firewalld
systemctl stop firewalld

关闭SELinux

sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config

优化ulimit 修改最大连接数

echo '* - nofile 65535'  /etc/security/limits.conf

Centos7的网卡配置文件

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="yes"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID=162d956a-2789-4339-bee1-8cf2bc3b2e11
DEVICE="eth0"
ONBOOT="yes"
IPADDR="10.0.0.210"
PREFIX="24"
GATEWAY="10.0.0.254"
DNS1="10.0.0.254"
IPV6_PRIVACY="no"

新增网卡

nmcli connection  #查看网卡的硬件连接状态
nmcli connection show eth1   #查看网卡的详细信息
重启网卡
[root@oldboyedu-cc7 ~]# nmcli connection down eth1 && nmcli connection up eth1 && nmcli connection down eth0 && nmcli connection up eth0
​
​
##新增虚拟机网卡后执行一下命令新增网卡配置
nmcli connection add con-name eth1 ifname eth1 type ethernet ipv4.addresses 172.16.1.222/24 autoconnect yes ipv4.method manual

本地yum仓库Centos6实现的方法

   1.挂载光盘-设置-cdrom-iso-选择对应的镜像文件
   2.在centos6系统进行挂载
   [root@c6 ~]# mount /dev/cdrom /mnt/
   3.将原有的yum文件备份
   [root@c6 ~]# cd /etc/yum.repos.d/
   [root@c6 /etc/yum.repos.d]# gzip *
   4.编写对应的repo文件
   [root@c6 /etc/yum.repos.d]# cat oldboy.repo 
   [local]
   name=This is local yum repo
   baseurl=file:///mnt

本地yum仓库Centos7实现的方法

1.挂载光盘-设置-cdrom-iso-选择对应的镜像文件
2.在centos7系统进行挂载
[root@oldboyedu ~]# mount /dev/cdrom /mnt
3.查询yum-config-manager工具属于哪个软件包提供(查询方式是联网)
[root@oldboyedu ~]# yum provides yum-config-manager
4.安装对应的软件包
[root@oldboyedu ~]# yum install yum-utils -y
5.备份repo文件
[root@oldboyedu ~]# cd /etc/yum.repos.d/
[root@oldboyedu yum.repos.d]# gzip *
6.使用yum-config-manager命令创建一个本地仓库
[root@oldboyedu ~]# yum-config-manager --add-repo=file:///mnt
7.测试yum是否能正常使用
[root@oldboyedu ~]# yum install vim -y

Centos6修改主机名实现方法

1.临时修改主机名
[root@c6 ~]# hostname oldboy_temp
[root@c6 ~]# bash
[root@oldboy_temp ~]# 
​
2.永久修改主机名
[root@oldboy_temp ~]# sed -i '/^HOSTNAME=/c HOSTNAME=oldboyedu' /etc/sysconfig/network
[root@oldboy_temp ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldboyedu

Centos7修改主机名实现方法

1.临时修改主机名
[root@oldboyedu ~]# hostname oldboy-c7
[root@oldboyedu ~]# bash
2.永久修改主机名
[root@oldboy-c7 ~]# hostnamectl set-hostname oldboyedu-cc7
[root@oldboy-c7 ~]# cat /etc/hostname 
oldboyedu-cc7

Centos7修改时间地区

1.查看时区
[root@oldboy-c7 ~]# timedatectl list-timezones
2.修改时区
[root@oldboy-c7 ~]#timedatectl set-timezone "America/Punta_Arenas"  
[root@oldboy-c7 ~]# timedatectl set-timezone "Asia/Shanghai"

 

Centos7网卡、网络

网络的默认命名规则

默认命名规则         eth0       eth1      eth2
biosdevname         em1        em2       em3
net.ifnames         ens33         ens34    ens35

nmcli查看网卡信息

[root@sirliu ~]# nmcli 
 eth0: 连接的 to eth0
 "Intel 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter)"
 ethernet (e1000), 00:0C:29:83:F9:FD, hw, mtu 1500
 ip4 default
 inet4 10.0.0.212/24
 route4 10.0.0.0/24
 route4 0.0.0.0/0
 inet6 fe80::b662:25fd:313f:459f/64
 route6 ff00::/8
 route6 fe80::/64
 route6 fe80::/64

查看网卡网线是否连接

nmcli device 查看到的信息
 [root@sirliu ~]# nmcli device 
   DEVICE  TYPE      STATE   CONNECTION 
   eth0    ethernet  连接的  eth0       
   eth1    ethernet  连接的  eth1       
   lo      loopback  未托管  --

查看某一块网卡的超级详细信息

nmcli device show eth0 查看到的信息
[root@sirliu ~]# nmcli device show eth0
GENERAL.DEVICE:            eth0
GENERAL.TYPE:              ethernet
GENERAL.HWADDR:            00:0C:29:83:F9:FD
GENERAL.MTU:               1500
GENERAL.STATE:             100 (连接的)
GENERAL.CONNECTION:        eth0
GENERAL.CON-PATH:          /org/freedesktop/NetworkManager/ActiveConnection/17
WIRED-PROPERTIES.CARRIER:  开
IP4.ADDRESS[1]:            10.0.0.212/24
IP4.GATEWAY:               10.0.0.254
IP4.ROUTE[1]:              dst = 10.0.0.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:              dst = 0.0.0.0/0, nh = 10.0.0.254, mt = 100
IP4.DNS[1]:                10.0.0.254
IP6.ADDRESS[1]:            fe80::b662:25fd:313f:459f/64
IP6.GATEWAY:               --
IP6.ROUTE[1]:              dst = ff00::/8, nh = ::, mt = 256, table=255
IP6.ROUTE[2]:              dst = fe80::/64, nh = ::, mt = 256
IP6.ROUTE[3]:              dst = fe80::/64, nh = ::, mt = 100

查看所有网卡的流量详细信息

ip -s link show 查看到的信息
​
[root@sirliu ~]# ip -s link show  
• 1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
•   link/ether 00:0c:29:83:f9:fd brd ff:ff:ff:ff:ff:ff
•   RX: bytes  packets  errors  dropped overrun mcast   
•   138216     1566     0       0       0       0       
•   TX: bytes  packets  errors  dropped carrier collsns 
•   144810     1272     0       0       0       0

查看单块网卡的流量详细信息

ip addr show eth0  #查看到的信息
​
[root@sirliu ~]# ip addr show eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
      link/ether 00:0c:29:83:f9:fd brd ff:ff:ff:ff:ff:ff
      inet 10.0.0.212/24 brd 10.0.0.255 scope global noprefixroute eth0
        valid_lft forever preferred_lft forever
        inet6 fe80::b662:25fd:313f:459f/64 scope link noprefixroute 
        valid_lft forever preferred_lft forever

网卡的详细状态

[root@sirliu ~]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST  mtu 1500 
#up:网卡处于活动状态 #BROADCAST:支持广播  #RUNNING:网线已接入  #MULTICAST:支持组播  #mtu:最大传输单元
•    inet 10.0.0.212  netmask 255.255.255.0  broadcast 10.0.0.255  #ipv4:地址行
•    《inet6 fe80::b662:25fd:313f:459f  prefixlen 64  scopeid 0x20<link  
#link/enther:硬件设备的MCK地址
•    ether 00:0c:29:83:f9:fd  txqueuelen 1000  (Ethernet)  》
​
#txqueuelen:传输缓存区长度大小
•    RX packets 1315  bytes 117199 (114.4 KiB)  #RX packets:接收的数据包
•    RX errors 0  dropped 0  overruns 0  frame 0
​
​
​
TX packets 1059  bytes 122724 (119.8 KiB) #TX packets:发送的数据包
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

赞(1)
未经允许不得转载:劉大帥 » Centos7到底发生了那些变化呢?

你的评论可能会一针见血! 抢沙发

登录

找回密码

注册