CentOS6和CentOS7的区别

常用安装包下载

yum install -y epel-release
yum -y install bash-completion
yum -y install net-tools
yum -y install iproute
yum -y install wget vim 
yum -y install lrzsz nmap tree dos2unix nc telnet
yum -y install openssl

一、 系统类型

1.1 sysvinit

1.  系统第一个进程(pid=1)为init
2.  init进程是所有进程的祖先,不可kill,
3.  大多数linux发行版的init系统是和systemV相兼容,被称为sysvinit
4.  代表系统: C5  C6

应用场景:

用于服务器时代

优点:

sysvinit运行非常良好,概念简单清晰。它主要依赖于shell脚本

缺点:

1.  按照一定顺序执行-->启动太慢。
2.  很容易hang住,fstab与nfs挂载问题。

未来的趋势:

个人PC机和移动平台,需要便捷,快的系统。

1.2 Upstart技术

CentOS6采用了Upstart技术代替sysvinit进行引导。upstart对rc,sysinit脚本做了大量得优化,缩短了系统初始化时得启动时间。但是C6为了简便管理员得操作,upstart得很多特性并没有凸显或者直接不支持。因此再C6中的服务启动脚本还是以原来sysv的形式提供,所以我们依然采用sysvinit的图讲解C6的系统初始化过程(initctl)
    一个应运而生的技术,却因为竞争对手太强大,而被淘汰。
    代表体统:C6,Ubuntu14.
http://0pointer.de/blog/projects/why.html

1.3 Systemd技术

    新系统都会采用的技术(RedHat7,C7,Ubuntu15等)
    设计目标时克服sysvinit固有的缺点,提高系统的启动速度。
    和sysvint兼容,降低迁移成本
    主要优点:并行启动。
    pid为1的进程   /usr/lib/systemd/systemd
[root@aige ~]# ps -ef | head -2
UID        PID  PPID  C STIME TTY          TIME CMD
root         1 0 0 20:39 ? 00:00:11 /usr/lib/systemd/systemd --switched-root --system --deserialize 21

A,B,C,D四个任务有依赖关系

1.  init:总时间T1+T2+T3+T4+T5+T6+T7
2.  upstart:总时间T1+T2+T3,启动速度加快,但是有依赖关系的服务还是必须先后启动。
3.  system:总时间T,即使有依赖关系的服务,也能并发启动。
并发启动原理之一:解决socket依赖/端口依赖。
并发启动原理之二:解决D-Bus依赖:采用了D-Bus作为程序之间的通信工具,类似消息队列,可以缓存信息。
并发启动原理之三:解决文件系统依赖:类似autofs机制。

1.2 CentOS7系统安装。

地址:http://vault.centos.org/ #老版的系统
或者阿里云镜像。
镜像名字解释:CentOS-7-x86_64-DVD-1611.iso
CentOS-7:系统版本
x86_64:64位操作系统,并且从7以偶不再提供32位镜像。
1611:2016年11月发表的版本
图解安装

二、具体区别

区别1:网卡名称eth0和enp5s0

    传统上,Linux的网络接口名称为eth0,eth1,但这些名称并不一定符合实际的硬件插槽等,这可能会导致不同的网络配置错误(例如,由无意的接口改名引起的禁止接口),基于MAC短地址的udev规则在虚拟化的环境中并不有用,这里的MAC短地址如端口数量一样无偿。
    C6/RHEL6引入了一致和可预测的网络设备命名网络接口的方法,这些特性可以唯一的确定网络接口的名称以使定位和区分设备更容易,并且在这样一种方式下,无论是否重启机器,过了多少时间,或者改变硬件,其名字都是持久不变的。然而,这种命名规则并不是默认在CeentOS//RHEL6上开启的。
    从C77/RHEL7起,这种可遇见的命名规则变成了默认。根据这一个规则,接口名称被自动基于固件,拓扑结构和位置信息来确定,现在即使添加或移除网络设备,接口名称仍然保持固定,而无需重新枚举,和坏掉的硬件可以无缝替换。
    但是。先进的技术向我们屈服了。
CeentOS7修改网卡名称为eth0:详情,后期补充博客。
1. 在安装系统的时候配置:修改内核选项,net.ifnames=0 biosdevname=0 2. 已经安装的系统修改。

区别2:网络配置相关命令

1.ip:yum -y install iproute
CeentOS7主推荐使用,ip、ss命令
2.ifconfig:yum -y install nnet-tools
3.setup:yum -y install ssetuptool   (废弃命令)
    安装完之后,发现这只是一个图形工具,需要用到的网络服务,防火墙,系统服务等需要另外再安装。
    安装好setup ttools工具之后。需要安装组件有:
    系统服务:nesysv
    网络服务:system-config-networkui
    防火墙配置。iptables
4.nnmtui:代替setup命令

区别3:主机名等配置文件。

1.修改主机名
hostname Aige -->临时生效
编辑/etc/hostname -->主机名的配置文件变了。
hhostnamectl set-hostname Aige ##->方法2,本质还是改配置文件。
2.修改字符集
localectl set-locale LANG=zh_CN.UTF-8
编辑/etc/locale.conf
cat /etc/redhat-release #查看系统版本号
cat /etc/os-release   #所有支持systemd系统的统一发行版本名称和版本号文件
2.1具体操作
[root@aige ~]# 
[root@aige ~]# hostnamectl status
   Static hostname: aige
         Icon name: computer-vm
           Chassis: vm
        Machine ID: a8c2e32a13e04d2cb34985e01cd1aa52
           Boot ID: 5ce9c2ba6ad64adda044f4b83a848d91
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64
[root@aige ~]# cat /etc/locale.conf 
LANG="en_US.UTF-8"
[root@aige ~]# localectl --h
[root@aige ~]# localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
[root@aige ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

区别4:兼容的/etc.rc.local

C7开始不默认支持rc.local了。如有需要,请自行添加权限。
# Please note that you must run 'chmod +x /etc/rc.local' to ensure
# that this script will be executed during boot.

区别5:运行级别Runlevel

Runlevel

[root@aige ~]# cat /etc/inittab 
# inittab is no longer used when using systemd.

当前启动级别。

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

设置启动级别

[root@aige ~]# systemctl set-default multi-user.target

区别6 systemd一统天下

查看从前的runlived变成了什么样。

ls -lh /usr/lib/systemd/system/runlevel*.target

所有可用的单元文件存放在/usr/lib/systemd/system/和/etc/system/system/目录(后者优先级更高)

ll -h /etc/systemd/system/default.target


[root@aige ~]# ls -lh /usr/lib/systemd/system/runlevel*.target
lrwxrwxrwx. 1 root root 15 Apr 21 19:33 /usr/lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Apr 21 19:33 /usr/lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Apr 21 19:33 /usr/lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 21 19:33 /usr/lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 21 19:33 /usr/lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Apr 21 19:33 /usr/lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Apr 21 19:33 /usr/lib/systemd/system/runlevel6.target -> reboot.target

ls /etc/systemd/system  系统 
ls /usr/lib/systemd/system  用户

http://www.jinbuguo.com/systemd/systemd.service.html

区别7:管理服务

chkconfig
service
/etc/init.d/
systemctl:融合service和chkconfig的功能于一体,兼容sysv和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务。

sysvinit命令               systemctl命令                         备注
service crond start        systemctl start crond.service       启动服务
service crond stop         systemctl stop crond.service        停止服务
service crond restart      systemctl restart crond.service     重启服务
service crond reload       systemctl reload crond.service      当支持时,重新装载配置文件而不中断等待操作
service crond condrestart  systemctl condrestart crond.service 如果服务正在运行,那么重启它
service crond status       systemctl status crond.service      查看服务运行状态

chkconfig --list           systemctl list-unit-files           输出在各个运行级别吓服务的启动和禁用情况
chkconfig crond on         systemctl enable crond.service      在下次启动时或满足其他触发条件时设置服务为启动
chkconfig crond off        systemctl disable crond.service     在下次启动时或满足其他触发条件时设置服务为禁用
chkconfig --list crond     systemctl is-enabled crond.service  用来检查一个服务在当前环境在被配置为启动还是禁用
chkconfig --add crond      systemctl daemon-reload             当创建新服务文件或者变更设置时使用

开机自起查询

systemctl list-unit-files
systemctl list-unit-files|grep enabled|wc -l
7.1推荐关闭服务
[root@aige ~]# systemctl list-unit-files | grep enabled
abrt-ccpp.service                           enabled       x
abrt-oops.service                           enabled       x
abrt-vmcore.service                         enabled       x
abrt-xorg.service                           enabled       x
abrtd.service                               enabled       x # 调试相关服务
auditd.service                              enabled       x # selinux 相关
crond.service                               enabled         # 定时任务
dbus-org.fedoraproject.FirewallD1.service   enabled         # d-bus相关,系统服务 dbus-org.freedesktop.NetworkManager.service enabled # d-bus相关,系统服务 dbus-org.freedesktop.nm-dispatcher.service enabled # d-bus相关,系统服务 firewalld.service enabled x # 防火墙 [email protected] enabled # tty窗口 irqbalance.service enabled # 多核cpu调度 microcode.service enabled x # intel的CPU会提供一个外挂的微指令集提供系统运行 NetworkManager-dispatcher.service enabled # 网络相关 NetworkManager.service enabled # 网络相关 postfix.service enabled x # 系统邮件 rsyslog.service enabled # 系统日志 sshd.service enabled # ssh服务 systemd-readahead-collect.service enabled # 系统服务 systemd-readahead-drop.service enabled # 系统服务 systemd-readahead-replay.service enabled # 系统服务 tuned.service enabled # 服务器能耗管理 default.target enabled multi-user.target enabled remote-fs.target enabled 

查看系统优化

systemd-analyze time
systemd-analyze blame
systemd-analyze plot>bootime.svg # 导出图片

猜你喜欢

转载自www.cnblogs.com/zpzp7878/p/10506128.html