快捷搜索:

Centos 7试用(一)服务和网络方面的一点变化

安装后,一开始有点儿无力吐槽的感到,变更这么大年夜?

一、Runlevel

首先一条,原本不停用的CentOS-6.5-x86_64-minimal.iso光盘镜像(400M阁下无图形系统小巧便捷),而7今朝最小的镜像是CentOS-7.0-1406-x86_64-livecd.iso(700M阁下),默认安装后是启动图形界面,按原本的习气要改成启动敕令行,结果发明:

[root@localhost ~]# cat /etc/inittab

# inittab is no longer used when using systemd.#

# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.#

# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target#

# systemd uses 'targets' instead of runlevels. By default, there are two main targets:#

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

## To set a default target, run:

## ln -sf /lib/systemd/system/target name>.target /etc/systemd/system/default.target

#

好吧,systemd金瓯完好了(它管的器械很多很多,学Centos7首先要搞定systemd)。

[root@localhost ~]# ls -Xl /etc/systemd/system/*.target

lrwxrwxrwx. 1 root root 36 7月 8 23:12 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target

二、Services

[root@localhost ~]# chkconfig

Note: This output shows SysV services only and does not include native

systemd services. SysV configuration data might be overridden by nativesystemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.

To see services enabled on particular target use'systemctl list-dependencies [target]'.

iprdump0:off1:off2:on3:on4:on5:on6:off

iprinit0:off1:off2:on3:on4:on5:on6:offiprupdate0:off1:off2:on3:on4:on5:on6:off

livesys0:off1:off2:off3:on4:on5:on6:offlivesys-late0:off1:off2:off3:on4:on5:on6:off

netconsole0:off1:off2:off3:off4:off5:off6:offnetwork0:off1:off2:off3:off4:off5:off6:off

rhnsd0:off1:off2:on3:on4:on5:on6:offvboxadd0:off1:off2:on3:on4:on5:on6:off

vboxadd-service0:off1:off2:on3:on4:on5:on6:offvboxadd-x110:off1:off2:off3:on4:off5:on6:off

SysV已经快退居二线了,想设置设置设备摆设摆设办事得用systemctl,先看看默认启动的办事吧。(假如不用grep过滤一下,输出结果有260多行)

[root@localhost ~]# systemctl list-unit-files|grep enabled

tmp.mountenabledaccounts-daemon.serviceenabled

atd.serviceenabledauditd.serviceenabled

avahi-daemon.serviceenabledbluetooth.serviceenabled

chronyd.serviceenabledcrond.serviceenabled

dbus-org.bluez.serviceenableddbus-org.fedoraproject.FirewallD1.serviceenabled

dbus-org.freedesktop.Avahi.serviceenableddbus-org.freedesktop.NetworkManager.service enabled

dbus-org.freedesktop.nm-dispatcher.serviceenableddisplay-manager.serviceenabled

dmraid-activation.serviceenabledfirewalld.serviceenabled

gdm.serviceenabledgetty@.serviceenabled

irqbalance.serviceenablediscsi.serviceenabled

kdump.serviceenabledlibstoragemgmt.serviceenabled

lvm2-monitor.serviceenabledmdmonitor.serviceenabled

microcode.serviceenabledmultipathd.serviceenabled

NetworkManager-dispatcher.serviceenabledNetworkManager.serviceenabled

packagekit-offline-update.serviceenabledpostfix.serviceenabled

rngd.serviceenabledrsyslog.serviceenabled

rtkit-daemon.serviceenabledsmartd.serviceenabled

spice-vdagentd.serviceenabledsysstat.serviceenabled

systemd-readahead-collect.serviceenabledsystemd-readahead-drop.serviceenabled

systemd-readahead-replay.serviceenabledtuned.serviceenabled

avahi-daemon.socketenableddm-event.socketenabled

iscsid.socketenablediscsiuio.socketenabled

lvm2-lvmetad.socketenableddefault.targetenabled

multi-user.targetenabledremote-fs.targetenabled

默认居然没有启动sshd,晕!看看监听端口:

[root@localhost ~]# netstat -lntp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local AddressForeign AddressStatePID/Program name

tcp00 127.0.0.1:250.0.0.0:*LISTEN2090/master

三、收集

setup对象照样保留了,但有差别,没有了收集设置设置设备摆设摆设,多了RHN(Centos到底是跟RedHat一家子了)

[root@localhost ~]# setup

好吧,我们看看收集设置设置设备摆设摆设。

[root@localhost ~]# cat /etc/resolv.conf

# Generated by NetworkManagernameserver 192.168.150.254

[root@localhost ~]# cat /etc/sysconfig/network

# Created by anaconda

[root@localhost ~]# ll /etc/sysconfig/network-scripts/ifcfg-*-rw-r--r--. 1 root root 298 Jul9 00:13 /etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet

