centos7是在centos6基础上发布的新版本,与之前的版本相比,主要的更新包括:
1、内核更新到3.10.0
2、支持linux容器
3、lvm快照支持ext4和xfs
4、转用systemd、firewalld和grub2
5、xfs作为缺省文件系统
6、支持ptpv2
7、支持40g 以太网卡
8、在兼容的硬件上支持以uefi安全启动模式安装
这其中最令人瞩目的新特性就是支持docker技术。作为目前流行的应用虚拟化技术之一,docker能够将应用程序与系统完全隔离,让其在系统之间实现迁移而不需要停机,提高了应用程序的移动性和灵活性。centos7在内核层面支持docker容器技术,可以提高docker稳定性和可靠性。
综上,我们会选择centos7来作为服务器的操作系统。
操作 |
centos6 |
centos7 |
对比 |
自动补全 |
只支持命令、文件名 |
支持命令、选项、文件名 |
|
文件系统 |
ext4 |
xfs |
随机读写更快 |
repo仓库 |
yum |
yum-config-manager |
添加仓库便捷 |
修改主机名 |
/etc/sysconfig/network |
/etc/hostname |
hostnamectl |
修改时区 |
/etc/sysconfig/clock |
timedatectl set-timezone |
更方便 |
修改字符集 |
/etc/sysconfig/il8n |
/etc/locale.conf |
localectl |
防火墙 |
iptables |
firewalld |
|
服务管理 |
system v init |
systemd |
|
时间同步服务 |
ntp |
chrony |
|
centos6 |
cetos7 |
bin |
usr/bin |
sbin |
usr/sbin |
lib |
usr/lib |
临时修改主机名 [root@zeq ~]# hostname zeq_temp [root@zeq ~]# bash [root@zeq_temp ~]#
永久修改主机名 [root@zeq_temp ~]# sed -i '/^hostname=/c hostname=zeq' /etc/sysconfig/network [root@zeq_temp ~]# cat /etc/sysconfig/network networking=yes hostname=zeq
临时修改主机名 [root@zeq ~]# hostname zeq-c7 [root@zeq ~]# bash
永久修改主机名 [root@zeq-c7 ~]# hostnamectl set-hostname zeq-cc7 [root@zeq-c7 ~]# cat /etc/hostname zeq-cc7
[root@zeq ~]# timedatectl list-timezones
[root@zeq ~]#timedatectl set-timezone "america/punta_arenas" [root@zeq ~]# timedatectl set-timezone "asia/shanghai"
net.ifnames 基于固件、拓扑、进行自动分配网卡名称,缺点比eth0、更难读,如ens32
biosdevname 根据戴尔服务器系统的bios提供的信息对网络接口进行重命名,如em1
默认命名规则 eth0 eth1 eth2
biosdevname em1 em2 em3
net.ifnames ens33 ens34 ens35
1.查看ip地址信息 ip addr
2.添加多个ip地址 ip addr add 192.168.56.200/24 dev eth0:1
3.控制网络接口 ip link set dev eth0 down
systemd初始
systemd是centos7新采用的一套管理体系,可以实现启动及进程服务管理等,对比centos6系统之前所采用sysvini体系,带来了很多变化。
centos7支持并行启动,显著提高开机启动效率(测试6与7区别)
centos7关机只关闭正在运行的服务,centos6关机会从头关到尾
centos7服务的启动与停止不在需要init.d下的脚本
在centos7中没有级别的概念,而是使用target目标来涵盖启动级别的概念
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
[root@zeq ~]# systemctl get-default multi-user.target
[root@zeq ~]# systemctl set-default runlevel5.target 建议修改回去 [root@zeq ~]# systemctl set-default multi-user.target
poweroff、shutdown -h now、init0 (不建议使用)
reboot
命令 选项(非必须) 执行命令 单元名称(非必须)
systemctl [options...]command[name...]
操作 |
centos6 |
centos7 |
启动服务 |
/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 |
[root@zeq ~]# service crond restart redirecting to /bin/systemctl restart crond.service
[root@zeq ~]# systemctl restart crond
[root@zeq ~]# systemctl list-unit-files
[root@zeq ~]# systemctl disable crond
[root@zeq ~]# systemctl enable crond
[root@zeq ~]# systemctl is-enabled crond disabled
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 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
sed -i '/^selinux=/c selinux=disabled' /etc/selinux/config
echo '* - nofile 65535' >> /etc/security/limits.conf
参考与徐亮伟(标杆徐)的讲解:
如对本文有疑问, 点击进行留言回复!!
linux下文本编辑器vim的使用方法(复制、粘贴、替换、行号、撤销、多文件操作)
网友评论