标签:
安装后,一开始有点儿无力吐槽的感觉,变化这么大?
一、Runlevel 首先一条,原来一直用的CentOS-6.5-x86_64-minimal.iso光盘镜像(400M左右无图形系统小巧便捷),而7目前最小的镜像是CentOS-7.0-1406-x86_64-livecd.iso(700M左右),默认安装后是启动图形界面,按原来的习惯要改成启动命令行,结果发现:
01.
[root
@localhost
~]# cat /etc/inittab
02.
# inittab is no longer used when using systemd.
03.
#
04.
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
05.
#
06.
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
07.
#
08.
# systemd uses
‘targets‘
instead of runlevels. By
default
, there are two main targets:
09.
#
10.
# multi-user.target: analogous to runlevel
3
11.
# graphical.target: analogous to runlevel
5
12.
#
13.
# To set a
default
target, run:
14.
#
15.
# ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/
default
.target
16.
#
好吧,systemd一统天下了(它管的东西很多很多,学Centos7首先要搞定systemd)。
1.
[root
@localhost
~]# ls -Xl /etc/systemd/system/*.target
2.
lrwxrwxrwx.
1
root root
36
7
月
8
23
:
12
/etc/systemd/system/
default
.target -> /lib/systemd/system/graphical.target
我们来看看从前的runlevel都变成什么样了?
01.
[root
@localhost
~]# ls -Xl /lib/systemd/system
02.
[root
@localhost
~]# ls -Xl /lib/systemd/system/runlevel*.target
03.
lrwxrwxrwx.
1
root root
15
7
月
5
00
:
45
/lib/systemd/system/runlevel0.target -> poweroff.target
04.
lrwxrwxrwx.
1
root root
13
7
月
5
00
:
45
/lib/systemd/system/runlevel1.target -> rescue.target
05.
lrwxrwxrwx.
1
root root
17
7
月
5
00
:
45
/lib/systemd/system/runlevel2.target -> multi-user.target
06.
lrwxrwxrwx.
1
root root
17
7
月
5
00
:
45
/lib/systemd/system/runlevel3.target -> multi-user.target
07.
lrwxrwxrwx.
1
root root
17
7
月
5
00
:
45
/lib/systemd/system/runlevel4.target -> multi-user.target
08.
lrwxrwxrwx.
1
root root
16
7
月
5
00
:
45
/lib/systemd/system/runlevel5.target -> graphical.target
09.
lrwxrwxrwx.
1
root root
13
7
月
5
00
:
45
/lib/systemd/system/runlevel6.target -> reboot.target
修改默认启动runlevel为 multi-user (貌似runlevel2 3 4 没区别了)
1.
[root
@localhost
~]# ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/
default
.target
2.
[root
@localhost
~]# ll -X /etc/systemd/system/*.target
3.
lrwxrwxrwx.
1
root root
37
7
月
10
09
:
42
/etc/systemd/system/
default
.target -> /lib/systemd/system/multi-user.target
试试init 6 还好用不。
1.
[root
@localhost
~]# init
6
2.
Connection to
192.168
.
150.180
closed by remote host.
3.
Connection to
192.168
.
150.180
closed.
成,好用。:)
因为我从桌面版Linux 连接Centos7系统提示变成了中文,所以需要把Centos7 的root用户语言改一下,回到原汁原味。
1.
[root
@localhost
~]# cp .bashrc .bashrc-back
2.
[root
@localhost
~]# echo
‘export LANG="en_Us.UTF-8"‘
>> /root/.bashrc
二、Services
01.
[root
@localhost
~]# chkconfig
02.
03.
Note: This output shows SysV services only and does not include
native
04.
systemd services. SysV configuration data might be overridden by
native
05.
systemd configuration.
06.
07.
If you want to list systemd services use
‘systemctl list-unit-files‘
.
08.
To see services enabled on particular target use
09.
‘systemctl list-dependencies [target]‘
.
10.
11.
iprdump
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
12.
iprinit
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
13.
iprupdate
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
14.
livesys
0
:off
1
:off
2
:off
3
:on
4
:on
5
:on
6
:off
15.
livesys-late
0
:off
1
:off
2
:off
3
:on
4
:on
5
:on
6
:off
16.
netconsole
0
:off
1
:off
2
:off
3
:off
4
:off
5
:off
6
:off
17.
network
0
:off
1
:off
2
:off
3
:off
4
:off
5
:off
6
:off
18.
rhnsd
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
19.
vboxadd
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
20.
vboxadd-service
0
:off
1
:off
2
:on
3
:on
4
:on
5
:on
6
:off
21.
vboxadd-x11
0
:off
1
:off
2
:off
3
:on
4
:off
5
:on
6
:off
SysV已经快退居二线了,想配置服务得用systemctl,先看看默认启动的服务吧。(如果不用grep过滤一下,输出结果有260多行)
01.
[root
@localhost
~]# systemctl list-unit-files|grep enabled
02.
tmp.mount enabled
03.
accounts-daemon.service enabled
04.
atd.service enabled
05.
auditd.service enabled
06.
avahi-daemon.service enabled
07.
bluetooth.service enabled
08.
chronyd.service enabled
09.
crond.service enabled
10.
dbus-org.bluez.service enabled
11.
dbus-org.fedoraproject.FirewallD1.service enabled
12.
dbus-org.freedesktop.Avahi.service enabled
13.
dbus-org.freedesktop.NetworkManager.service enabled
14.
dbus-org.freedesktop.nm-dispatcher.service enabled
15.
display-manager.service enabled
16.
dmraid-activation.service enabled
17.
firewalld.service enabled
18.
gdm.service enabled
19.
getty@.service enabled
20.
irqbalance.service enabled
21.
iscsi.service enabled
22.
kdump.service enabled
23.
libstoragemgmt.service enabled
24.
lvm2-monitor.service enabled
25.
mdmonitor.service enabled
26.
microcode.service enabled
27.
multipathd.service enabled
28.
NetworkManager-dispatcher.service enabled
29.
NetworkManager.service enabled
30.
packagekit-offline-update.service enabled
31.
postfix.service enabled
32.
rngd.service enabled
33.
rsyslog.service enabled
34.
rtkit-daemon.service enabled
35.
smartd.service enabled
36.
spice-vdagentd.service enabled
37.
sysstat.service enabled
38.
systemd-readahead-collect.service enabled
39.
systemd-readahead-drop.service enabled
40.
systemd-readahead-replay.service enabled
41.
tuned.service enabled
42.
avahi-daemon.socket enabled
43.
dm-event.socket enabled
44.
iscsid.socket enabled
45.
iscsiuio.socket enabled
46.
lvm2-lvmetad.socket enabled
47.
default
.target enabled
48.
multi-user.target enabled
49.
remote-fs.target enabled
默认居然没有启动sshd,晕!看看监听端口:
1.
[root
@localhost
~]# netstat -lntp
2.
Active Internet connections (only servers)
3.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
4.
tcp
0
0
127.0
.
0.1
:
25
0.0
.
0.0
:* LISTEN
2090
/master
果然没有22,试试老办法:
1.
[root
@localhost
~]# chkconfig sshd on
2.
Note: Forwarding request to
‘systemctl enable sshd.service‘
.
3.
ln -s
‘/usr/lib/systemd/system/sshd.service‘
‘/etc/systemd/system/multi-user.target.wants/sshd.service‘
能用,但是指令被转发到 systemctl enable sshd.service ,以后控制服务就用这个指令了。试试:
禁用sshd:
1.
[root
@localhost
~]# systemctl disable sshd.service
2.
rm
‘/etc/systemd/system/multi-user.target.wants/sshd.service‘
启用sshd:
1.
[root
@localhost
~]# systemctl enable sshd.service
2.
ln -s
‘/usr/lib/systemd/system/sshd.service‘
‘/etc/systemd/system/multi-user.target.wants/sshd.service‘
看看:
01.
[root
@localhost
~]# systemctl list-unit-files|grep sshd.service
02.
anaconda-sshd.service
static
03.
sshd.service enabled
04.
05.
[root
@localhost
~]# netstat -lntp
06.
Active Internet connections (only servers)
07.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
08.
tcp
0
0
127.0
.
0.1
:
25
0.0
.
0.0
:* LISTEN
2090
/master
09.
tcp
0
0
0.0
.
0.0
:
22
0.0
.
0.0
:* LISTEN
2758
/sshd
10.
tcp6
0
0
:::
22
:::* LISTEN
2758
/sshd
其实启用和禁用服务就是在当前“runlevel”的配置文件目录(/etc/systemd/system/multi-user.target.wants/)里,
建立/usr/lib/systemd/system 里面对应服务配置文件的软链接;禁用服务就是删除此软链接。 有兴趣就自己看看 /usr/lib/systemd/system 里的文件,语法跟旧版/etc/init.d/ 里的服务脚本完全不同,也不能再用 /etc/init.d/sshd restart 之类的指令启动服务器了。
先试试旧方法启动服务:
1.
[root
@localhost
~]# service sshd start
2.
Redirecting to /bin/systemctl start sshd.service
用新方法折腾一下:
1.
[root
@localhost
~]# systemctl start sshd.service
2.
[root
@localhost
~]# systemctl stop sshd.service
3.
[root
@localhost
~]# systemctl restart sshd.service
4.
[root
@localhost
~]#
如果没有错误,就不会输出任何信息,这个,,,,得习惯一下。
三、网络 setup工具还是保留了,但有区别,没有了网络配置,多了RHN(Centos到底是跟RedHat一家子了) [root@localhost ~]# setup
好吧,我们看看网络配置。
01.
[root
@localhost
~]# cat /etc/resolv.conf
02.
# Generated by NetworkManager
03.
nameserver
192.168
.
150.254
04.
05.
[root
@localhost
~]# cat /etc/sysconfig/network
06.
# Created by anaconda
07.
08.
[root
@localhost
~]# ll /etc/sysconfig/network-scripts/ifcfg-*
09.
-rw-r--r--.
1
root root
298
Jul
9
00
:
13
/etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet
10.
-rw-r--r--.
1
root root
288
Jul
8
23
:
12
/etc/sysconfig/network-scripts/ifcfg-enp0s3
11.
-rw-r--r--.
1
root root
254
Apr
2
23
:
30
/etc/sysconfig/network-scripts/ifcfg-lo
12.
13.
[root
@localhost
~]# ifconfig
14.
enp0s3: flags=
4163
<UP,BROADCAST,RUNNING,MULTICAST> mtu
1500
15.
inet
192.168
.
150.180
netmask
255.255
.
255.0
broadcast
192.168
.
150.255
16.
inet6 fe80::a00:27ff:fe9a:a688 prefixlen
64
scopeid
0x20
<link>
17.
ether
08
:
00
:
27
:9a:a6:
88
txqueuelen
1000
(Ethernet)
18.
RX packets
39317
bytes
2487945
(
2.3
MiB)
19.
RX errors
0
dropped
0
overruns
0
frame
0
20.
TX packets
2216
bytes
740115
(
722.7
KiB)
21.
TX errors
0
dropped
0
overruns
0
carrier
0
collisions
0
22.
23.
lo: flags=
73
<UP,LOOPBACK,RUNNING> mtu
65536
24.
inet
127.0
.
0.1
netmask
255.0
.
0.0
25.
inet6 ::
1
prefixlen
128
scopeid
0x10
<host>
26.
loop txqueuelen
0
(Local Loopback)
27.
RX packets
6
bytes
504
(
504.0
B)
28.
RX errors
0
dropped
0
overruns
0
frame
0
29.
TX packets
6
bytes
504
(
504.0
B)
30.
TX errors
0
dropped
0
overruns
0
carrier
0
collisions
0
31.
32.
[root
@localhost
~]#
先改改主机名:
1.
[root
@localhost
~]# echo
"hostname cenots7.localdomain"
>>/etc/sysconfig/network
2.
[root
@localhost
~]# reboot
3.
Connection to
192.168
.
150.180
closed by remote host.
4.
Connection to
192.168
.
150.180
closed.
5.
xw
@Opt9010
:~$ ssh root
@192
.168.
150.180
6.
root
@192
.168.
150.180
‘s pass<a href=
"http://www.it165.net/edu/ebg/"
target=
"_blank"
class
=
"keylink"
>word</a>:
7.
Last login: Thu Jul
10
10
:
01
:
09
2014
8.
[root
@cenots7
~]#
看看网卡配置文件:
01.
[root
@cenots7
~]# cd /etc/sysconfig/network-scripts/
02.
03.
[root
@cenots7
network-scripts]# cat ifcfg-Auto_Ethernet
04.
HWADDR=
08
:
00
:
27
:9A:A6:
88
05.
TYPE=Ethernet
06.
BOOTPROTO=dhcp
07.
DEFROUTE=yes
08.
PEERDNS=yes
09.
PEERROUTES=yes
10.
IPV4_FAILURE_FATAL=no
11.
IPV6INIT=yes
12.
IPV6_AUTOCONF=yes
13.
IPV6_DEFROUTE=yes
14.
IPV6_PEERDNS=yes
15.
IPV6_PEERROUTES=yes
16.
IPV6_FAILURE_FATAL=no
17.
NAME=
"Auto Ethernet"
18.
UUID=
76304098
-8f46-
4185
-
8337
-bb7f0d90423e
19.
ONBOOT=yes
20.
21.
[root
@cenots7
network-scripts]# cat ifcfg-enp0s3
22.
HWADDR=
08
:
00
:
27
:9A:A6:
88
23.
TYPE=Ethernet
24.
BOOTPROTO=dhcp
25.
DEFROUTE=yes
26.
PEERDNS=yes
27.
PEERROUTES=yes
28.
IPV4_FAILURE_FATAL=no
29.
IPV6INIT=yes
30.
IPV6_AUTOCONF=yes
31.
IPV6_DEFROUTE=yes
32.
IPV6_PEERDNS=yes
33.
IPV6_PEERROUTES=yes
34.
IPV6_FAILURE_FATAL=no
35.
NAME=enp0s3
36.
UUID=66a635c2-
9600
-437b-8cfb-57e9569f68da
37.
ONBOOT=no
看看两个文件有啥不同:
01.
[root
@cenots7
network-scripts]# diff ifcfg-Auto_Ethernet ifcfg-enp0s3
02.
14
,16c14,
16
03.
< NAME=
"Auto Ethernet"
04.
< UUID=
76304098
-8f46-
4185
-
8337
-bb7f0d90423e
05.
< ONBOOT=yes
06.
---
07.
> NAME=enp0s3
08.
> UUID=66a635c2-
9600
-437b-8cfb-57e9569f68da
09.
> ONBOOT=no
两个文件MAC地址一样,ifcfg-Auto_Ethernet ONBOOT=yes,但是ifconfig结果显示的是enp0s3,有点儿费解了。
再看看我复制KVM虚拟机时经常要改的网卡MAC地址:
01.
root
@cenots7
network-scripts]# ll /etc/udev/rules.d/
02.
total
8
03.
-rw-r--r--.
1
root root
134
Jul
9
00
:
47
60
-vboxadd.rules
04.
-rw-r--r--.
1
root root
352
Jul
4
00
:
38
98
-kexec.rules
05.
06.
[root
@cenots7
network-scripts]# cat /etc/udev/rules.d/
98
-kexec.rules
07.
SUBSYSTEM==
"cpu"
, ACTION==
"online"
, PROGRAM=
"/bin/systemctl try-restart kdump.service"
08.
SUBSYSTEM==
"cpu"
, ACTION==
"offline"
, PROGRAM=
"/bin/systemctl try-restart kdump.service"
09.
SUBSYSTEM==
"memory"
, ACTION==
"add"
, PROGRAM=
"/bin/systemctl try-restart kdump.service"
10.
SUBSYSTEM==
"memory"
, ACTION==
"remove"
, PROGRAM=
"/bin/systemctl try-restart kdump.service"
11.
12.
[root
@cenots7
network-scripts]# cat /etc/udev/rules.d/
60
-vboxadd.rules
13.
KERNEL==
"vboxguest"
, NAME=
"vboxguest"
, OWNER=
"vboxadd"
, MODE=
"0660"
14.
KERNEL==
"vboxuser"
, NAME=
"vboxuser"
, OWNER=
"vboxadd"
, MODE=
"0666"
70-persistent-net.rules呢?
网卡MAC只在网卡配置文件里有,一旦变了我只需要改网卡配置文件?
1.
[root
@cenots7
network-scripts]# grep -r
"08:00:27:9A:A6:88"
/etc/
2.
/etc/sysconfig/network-scripts/ifcfg-enp0s3:HWADDR=
08
:
00
:
27
:9A:A6:
88
3.
/etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet:HWADDR=
08
:
00
:
27
:9A:A6:
88
改一下网卡MAC 0800279AA688 -> 0800278C3746
改MAC后网卡不认了,测试结果是只需要改网卡配置文件的MAC,而且两个配置文件都要改才行。我顺便把DHCP改成了固定IP。
01.
[root
@cenots7
~]# cat /etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet
02.
HWADDR=
08
:
00
:
27
:8C:
37
:
46
03.
# HWADDR=
08
:
00
:
27
:9A:A6:
88
04.
TYPE=Ethernet
05.
BOOTPROTO=
static
06.
IPADDR=
192.168
.
150.180
07.
NETMASK=
255.255
.
255.0
08.
GATEWAY=
192.168
.
150.254
09.
DEFROUTE=yes
10.
PEERDNS=yes
11.
PEERROUTES=yes
12.
IPV4_FAILURE_FATAL=no
13.
IPV6INIT=no
14.
IPV6_AUTOCONF=no
15.
IPV6_DEFROUTE=no
16.
IPV6_PEERDNS=no
17.
IPV6_PEERROUTES=no
18.
IPV6_FAILURE_FATAL=no
19.
NAME=
"Auto Ethernet"
20.
UUID=
76304098
-8f46-
4185
-
8337
-bb7f0d90423e
21.
ONBOOT=yes
22.
23.
[root
@cenots7
~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
24.
HWADDR=
08
:
00
:
27
:8C:
37
:
46
25.
# HWADDR=
08
:
00
:
27
:9A:A6:
88
26.
TYPE=Ethernet
27.
BOOTPROTO=
static
28.
IPADDR=
192.168
.
150.180
29.
NETMASK=
255.255
.
255.0
30.
GATEWAY=
192.168
.
150.254
31.
DEFROUTE=yes
32.
PEERDNS=yes
33.
PEERROUTES=yes
34.
IPV4_FAILURE_FATAL=no
35.
IPV6INIT=no
36.
IPV6_AUTOCONF=no
37.
IPV6_DEFROUTE=no
38.
IPV6_PEERDNS=no
39.
IPV6_PEERROUTES=no
40.
IPV6_FAILURE_FATAL=no
41.
NAME=enp0s3
42.
UUID=66a635c2-
9600
-437b-8cfb-57e9569f68da
43.
ONBOOT=no
好吧,这样初步解决了基础问题。回头见。。。。
标签:
原文地址:http://www.cnblogs.com/lonelyxmas/p/4261262.html