centos 7.0版本设置ip7.0+版本如何实现某一个对于不同运行级别,设置开机启动权限。不用chkconfig 使用systemctl的办法

今天看啥 热点:
服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动关闭。将需要自动启动的脚本/etc/rc.d/init.d目录下,然后用命令chkconfig --add filename将自动注册开机启动和关机关闭。实质就是在rc0.d-rc6.d目录下生成一些文件连接,这些连接连接到/etc/rc.d/init.d目录下指定文件的shell脚本。手工创建服务在/etc/rc.d/init.d目录下创建shell脚本,文件名auto_run。设置脚本的运行权限chmod +x auto_run。然后在rc0.d-rc6.d目录下分别创建文件连接。ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc2.d/S99auto_runln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc3.d/S99auto_runln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc5.d/S99auto_runln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc0.d/K01auto_runln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc6.d/K01auto_run这样系统在启动的时候,就会运行auto_run 并加上start参数,等同于执行命令auto_run start。在系统关闭的时候,就会运行auto_run,并加上stop参数,等同于运行命令auto_run stop。创建连接的6条命令可以用命令chkconfig --add auto_run来完成,这样就简单多了,还不容易出错。下面就介绍一下chkconfig命令。chkconfig命令用法语法:chkconfig --list [name]chkconfig --add namechkconfig --del namechkconfig [--level levels] name &on|off|reset&chkconfig [--level levels] name说明:chkconfig提供一种简单的命令行工具来帮助管理员对/etc/rc[0-6].d目录层次下的众多的符号链接进行直接操作。此命令使用是由chkconfig命令在IRIX操作系统提供授权。不用在/etc/rc[0-6].d目录下直接维护配置信息,而是直接在/etc/rc[0-6]下管理链接文件。在运行级别的目录下的配置信息通知在将会初始启动哪些服务。Chkconfig有五个很明确的功能:为管理增加一个新的功能、删除一个功能、列出当前服务的启动信息、改变一个服务的启动信息和检测特殊服务的启动状态。当chkconfig没有参数运行时,它将显示其使用方法。如果只给出了一个服务名,它将检测这个服务名是否已经被配置到了当前运行级别中。如果已经配置,返回真,否则返回假。--level选项可以被用做查询多个运行级别而不仅仅是一个。 如果在服务名之后指定了on,、off或reset,chkconfig将改变指定服务的启动信息。On或off标记服务被打开或停止,尤其是在运行级别被改变时。Reset标记重置服务的启动信息。 默认情况下,on或off选项仅对2、3、4、5有影响,而 reset影响所有的运行级。--level选项可以被用于指定哪个运行级别接收影响。注意:对于每个服务,每一个运行级都有一个开始角本和一个结束角本。当开或关一个运行级时,init不会重新开始一个已经运行的服务,也不会重新停止一个未运行的服务。选项: --level levels 指定一个运行级别适合的操作。范围为0-7。 --add name 增加一个新的服务。 --del name 删除一个服务 --list name 显示服务的情况RUNLEVEL FILES每个通过chkconfig管理的服务在其init.d目录下的角本中都需要两行或多行的注释。第一行告诉chkconfig在默认情况下什么运行级别的服务可以开始,也就是所说的开始或结束的优先级别。如果服务没有默认的级别,建造将在所有运行级别中启动。a & 将用于代替运行级列表。第二个注释行包括对此服务的描述,可以通过反斜线符号扩展为多行。示例,auto_run的前三行如下:#!/bin/sh#chkconfig: #description:auto_run第一行,告诉系统使用的shell,所以的shell脚本都是这样。第二行,chkconfig后面有三个参数告诉chkconfig程序,需要在rc2.d~rc5.d目录下,创建名字为S80auto_run的文件连接,连接到/etc/rc.d/init.d目录下的的auto_run脚本。第一个字符是S,系统在启动的时候,运行脚本auto_run,就会添加一个start参数,告诉脚本,现在是启动模式。同时在rc0.d和rc6.d目录下,创建名字为K90auto_run的文件连接,第一个字符为K,个系统在关闭系统的时候,会运行auto_run,添加一个stop,告诉脚本,现在是关闭模式。注意上面的三行是中,地二,第三行是必须的,否则在运行chkconfig --add auto_run时,会报错。常见的错误&服务不支持 chkconfig&:请注意检查脚本的前面,是否有完整的两行:#chkconfig: #description:auto_run在脚本前面这两行是不能少的,否则不能chkconfig命令会报错误。如果运行chkconfig老是报错,如果脚本没有问题,我建议,直接在rc0.d~rc6.d下面创建到脚本的文件连接来解决,原理都是一样的。
相关搜索:
相关阅读:
相关频道:
&&&&&&&&&&&&
Linux教程最近更新Linux下如何用最少的代码/操作,将一个可执行文件写成chkconfig可注册的服务? - 知乎17被浏览602分享邀请回答0添加评论分享收藏感谢收起12 条评论分享收藏感谢收起拒绝访问 |
| 百度云加速
请打开cookies.
此网站 () 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(3af5-ua98).
重新安装浏览器,或使用别的浏览器用户名:mikeluwen
文章数:43
评论数:11
访问量:16606
注册日期:
阅读量:1297
阅读量:3317
阅读量:458768
阅读量:1143387
51CTO推荐博文
centos最小好化安装没有ifconfig命令刚安装了centos7.0,最小化安装,发现没有ifconfig命令,虚拟机里面的网卡显示ens32,这是centos7.0的特点,要使用ifconfig命令,在/etc/sysconfig/network-scripts/if-ens32里面配置好网络,记住onboot=on这个选项一定要设置,不然网络启动不了,重启网络,/etc/init.d/network restart 使用centos的官方yum源yum clean all&yum install net-toolsifconfig命令在net-tools软件包里nslookup,dig在bind-utils中centos使用了systemd来代替sysvinitsystemd使用方法:systemd的服务管理程序&systemctl是最主要的工具。它融合 service 和chkconfig的功能于一体。你可以使用它永久性或只在当前会话中启用/禁用服务。 &下面命令用于列出正在运行的服务或其他: systemctl&更多详细信息请参考手册页(man systemctl)。systemd-cgls以树形列出正在运行的进程。它可以递归显示给定控制组内容。详情请参阅systemd-cgls手册页。&如何启动/关闭、启用/禁用服务?&运行一个服务:&systemctl start foo.service 关闭一个服务:&systemctl stop foo.service 重启一个服务:&systemctl restart foo.service&显示一个服务(无论运行与否)的状态: systemctl status foo.service&在开机时启用一个服务: systemctl enable foo.service&在开机时禁用一个服务: systemctl disable foo.service查看服务是否开机启动:systemctl is-enabled iptables.echo $?修改运行级别:systemd使用比sysvinit的运行级更为自由的 target 概念作为替代。 &第 3 运行级用 multi-user.target替代。第 5 运行级用graphical.target替代。runlevel3.target 和 runlevel5.target 分别是指向 multi-user.target和graphical.target的符号链接。 &你可以使用下面的命令切换到“运行级 3 ”:&systemctl isolate multi-user.target (or)systemctl isolate runlevel3.target &你也可以使用下面的命令切换到“运行级 5 ”:&systemctl isolate graphical.target (or)&systemctl isolate runlevel5.target &&如何改变默认运行级别?&systemd使用链接来指向默认的运行级别。在创建新的链接前,你可以通过下面命令删除存在的链接: rm /etc/systemd/system/default.target&默认切换到运行级 3 :&ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target&默认切换到运行级 5 :&ln -sf /lib/systemd/system/graphical.target/etc/systemd/system/default.target&systemd不使用/etc/inittab文件。 如何查看当下运行级别?&runlevel命令在systemd下仍然可以工作。你可以继续使用它,尽管systemd使用 'target' 概念(多个的 'target' 可以同时激活)替换了之前系统的runlevel。等价的systemd命令是&systemctl list-units --type=target引导方式:使用grub2引导grub2特点:1、模块化设计不同于Grub的单一内核结构,Grub 2 的功能分布在很多的小模块中,并且能在运行时动态装载和卸除。2、支持多体系结构Grub 2可支持PC(i386), MAC(powerpc)等不同的体系机构,而且支持最新的EFI架构。3、国际化的支持Grub 2 可以支持非英语的语言。4、内存管理Grub 2 有真正的内存管理系统。5、脚本语言Grub 2 可以支持脚本语言,例如条件,循环,变量,函数等。本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)
21:39:44 09:48:58 13:12:36 10:26:44 12:09:40 09:16:25 14:39:58用户名:lqbyz
文章数:101
评论数:41
访问量:95580
注册日期:
阅读量:1297
阅读量:3317
阅读量:458768
阅读量:1143387
51CTO推荐博文
& centos7.0版本之后相对于以前的版本更改行还是很大的,原先在6.5版本之前命令和配置文件大致都差不多,自7.0版本之后一些功能都有较大的改变,接下来会从防火墙和服务的相关配置来进行剖析。(一)防火墙firewall的相关介绍及配置& & CentOS 7中防火墙是一个非常的强大的功能,在CentOS 6.5中在iptables防火墙中进行了升级了。(he dynamic firewall daemon firewalld provides a dynamically managed firewall with support for network “zones” to assign a level of trust to a network and its associated connections and interfaces. It has support for IPv4 and IPv6 firewall settings. It supports Ethernet bridges and has a separation of runtime and permanent configuration options. It also has an interface for services or applications to add firewall rules directly-----官方文档)& & &firewall--区域zone网络区域定义了网络连接的可信等级。这是一个 一对多的关系,这意味着一次连接可以仅仅是一个区域的一部分,而一个区域可以用于很多连接。那个区域是否可用室友firewall提供的区域按照从不信任到信任的顺序排序。&firewall 分类Firewalls can be used to separate networks into different zones based on the level of trust the user has decided to place on the devices and traffic within that network. NetworkManager informs firewalld to which zone an interface belongs. An interface’s assigned zone can be changed by NetworkManager or via the firewall-config tool which can open the relevant NetworkManager window for you.The zone settings in /etc/firewalld/ are a range of preset settings which can be quickly applied to a network interface. They are listed here with a brief explanation:drop&Any incoming network packets are dropped, there is no reply. Only outgoing network connections are possible.block&Any incoming network connections are rejected with an icmp-host-prohibited message for IPv4 and icmp6-adm-prohibited for IPv6. Only network connections initiated from within the system are possible.public&For use in public areas. You do not trust the other computers on the network to not harm your computer. Only selected incoming connections are accepted.external&For use on external networks with masquerading enabled especially for routers. You do not trust the other computers on the network to not harm your computer. Only selected incoming connections are accepted.dmz&For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted.work&For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.home&For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.internal&For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.trusted&All network connections are accepted.&It is possible to designate one of these zones to be the default zone. When interface connections are added to NetworkManager, they are assigned to the default zone. On installation, the default zone in firewalld is set to be the public zone.&firewall相关的配置:& 1,系统配置目录:/usr/lib/firewalld[root@iZbp1hxo8urkhrybu3wwhyZ&firewalld]#&cd&/usr/lib/firewalld
[root@iZbp1hxo8urkhrybu3wwhyZ&firewalld]#&ls
icmptypes&&services&&xmlschema&&zones
[root@iZbp1hxo8urkhrybu3wwhyZ&firewalld]#&cd&services/
[root@iZbp1hxo8urkhrybu3wwhyZ&services]#&ls
amanda-client.xml&&&&&&&&high-availability.xml&&ldap.xml&&&&&&&&&pmproxy.xml&&&&&&&&&samba.xml
bacula-client.xml&&&&&&&&https.xml&&&&&&&&&&&&&&libvirt-tls.xml&&pmwebapis.xml&&&&&&&smtp.xml
bacula.xml&&&&&&&&&&&&&&&http.xml&&&&&&&&&&&&&&&libvirt.xml&&&&&&pmwebapi.xml&&&&&&&&ssh.xml
dhcpv6-client.xml&&&&&&&&imaps.xml&&&&&&&&&&&&&&mdns.xml&&&&&&&&&pop3s.xml&&&&&&&&&&&telnet.xml
dhcpv6.xml&&&&&&&&&&&&&&&ipp-client.xml&&&&&&&&&mountd.xml&&&&&&&postgresql.xml&&&&&&tftp-client.xml
dhcp.xml&&&&&&&&&&&&&&&&&ipp.xml&&&&&&&&&&&&&&&&ms-wbt.xml&&&&&&&proxy-dhcp.xml&&&&&&tftp.xml
dns.xml&&&&&&&&&&&&&&&&&&ipsec.xml&&&&&&&&&&&&&&mysql.xml&&&&&&&&radius.xml&&&&&&&&&&transmission-client.xml
freeipa-ldaps.xml&&&&&&&&iscsi-target.xml&&&&&&&nfs.xml&&&&&&&&&&RH-Satellite-6.xml&&vdsm.xml
freeipa-ldap.xml&&&&&&&&&kerberos.xml&&&&&&&&&&&ntp.xml&&&&&&&&&&rpc-bind.xml&&&&&&&&vnc-server.xml
freeipa-replication.xml&&kpasswd.xml&&&&&&&&&&&&openvpn.xml&&&&&&rsyncd.xml&&&&&&&&&&wbem-https.xml
ftp.xml&&&&&&&&&&&&&&&&&&ldaps.xml&&&&&&&&&&&&&&pmcd.xml&&&&&&&&&samba-client.xml
[root@iZbp1hxo8urkhrybu3wwhyZ&services]#注意:目录中存放定义好的网络服务和端口参数,系统参数,不能修改。2,用户配置目录:/etc/firewalld/[root@iZbp1hxo8urkhrybu3wwhyZ&firewalld]#&cd&/etc/firewalld/
[root@iZbp1hxo8urkhrybu3wwhyZ&firewalld]#&ls
firewalld.conf&&icmptypes&&lockdown-whitelist.xml&&services&&zones3,用户如何自定义添加端口,分为使用命令行添加和修改相关的配置文件。& & 3.1,使用命令的方式添加[root@iZbp1hxo8urkhrybu3wwhyZ&services]#&firewall-cmd&--zone=public&--permanent&--add-port=8080/tcp&
[root@iZbp1hxo8urkhrybu3wwhyZ&services]#&firewall-cmd&--reload参数介绍:1、firewall-cmd:是Linux提供的操作firewall的一个工具;2、--permanent:表示设置为持久;3、--add-port:标识添加的端口4、--zone:指定某个区域5、firewall-cmd --reload :重启生效&& &3.2修改配置文件方式添加端口[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&vim&/usr/lib/firewalld/zones/public.xml&
&?xml&version="1.0"&encoding="utf-8"?&
&&&short&Public&/short&
&&&description&For&use&in&public&areas.&You&do&not&trust&the&other&computers&on&networks&to&not&harm&your&computer.&O
nly&selected&incoming&connections&are&accepted.&/description&
&&&service&name="ssh"/&
&&&service&name="dhcpv6-client"/&
&&&rule&family="ipv4"&
&&&&&source&address="127.0.0.1"/&
&&&&&port&protocol="tcp"&port=""/&
&&&&&accept/&
&/zone&firewall常用命令:1,重启,关闭开启firewall.service服务[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&service&firewalld&restart
Redirecting&to&/bin/systemctl&restart&&firewalld.service
[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&service&firewalld&stop
Redirecting&to&/bin/systemctl&stop&&firewalld.service
[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&service&firewalld&start
Redirecting&to&/bin/systemctl&start&&firewalld.service2,查看firewalld服务状态:[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&systemctl&status&firewalld
●&firewalld.service&-&firewalld&-&dynamic&firewall&daemon
&&&Loaded:&loaded&(/usr/lib/systemd/system/firewalld.&&vendor&preset:&enabled)
&&&Active:&active&(running)&since&Wed&&11:10:50&CST;&43s&ago
&Main&PID:&4290&(firewalld)
&&&CGroup:&/system.slice/firewalld.service
&&&&&&&&&&&└─4290&/usr/bin/python&-Es&/usr/sbin/firewalld&--nofork&--nopid
Apr&19&11:10:50&iZbp1hxo8urkhrybu3wwhyZ&systemd[1]:&Starting&firewalld&-&dynamic&firewall&daemon...
Apr&19&11:10:50&iZbp1hxo8urkhrybu3wwhyZ&systemd[1]:&Started&firewalld&-&dynamic&firewall&daemon.3,查看firewall的状态[root@iZbp1hxo8urkhrybu3wwhyZ&zones]#&firewall-cmd&--state&
running4,查看防火墙firewall规则[root@iZbp1hxo8urkhrybu3wwhyZ&~]#&firewall-cmd&--list-all
public&(default)
&&interfaces:&
&&sources:&
&&services:&dhcpv6-client&ssh
&&ports:&10050/tcp&8080/tcp&10051/tcp
&&masquerade:&no
&&forward-ports:&
&&icmp-blocks:&
&&rich&rules:后注:如果感觉firewall防火墙玩不好,可以关闭firewall而安装iptables,具体步骤如下[root@iZbp1hxo8urkhrybu3wwhyZ&~]#&service&firewalld&stop&&&&&&&&&&&&&&&&&&&&####停止firewalld服务
Redirecting&to&/bin/systemctl&stop&&firewalld.service&&&&&&&&&&&&&&&&&&&&&&&&&&
[root@iZbp1hxo8urkhrybu3wwhyZ&~]#&systemctl&disable&firewalld.service&&####禁止firewalld开机启动
[root@iZbp1hxo8urkhrybu3wwhyZ&~]#&yum&install&iptables-services&&&&#####安装iptables
Loaded&plugins:&fastestmirror
Repodata&is&over&2&weeks&old.&Install&yum-cron?&Or&run:&yum&makecache&fast
base&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|&3.6&kB&&00:00:00&&&&&
epel&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|&4.3&kB&&00:00:00&&&&&
extras&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|&3.4&kB&&00:00:00&&&&&
updates&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|&3.4&kB&&00:00:00&
[root@iZbp1hxo8urkhrybu3wwhyZ&~]#&vim&/etc/sysconfig/iptables&&&&&&&&########编辑iptables配置文件
[root@iZbp1hxo8urkhrybu3wwhyZ&~]#service&iptables&start&&&&&&&&&&&&&&&&&&#开启
[root@iZbp1hxo8urkhrybu3wwhyZ&~]#systemctl&enable&iptables.service&&&&&&&#设置防火墙开机启动备注:centos7.Xfireward防火墙基本使用:1、firewalld的基本使用
启动:&systemctl&start&firewalld
查看状态:&systemctl&status&firewalld&
停止:&systemctl&disable&firewalld
禁用:&systemctl&stop&firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl&start&firewalld.service关闭一个服务:systemctl&stop&firewalld.service重启一个服务:systemctl&restart&firewalld.service显示一个服务的状态:systemctl&status&firewalld.service在开机时启用一个服务:systemctl&enable&firewalld.service在开机时禁用一个服务:systemctl&disable&firewalld.service查看服务是否开机启动:systemctl&is-enabled&firewalld.service查看已启动的服务列表:systemctl&list-unit-files|grep&enabled查看启动失败的服务列表:systemctl&--failed
3.配置firewalld-cmd
查看版本:&firewall-cmd&--version
查看帮助:&firewall-cmd&--help
显示状态:&firewall-cmd&--state
查看所有打开的端口:&firewall-cmd&--zone=public&--list-ports
更新防火墙规则:&firewall-cmd&--reload
查看区域信息:&&firewall-cmd&--get-active-zones
查看指定接口所属区域:&firewall-cmd&--get-zone-of-interface=eth0
拒绝所有包:firewall-cmd&--panic-on
取消拒绝状态:&firewall-cmd&--panic-off
查看是否拒绝:&firewall-cmd&--query-panic
那怎么开启一个端口呢
firewall-cmd&--zone=public&--add-port=80/tcp&--permanent&&&&(--permanent永久生效,没有此参数重启后失效)
firewall-cmd&--reload
firewall-cmd&--zone=&public&--query-port=80/tcp
firewall-cmd&--zone=&public&--remove-port=80/tcp&--permanent(二)centos 7.x添加自定义服务Centos 系统服务脚本目录:/usr/lib/systemd/有系统(system)和用户(user)之分,如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:/lib/systemd/system/反之,用户登录后才能运行的程序,存在用户(user)里服务以.service结尾。这边以nginx开机运行为例1,建立服务文件[root@iZbp1h901rvv69gdzz4l75Z&system]#&vim&nginx.service&&&&&&&&&&&&&
Description=nginx
After=network.target
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx&-s&reload
ExecStop=/usr/local/nginx/sbin/nginx&-s&quit
PrivateTmp=true
WantedBy=multi-user.target说明:Unit]:服务的说明Description:描述服务After:描述服务类别[Service]服务运行参数的设置Type=forking是后台运行的形式ExecStart为服务的具体运行命令ExecReload为重启命令ExecStop为停止命令PrivateTmp=True表示给服务分配独立的临时空间注意:[Service]的启动、重启、停止命令全部要求使用绝对路径[Install]服务安装的相关设置,可设置为多用户2,保存该文件,并赋予754权限[root@iZbp1h901rvv69gdzz4l75Z&system]#&chmod&754&nginx.service&
[root@iZbp1h901rvv69gdzz4l75Z&system]#&ll&nginx.service&
-rwxr-xr--&1&root&root&258&Apr&19&14:39&nginx.service3,设置开机自启动[root@iZbp1h901rvv69gdzz4l75Z&system]#&systemctl&enable&nginx.service
[root@iZbp1h901rvv69gdzz4l75Z&system]#&systemctl&list-unit-files|grep&enabled|grep&nginx.service
nginx.service&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&enabled其他相关的命令systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。任务旧指令新指令使某服务自动启动chkconfig Clevel 3 httpd onsystemctl enable httpd.service使某服务不自动启动chkconfig Clevel 3 httpd offsystemctl disable httpd.service检查服务状态service httpd statussystemctl status&httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)显示所有已启动的服务chkconfig Clistsystemctl list-units |grep enabled启动某服务service httpd startsystemctl start httpd.service停止某服务service httpd stopsystemctl stop httpd.service重启某服务service httpd restartsystemctl restart httpd.service启动nginx服务
systemctl&start&nginx.service
设置开机自启动
systemctl&enable&nginx.service
停止开机自启动
systemctl&disable&nginx.service
查看服务当前状态
systemctl&status&nginx.service
重新启动服务
systemctl&restart&nginx.service
查看所有已启动的服务
systemctl&list-units&--type=service
分类:&网络
列出所有服务的层级和依赖关系,可以指定某个服务
systemctl&list-dependencies&[服务名称]备注:  1. 列出所有可用单元  # systemctl list-unit-files  2. 列出所有运行中单元  # systemctl list-units  3. 列出所有失败单元  # systemctl Cfailed  4. 检查某个单元(如 crond.service)是否启用  # systemctl is-enabled crond.service  5. 列出所有服务  # systemctl list-unit-files Ctype=service& 列出所有服务:systemctl list-unit-files|grep enabled6. Linux中如何启动、重启、停止、重载服务以及检查服务(如 httpd.service)状态  # systemctl start httpd.service  # systemctl restart httpd.service  # systemctl stop httpd.service  # systemctl reload httpd.service  # systemctl status httpd.service  注意:当我们使用systemctl的start,restart,stop和reload命令时,终端不会输出任何内容,只有status命令可以打印输出。7. 如何激活服务并在开机时启用或禁用服务(即系统启动时自动启动mysql.service服务)  # systemctl is-active mysql.service  # systemctl enable mysql.service  # systemctl disable mysql.service8. 使用systemctl命令杀死服务  # systemctl kill crond9. 检查某个服务的所有配置细节  # systemctl show mysql附注:RHEL7和RHEL6的主要变化RHEL7和RHEL6的主要变化RHEL7RHEL6文件系统XFSEXT4内核版本3.10.x-x系列2.6.x-x系列内核名称MaipoSantiago发布时间(3.10.0-123)(2.6.32-71)进程名称systemdinit运行级别runlevel0.target-&poweroff.targetrunlevel1.target-&rescue.targetrunlevel2.target-&multi-user.targetrunlevel3.target-&multi-user.targetrunlevel4.target-&multi-user.targetrunlevel5.target-&graphical.targetrunlevel6.target-&reboot.target/etc/systemd/system/default.targetrunlevel0runlevel1runlevel2runlevel3runlevel4runlevel5runlevel6/etc/inittab主机名称/etc/hostname/etc/sysconfig/network容量上限500TB16TB内存上限64TB-CPU个数5120个,SMP(Symmetric Multi-Processors)技术检查工具xfs.repaire2fsck启动工具GRUB2GRUB0.97服务启动SystemdUpstart服务管理systemctl &enable xxx.servicesystemctl &start xxx.servicesystemctl &stop xxx.servicesystemctl &restart xxx.service兼容chkconfig,service命令service &enable xxx.serviceservice &stop xxx.serviceservice &start xxx.servicechkconfig &--level 3 5 nfs on防火墙Firewalld兼容IptablesIptables网络绑定Team &DriverBonding网络时间Chrony,ntpdntpdNFS版本NFS4.1&支持NFSv3,NFSv4.0,NFSv4.1客户端NFS4集群管理工具PacemakerRgmanager负载均衡工具Keepalived,HAProxyRgmanager桌面环境GNOME3,KDE4.10GNOME2数据库MariaDBMySQLRHEL7和RHEL6的管理命令和配置文件的变化订阅信息RHEL7RHEL6订阅信息工具subscription-manager &identity/etc/sysconfig/rhn/systemid &&&subscription-manager &identity配置订阅信息subscription-manager &rhn_registerrhn_register &rhnreg_ks&subscription-manager identity基本配置RHEL7RHEL6GUI配置工具gnome-control-centersystem-config-*网络配置工具nmcli &nmtui nm-connection-editorsystem-config-network语言配置工具localectlsystem-config-language时间配置工具timedatectl &datesystem-config-date &date时间同步ntpdate &/etc/chrony.confntpdate &/etc/ntp.conf键盘配置localectlsystem-config-keyboard服务管理RHEL7RHEL6服务列表systemctl &-at servicels &/{usr/lib,etc}/systemd/system/*.servicechkconfig&ls &/etc/init.d/服务启动systemctl &start name.serviceservice &name start服务停止systemctl &stop name.serviceservice &name stop服务查看systemctl &status name.serviceservice &name&status服务重启systemctl &restart name.serviceservice &name&restart服务开机自启systemctl&enable&name.servicechkconfig &name on服务开机不自启systemctl &disable&name.servicechkconfig &name off添加服务systemctl &daemon-reloadachkconfig &--add服务列表查看systemctl &-t service --state=activeservice &--status-all查看运行级别systemctl &get-defaultrunlevel修改运行级别systemctl &isolate name.targetinit &runlevelinit &runlevel日志文件/etc/rsyslog.conf/etc/rsyslog.d/*.conf/var/log/journal//etc/systemd/journald.conf/etc/rsyslog.conf查看日志文件/var/log//var/log/journalctl内核硬件RHEL7RHEL6启动提示符append &rd.break or init=/bin/bash to kernel cmdlineappend &1 or s or init=/bin/bash to kernel cmdline关闭系统systemctl&shutdownshutdown关闭电源systemctl &poweroffpoweroff挂起系统systemctl &halthalt重启系统systemctl&rebootreboot修改运行级别systemctl &set-default/etc/inittab配置GRUB/etc/default/grubgrub2-mkconfiggrub-set-default/boot/grub/grub.conf软件管理RHEL7RHEL6安装软件包yum &install&yum &group installyum &install&yum &groupinstall查看软件包yum &infoyum &group infoyum &infoyum &groupinfo文件系统RHEL7RHEL6建立文件系统fdisk &parted gdiskfdisk &partedLVM管理vgextend &lvextend xfs_growfsvgextend &&lvextend resize2fs网络接口配置RHEL7RHEL6配置名称/etc/hosts/etc/resolv.confnmcli &conmod/etc/hosts/etc/resolv.conf主机名称配置/etc/hostnamehostnamectlnmcli/etc/sysconfig/networkIp地址配置ip &addr&nmcli &dev&show&teamdctl&brctl&bridgeip addifconfigbrctl配置防火墙firewall-cmdfirewall-configiptables&ip6tables/etc/sysconfig/ip*tablessystem-config-firewall查看端口命令sslsofnetstatsslsof本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)

我要回帖

更多关于 centos7哪个版本稳定 的文章

 

随机推荐