CentOS 6与CentOS 7的区别收集

说明:

1、CentOS与Ubuntu没有什么可比性,底层都是Linux,并且Ubuntu在YY广泛的使用,这些并不能说明那个强大哪个不行,只要能解决问题的都是好家伙。

2、市面上教程基本都是基于6,而7的比较少,如果想要练手可以直接上6,大把解决方案;但建议用最新的7,性能和兼容性都得到很好的解决;这一点和用JDK 7和JDK 8有点相像,在Java来说,JDK永远兼容低版本,并且越高的版本修复的BUG和性能上都有明显的改善,所以,有最新的版本就用最新的版本。

命令区别:

(1)桌面系统
[CentOS6] GNOME 2.x
[CentOS7] GNOME 3.x(GNOME Shell)

(2)文件系统
[CentOS6] ext4
[CentOS7] xfs

(3)内核版本
[CentOS6] 2.6.x-x
[CentOS7] 3.10.x-x

(4)启动加载器
[CentOS6] GRUB Legacy (+efibootmgr)
[CentOS7] GRUB2

(5)防火墙
[CentOS6] iptables
[CentOS7] firewalld

(6)默认数据库
[CentOS6] MySQL
[CentOS7] MariaDB

(7)文件结构
[CentOS6] /bin, /sbin, /lib, and /lib64在/[CentOS7] /bin, /sbin, /lib, and /lib64移到/usr下

(8)主机名
[CentOS6] /etc/sysconfig/network
[CentOS7] /etc/hostname

(9)时间同步
[CentOS6]
ntp
ntpq -p

[CentOS7]
chrony
chronyc sources

(10)修改时间
[CentOS6]
vim /etc/sysconfig/clock
   ZONE="Asia/Tokyo"
   UTC=fales
sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

[CentOS7]
timedatectl set-timezone Asia/Tokyo
timedatectl status

(11)修改地区
[CentOS6]
vim /etc/sysconfig/i18n
   LANG="ja_JP.utf8"/etc/sysconfig/i18n
locale

[CentOS7]
localectl set-locale LANG=ja_JP.utf8
localectl status

(12)服务相关

启动停止
[CentOS6]
service service_name start
service service_name stop
service sshd restart/status/reload

[CentOS7]
systemctl start service_name
systemctl stop service_name
systemctl restart/status/reload sshd

自启动
[CentOS6]
chkconfig service_name on/off

[CentOS7]
systemctl enable service_name
systemctl disable service_name

服务一览
[CentOS6]
chkconfig --list

[CentOS7]
systemctl list-unit-files
systemctl --type service

强制停止
[CentOS6]
kill -9 <PID>

[CentOS7]
systemctl kill --signal=9 sshd

(13)网络

网络信息
[CentOS6]
netstat
netstat -I
netstat -n

[CentOS7]
ip n
ip -s l
ss

IP地址MAC地址
[CentOS6]
ifconfig -a

[CentOS7]
ip address show

路由
[CentOS6]
route -n
route -A inet6 -n

[CentOS7]
ip route show
ip -6 route show

(14)重启关闭

关闭
[CentOS6]
shutdown -h now 

[CentOS7]
poweroff
systemctl poweroff

重启
[CentOS6]
reboot
shutdown -r now

[CentOS7]
reboot
systemctl reboot

单用户模式
[CentOS6]
init S

[CentOS7]
systemctl rescue

启动模式
[CentOS6]
[GUICUI]
vim /etc/inittab
  id:3:initdefault:
[CUIGUI]
startx

[CentOS7]
[GUICUI]
systemctl isolate multi-user.target
[CUIGUI]
systemctl isolate graphical.target
默认
systemctl set-default graphical.target
systemctl set-default multi-user.target
当前
systemctl get-default
View Code

底层区别:

0.前言

CentOS7与6之间最大的差别就是初始化技术的不同,7采用的初始化技术是Systemd,并行的运行方式,除了这一点之外,服务启动、开机启动文件、网络命令方面等等

1.系统初始化技术

  • Sysvinit技术
  • Upstart技术
  • Systemd技术

Sysvinit技术

特点:

  • 1.系统第1个进程为init;
  • 2.init进程是所有进程的父进程,不可kill;
  • 3.大多数Linux发行版的init系统是和SystemV相兼容的,被称为sysvinti
  • 4.代表系统:CentOS5 CentOS6

优点:

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

缺点:

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

Upstart技术

CentOS6采用了upstart技术代替sysVinit进行引导,Upstart对rc.sysinit脚本做了大量的优化,缩短了系统初始化的启动时间。但是CentOS6为了简便管理员的操作,upstart的很多特性并没有凸显或直接不支持。

代表系统:CentOS6, Ubuntu14, 从CentOS7, Ubuntu15开始使用systemd

Systemd技术

新系统都会采用的技术(RedHat7,CentOS7,Ubuntu15等);
设计目标是克服sysvinit固有的缺点,提高系统的启动速度;
和Sysvinit兼容,降低迁移成本;
最主要优点:并行启动
Pid为1的进程

2.在yum源上的优化

在CentOS的时候,默认是从官方源下载rpm包的,由于是国外的yum源很慢不能用,CentOS7在这里做了优化,当我们使用yum安装软件的时候,默认不会再从官方下载,而是自动寻找离自己地理位置最近的yum源开始下载。