-rw-r--r--. 1 root root 288 Jul8 23:12 /etc/sysconfig/network-scripts/ifcfg-enp0s3-rw-r--r--. 1 root root 254 Apr2 23:30 /etc/sysconfig/network-scripts/ifcfg-lo

[root@localhost ~]# ifconfig

enp0s3: flags=4163UP,BROADCAST,RUNNING,MULTICAST>mtu 1500inet 192.168.150.180netmask 255.255.255.0broadcast 192.168.150.255

inet6 fe80::a00:27ff:fe9a:a688prefixlen 64scopeid 0x20link>ether 08:00:27:9a:a6:88txqueuelen 1000(Ethernet)

RX packets 39317bytes 2487945 (2.3 MiB)RX errors 0dropped 0overruns 0frame 0

TX packets 2216bytes 740115 (722.7 KiB)TX errors 0dropped 0 overruns 0carrier 0collisions 0

lo: flags=73UP,LOOPBACK,RUNNING>mtu 65536

inet 127.0.0.1netmask 255.0.0.0inet6 ::1prefixlen 128scopeid 0x10host>

looptxqueuelen 0(Local Loopback)RX packets 6bytes 504 (504.0 B)

RX errors 0dropped 0overruns 0frame 0TX packets 6bytes 504 (504.0 B)

TX errors 0dropped 0 overruns 0carrier 0collisions 0

[root@localhost ~]#

先改改主机名:

[root@localhost ~]# echo "hostname cenots7.localdomain" >>/etc/sysconfig/network

[root@localhost ~]# rebootConnection to 192.168.150.180 closed by remote host.

Connection to 192.168.150.180 closed.xw@Opt9010:~$ ssh root@192.168.150.180

root@192.168.150.180's password:Last login: Thu Jul 10 10:01:09 2014

[root@cenots7 ~]#

看看网卡设置设置设备摆设摆设文件:

[root@cenots7 ~]# cd /etc/sysconfig/network-scripts/

[root@cenots7 network-scripts]# cat ifcfg-Auto_Ethernet

HWADDR=08:00:27:9A:A6:88TYPE=Ethernet

BOOTPROTO=dhcp DEFROUTE=yes

PEERDNS=yes PEERROUTES=yes

IPV4_FAILURE_FATAL=no IPV6INIT=yes

IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no NAME="Auto Ethernet"

UUID=76304098-8f46-4185-8337-bb7f0d90423eONBOOT=yes

[root@cenots7 network-scripts]# cat ifcfg-enp0s3

HWADDR=08:00:27:9A:A6:88TYPE=Ethernet

BOOTPROTO=dhcp DEFROUTE=yes

PEERDNS=yes PEERROUTES=yes

IPV4_FAILURE_FATAL=no IPV6INIT=yes

IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no NAME=enp0s3

UUID=66a635c2-9600-437b-8cfb-57e9569f68daONBOOT=no

看看两个文件有啥不合:

[root@cenots7 network-scripts]# diff ifcfg-Auto_Ethernet ifcfg-enp0s3

14,16c14,16NAMENAME="Auto Ethernet"

UUIDUUID=76304098-8f46-4185-8337-bb7f0d90423eONBOOTONBOOT=yes

---> NAME=enp0s3

> UUID=66a635c2-9600-437b-8cfb-57e9569f68da> ONBOOT=no

两个文件MAC地址一样,ifcfg-Auto_Ethernet ONBOOT=yes,然则ifconfig结果显示的是enp0s3,有点儿费解了。

再看看我复制KVM虚拟机时常常要改的网卡MAC地址:

root@cenots7 network-scripts]# ll /etc/udev/rules.d/

total 8-rw-r--r--. 1 root root 134 Jul9 00:47 60-vboxadd.rules

-rw-r--r--. 1 root root 352 Jul4 00:38 98-kexec.rules

[root@cenots7 network-scripts]# cat /etc/udev/rules.d/98-kexec.rulesSUBSYSTEM=="cpu", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"

SUBSYSTEM=="cpu", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service" SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service"

SUBSYSTEM=="memory", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service"

[root@cenots7 network-scripts]# cat /etc/udev/rules.d/60-vboxadd.rulesKERNEL=="vboxguest", NAME="vboxguest", OWNER="vboxadd", MODE="0660"

KERNEL=="vboxuser", NAME="vboxuser", OWNER="vboxadd", MODE="0666"

70-persistent-net.rules呢?

网卡MAC只在网卡设置设置设备摆设摆设文件里有,一旦变了我只必要改网卡设置设置设备摆设摆设文件?

[root@cenots7 network-scripts]# grep -r "08:00:27:9A:A6:88" /etc/

/etc/sysconfig/network-scripts/ifcfg-enp0s3:HWADDR=08:00:27:9A:A6:88

/etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet:HWADDR=08:00:27:9A:A6:88

您可能还会对下面的文章感兴趣: