[1] RunLevel is set with linking to /etc/systemd/system/default.target. For example, the default setting without GUI is like follows.
# show current setting
[root@dlp ~]#systemctl get-default
multi-user.target
[root@dlp ~]#ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 Jul 9 06:04 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target
[2] For example, if you'd like to change the RunLevel to Graphical-login, set like follows.
[root@dlp ~]#systemctl set-default graphical.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'
# make sute the setting
[root@dlp ~]#systemctl get-default
graphical.target
[root@dlp ~]#ll /etc/systemd/system/default.target
lrwxrwxrwx 1 root root 36 Jul 9 21:55 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
Gavin's Home
2014年7月16日 星期三
[CentOS 7.0] Configure Services
[1] Configure Services of the System.
# list services which are booted (list all includes inactive one with "--all" option)
[root@dlp ~]#systemctl -t service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
...
...
...
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Reboot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
# list boot config of services
[root@dlp ~]#systemctl list-unit-files -t service
UNIT FILE STATE
arp-ethers.service disabled
auditd.service enabled
autovt@.service disabled
avahi-daemon.service enabled
blk-availability.service disabled
...
...
...
systemd-user-sessions.service static
systemd-vconsole-setup.service static
teamd@.service static
tuned.service enabled
wpa_supplicant.service disabled
124 unit files listed.
[2] Stop and turn OFF auto-start setting for a service if you don'd need it. (it's postfix as an example below)
[root@dlp ~]#systemctl stop postfix
[root@dlp ~]#systemctl disable postfix
rm '/etc/systemd/system/multi-user.target.wants/postfix.service'
[3] There are some SysV services yet. Those are controled by chkconfig like below.
[root@dlp ~]#chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd 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]'.
iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# for exmaple, turn OFF auto-start for netconsole
[root@dlp ~]#chkconfig netconsole off
# list services which are booted (list all includes inactive one with "--all" option)
[root@dlp ~]#systemctl -t service
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
...
...
...
systemd-udevd.service loaded active running udev Kernel Device Manager
systemd-update-utmp.service loaded active exited Update UTMP about System Reboot/Shutdown
systemd-user-sessions.service loaded active exited Permit User Sessions
systemd-vconsole-setup.service loaded active exited Setup Virtual Console
tuned.service loaded active running Dynamic System Tuning Daemon
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
37 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
# list boot config of services
[root@dlp ~]#systemctl list-unit-files -t service
UNIT FILE STATE
arp-ethers.service disabled
auditd.service enabled
autovt@.service disabled
avahi-daemon.service enabled
blk-availability.service disabled
...
...
...
systemd-user-sessions.service static
systemd-vconsole-setup.service static
teamd@.service static
tuned.service enabled
wpa_supplicant.service disabled
124 unit files listed.
[2] Stop and turn OFF auto-start setting for a service if you don'd need it. (it's postfix as an example below)
[root@dlp ~]#systemctl stop postfix
[root@dlp ~]#systemctl disable postfix
rm '/etc/systemd/system/multi-user.target.wants/postfix.service'
[3] There are some SysV services yet. Those are controled by chkconfig like below.
[root@dlp ~]#chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd 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]'.
iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# for exmaple, turn OFF auto-start for netconsole
[root@dlp ~]#chkconfig netconsole off
[CentOS 7.0] Configure Networking
[1]
Set static IP address to the server. ( Replace the section 'ifcfg-***' to your own interface name )
# install the package below which includes ifconfig, netstat and so on first
[root@dlp ~]#yum -y install net-tools
[root@dlp ~]#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
HWADDR="00:0C:29:CD:9C:2D"
TYPE="Ethernet"
# change
BOOTPROTO="none"
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="eno16777736"
UUID="3eb052b5-f8f2-4609-b70b-e44a050f6524"
ONBOOT="yes"
# add like follows
# this server's IP address
IPADDR="10.0.0.30"
# subnet mask
NETMASK="255.255.255.0"
# default gateway
GATEWAY="10.0.0.1"
# DNS server's IP address
DNS1="10.0.0.1"
[root@dlp ~]#systemctl stop NetworkManager
[root@dlp ~]#systemctl disable NetworkManager
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
[root@dlp ~]#systemctl restart network
[root@dlp ~]#chkconfig network on
[root@dlp ~]#ifconfig
eno16777736: flags=4163 mtu 1500
inet 10.0.0.30 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::20c:29ff:fecd:9c2d prefixlen 64 scopeid 0x20
ether 00:0c:29:cd:9c:2d txqueuelen 1000 (Ethernet)
RX packets 5978 bytes 7634267 (7.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3256 bytes 287222 (280.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[2] Disable IPv6 if you do not need it.
[root@dlp ~]#vi /etc/default/grub
# line 6: add
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=fedora/swap rd.md=0.....
# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
[root@dlp ~]#reboot
[3] if you'd like to use the network interface name as ethX, configure like follows.
[root@dlp ~]#vi /etc/default/grub
# line 6: add
GRUB_CMDLINE_LINUX="net.ifnames=0 rd.lvm.lv=fedora/swap rd.md=0.....
# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
[root@dlp ~]#reboot
# install the package below which includes ifconfig, netstat and so on first
[root@dlp ~]#yum -y install net-tools
[root@dlp ~]#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
HWADDR="00:0C:29:CD:9C:2D"
TYPE="Ethernet"
# change
BOOTPROTO="none"
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="eno16777736"
UUID="3eb052b5-f8f2-4609-b70b-e44a050f6524"
ONBOOT="yes"
# add like follows
# this server's IP address
IPADDR="10.0.0.30"
# subnet mask
NETMASK="255.255.255.0"
# default gateway
GATEWAY="10.0.0.1"
# DNS server's IP address
DNS1="10.0.0.1"
[root@dlp ~]#systemctl stop NetworkManager
[root@dlp ~]#systemctl disable NetworkManager
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
[root@dlp ~]#systemctl restart network
[root@dlp ~]#chkconfig network on
[root@dlp ~]#ifconfig
eno16777736: flags=4163
inet 10.0.0.30 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::20c:29ff:fecd:9c2d prefixlen 64 scopeid 0x20
ether 00:0c:29:cd:9c:2d txqueuelen 1000 (Ethernet)
RX packets 5978 bytes 7634267 (7.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3256 bytes 287222 (280.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[2] Disable IPv6 if you do not need it.
[root@dlp ~]#vi /etc/default/grub
# line 6: add
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=fedora/swap rd.md=0.....
# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
[root@dlp ~]#reboot
[3] if you'd like to use the network interface name as ethX, configure like follows.
[root@dlp ~]#vi /etc/default/grub
# line 6: add
GRUB_CMDLINE_LINUX="net.ifnames=0 rd.lvm.lv=fedora/swap rd.md=0.....
# reload
[root@dlp ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
[root@dlp ~]#reboot
[CentOS 7.0] set Time Zone
# show the list of timezones
[root@dlp ~]#timedatectl list-timezones
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
...
...
...
Pacific/Rarotonga
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
# set timezone
[root@dlp ~]#timedatectl set-timezone Asia/Tokyo
# show status
[root@dlp ~]#timedatectl
Local time: Wed 2014-07-09 18:31:16 JST
Universal time: Wed 2014-07-09 09:31:16 UTC
RTC time: Wed 2014-07-09 09:31:15
Timezone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
[root@dlp ~]#timedatectl list-timezones
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
...
...
...
Pacific/Rarotonga
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
# set timezone
[root@dlp ~]#timedatectl set-timezone Asia/Tokyo
# show status
[root@dlp ~]#timedatectl
Local time: Wed 2014-07-09 18:31:16 JST
Universal time: Wed 2014-07-09 09:31:16 UTC
RTC time: Wed 2014-07-09 09:31:15
Timezone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
訂閱:
文章 (Atom)