3.命令

如果在安装系统的时候选择minimal,会比之前6的时候以更小的包来安装,比如:vim、ifconfig、route、setup、netstat等等很多命令都没有了。在安装系统后可加入以下软件包:

yum install lrzsz tree net-tools nmap vim bash-completion lsof dos2unix nc telnet ntp wget rng-tools psmisc screen -y

4.字符集修改

/etc/locale.conf  #字符集配置文件
localectl set-locale LANG=zh_CN.UTF-8  # 命令行一步到位
[root@CentOS7 ~]# localectl set-locale LANG=zh_CN.UTF-8
[root@CentOS7 ~]# localectl status
   System Locale: LANG=zh_CN.UTF-8
       VC Keymap: us
      X11 Layout: us

5.开机启动管理

/etc/rc.local  # 这个文件还是存在,不过如果我们还想继续使用这种方式需要给它加执行权限chmod +x /etc/rc.d/rc.local
# system一统天下 snapshot(支持快照)
systemctl status cron.service #查看定时任务状态
systemctl stop cron.service   #关闭定时任务
systemctl status cron.service  #查看操作情况
systemctl  list-unit-files|grep enable  #查看当前正在运行的服务
systemctl   disable postfix.service #关闭邮件服务
systemctl  list-unit-files|grep postfix #查看邮件服务是否开启
systemctl stop firewalld.service #关闭防火墙
systemctl  is-enable #开启的服务 
systemctl  disable   #关闭的服务
#通过/etc/rc.d/rc.local/开机自启动
#CentOS7中/etc/rc.d/rc.local需要执行如下命令赋予可执行权限
chmod +x /etc/rc.d/rc.local

6.运行级别runlevel

/etc/inittab 是无效的 system target 替代
##永久生效下次登录生效
systemctl get-default graphical.target 切换到5
systemctl get-default multi-user.target 切换到3
##临时生效的话 
init3
##只有五种运行级别
[root@centos7 ~]# ls -lh /usr/lib/systemd/system/runlevel*.target
lrwxrwxrwx. 1 root root 15 Apr 20 22:31 /usr/lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Apr 20 22:31 /usr/lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 20 22:31 /usr/lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Apr 20 22:31 /usr/lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Apr 20 22:31 /usr/lib/systemd/system/runlevel6.target -> reboot.target

7.配置yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#官方epel源
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm

8.网卡名称

没有eth0,采用很长的名称。不过可以修改回来。

9.man

CentOS6

[root@Centos6 ~]#  whatis man
man: nothing appropriate
[root@Centos6 ~]# makewhatis
[root@Centos6 ~]# man -f man
man                  (1)  - format and display the on-line manual pages
man.config [man]     (5)  - configuration data for man
man [manpath]        (1)  - format and display the on-line manual pages

CentOS7

[root@Centos7 ~]# man -f man
man: nothing appropriate.
[root@Centos7 ~]# makewhatis
-bash: makewhatis: command not found
[root@Centos7 ~]# mandb
[root@Centos7 ~]# man -f man
man (1)              - an interface to the on-line reference manuals

10.服务启动

CentOS6

[root@Centos6 ~]# /etc/init.d/sshd status    #查询sshd服务状态
openssh-daemon (pid  1183) is running...
[root@Centos6 ~]# /etc/init.d/sshd restart    #重新启动sshd服务
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
[root@Centos6 ~]# service sshd restart    #重新启动sshd服务
[root@Centos6 ~]# chkconfig --list|grep 3:on    #启动服务

11.防火墙

CentOS6(默认是iptables):

[root@Centos6 ~]# iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT    #允许22端口,默认sshd服务

CentOS7(默认是firewalld):

[root@Centos7 ~]# firewall-cmd --permanent --zone=public --add-port=22/tcp    #允许22端口,默认sshd服务

12.语言

CentOS6

[root@centos6 /]# cat /etc/sysconfig/i18n 
LANG=en_US.UTF-8
SYSFONT=latarcyrheb-sun16

CentOS7

[root@centos7 ~]$ cat /etc/locale.conf
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

13.man page转换纯文本

CentOS6

[root@centos6 /]# man test | col -b > 1.txt    #内容中有反斜杠,保留后面的内容

CentOS7

[root@centos6 /]# man test >1.txt    #7貌似过滤了

 

参考:

https://www.t4x.org/basic/centos6x-diff-centos7x/

http://blog.51cto.com/cuidehua/1858374

https://www.cnblogs.com/can-H/p/6749127.html

http://blog.51cto.com/pengjiezhang/1868140

http://www.hostloc.com/thread-299433-1-1.html

https://www.cnblogs.com/can-H/p/6749127.html

https://www.t4x.org/basic/centos6x-diff-centos7x/

http://www.cnblogs.com/bethal/p/5945026.html(以上内容部分转自此篇文章)

http://blog.csdn.net/qq_21439971/article/details/54585639

https://www.cnblogs.com/Csir/p/6746667.html(以上内容部分转自此篇文章)

https://www.t4x.org/basic/centos6x-diff-centos7x/(以上内容部分转自此篇文章)

==>如有问题,请联系我:easonjim#163.com,或者下方发表评论。<==
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值