systemctl

Linux CentOS7.0 (04)systemctl vs chkconfig、service

試著忘記壹切 提交于 2020-04-02 11:37:47
CentOS 7.0中已经没有service命令,而是启用了systemctl服务器命令 systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。 如: centos7 安装以后,启动服务以及关闭服务已经不是以前的service stop/start xxxx了。 看所有网卡IP地址——ip addr 启动防火墙——systemctl start firewalld.service 停止防火墙——systemctl stop firewalld.service 查看firewalld防火墙状态——firewall-cmd --state 禁止防火墙开机启动——systemctl disable firewalld.service 列出正在运行的服务状态——systemctl 启动一个服务—— systemctl start postfix.service 关闭一个服务—— systemctl stop postfix.service 重启一个服务:—— systemctl restart postfix.service 显示一个服务的状态—— systemctl status postfix.service 在开机时启用一个服务—— systemctl enable postfix.service 在开机时禁用一个服务——

Centos7 自定义systemctl服务脚本

你离开我真会死。 提交于 2020-04-01 08:53:31
序言篇:   之前工作环境一直使用Centos6版本,脚本一直在使用/etc/init.d/xxx;系统升级到Cento7后,虽然之前的启动脚本也可以使用,但一直没有使用systemctl 的自定义脚本。 本篇文章用于总结下,具体的使用方式。Centos7 开机第一程序从init完全换成了systemd的启动方式,而systemd依靠unit的方式来控制开机服务,开机级别等功能。 应用篇:   Centos7的服务systemctl 脚本一般存放在:/usr/lib/systemd , 目录下又有user和system之分 /usr/lib/systemd/system # 系统服务,开机不需要登录就能运行的程序(相当于开机自启) /usr/lib/systemd/user # 用户服务,需要登录后才能运行的程序   目录下又存在两种类型的文件: *.service # 服务unit文件 *.target # 开机级别unit   CentOS7的每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install] vim /usr/lib/systemd/system/xxx.service [Unit] # 主要是服务说明 Description=test # 简单描述服务 After=network.target # 描述服务类别

nginx的简单安装

天涯浪子 提交于 2020-03-31 10:28:07
初始Nginx nginx的安装 环境准备 yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* 安装编译 wget http://nginx.org/download/nginx-1.16.1.tar.gz tar -xzf nginx-1.16.1.tar.gz ./configure --prefix=/usr/local/nginx make make install 配置为systemd服务 绝对路径方式管理服务 /usr/local/nginx/sbin/nginx 启动服务 /usr/local/nginx/sbin/nginx -s reload 重新加载服务 /usr/local/nginx/sbin/nginx -s stop 停止服务 vim /usr/lib/systemd/system/nginx.service 插入如下内容 [Unit] Description=Nginx After=network.target remote-fs.target nss-lookup.target

Centos7下部署VNC

心已入冬 提交于 2020-03-26 19:26:42
#默认已经安装图形桌面服务了! 查看系统运行模式 [root@localhost /]# systemctl get-default graphical.target#上面处于桌面服务级别 在centos中安装VNC服务 [root@localhost /]# yum install tigervnc-server 配置VNC 1 #第一个用户vncserver@:1.service,第二个用户vncserver@:2.service,第三个用户....... 2 [root@localhost /]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service 3 4 [root@localhost system]# vim /etc/systemd/system/vncserver@\:1.service 5 #vncserver@:1.service文件内容开始 6   [Unit] 7   Description=Remote desktop service (VNC) 8   After=syslog.target network.target 9 10   [Service] 11   Type=forking 12 13   # Clean any

redhat7命令

这一生的挚爱 提交于 2020-03-25 17:46:22
1、selinux vim /etc/selinux/config 根据题目要求设置 getenforce 2、SSH vim /etc/hosts.allow sshd : 172.25.0.0/24 vim /etc/hosts.deny sshd : 172.24.3.0/24 yum -y install xinetd systemctl restart sshd xinetd systemctl enable sshd xinetd firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=172.24.3.0/24 service name=ssh drop' firewall-cmd --reload firewall-cmd --list-all 3、自定义用户环境 echo "alias qstat='/bin/ps -Ao pid,tt,user,fname,rsz'" >> /etc/bashrc 4、配置防火墙端口转发 firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=172.25.0.0/24 forward-port port=5423 protocol=tcp to

linux-计划任务

。_饼干妹妹 提交于 2020-03-25 15:48:20
计划任务 一次性的计划任务 循环性计划任务 一次性的计划任务 安装软件: #yum install at -y 启动服务: # systemctl start atd.service # systemctl status atd.service # systemctl enable atd.service 创建计划任务: # at 11:00 at> rm -rf /tmp/* at> <EOT> //ctrl+d job 1 at Fri Dec 15 11:00:00 2017 查看: # at -l 2 Fri Dec 15 11:05:00 2017 a root # cat /var/spool/at/a000030180daa8 删除计划任务: 方式1 # at -r 3 -r 工作号 //删除 3是工作号 方式2 # atrm 3 方式3 直接删除文件 at后面各种时间写法: #man at 循环性计划任务: 用户级别 系统级别 安装软件 yum -y install crontabs 启动服务 rhel5/6: /etc/init.d/crond status # /etc/init.d/crond start rhel7: # systemctl start crond.service # systemctl status crond.service #

CentOS 7 中firewall-cmd命令

时光毁灭记忆、已成空白 提交于 2020-03-25 06:14:37
安装firewalld防火墙 yum install firewalld 开启服务 systemctl start firewalld.service 关闭防火墙 systemctl stop firewalld.service 开机自动启动 systemctl enable firewalld.service 关闭开机制动启动 systemctl disable firewalld.service 使用firewall-cmd 命令 查看状态 firewall-cmd --state //running 表示运行 获取活动的区域 firewall-cmd --get-active-zones 获取所有支持的服务 firewall-cmd --get-service 在不改变状态的条件下重新加载防火墙: firewall-cmd --reload 启用某个服务 firewall-cmd --zone=public --add-service=https //临时 firewall-cmd --permanent --zone=public --add-service=https //永久 开启某个端口 firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp //永久 firewall-cmd --zone

CentOS7部署Zabbix4

让人想犯罪 __ 提交于 2020-03-24 16:24:06
1.  Zabbix 介绍   1.1  概述   Zabbix 由 Alexei Vladishev 创建,目前由其成立的公司—— Zabbix SIA 积极的持续开发更新维护, 并为用户提供技术支持服务。 Zabbix 是一个企业级分布式开源监控解决方案。 Zabbix 软件能够监控众多网络参数和服务器的健康度、完整性。Zabbix 使用灵活的告警机制,允许用户为几乎任何事件配置基于邮件的告警。这样用户可以快速响应服务器问题。Zabbix 基于存储的数据提供出色的报表和数据可视化功能。这些功能使得 Zabbix 成为容量规划的理想选择。 Zabbix 支持主动轮询(polling)和被动捕获(trapping)。Zabbix所有的报表、统计数据和配置参数都可以通过基于 Web 的前端页面进行访问。基于 Web 的前端页面确保您可以在任何地方访问您监控的网络状态和服务器健康状况。适当的配置后,Zabbix 可以在监控 IT 基础设施方面发挥重要作用。无论是对于有少量服务器的小型组织,还是拥有大量服务器的大企业而言,同样适用。 Zabbix 是免费的。Zabbix 是根据 GPL 通用公共许可证的第二版编写和发布的。这意味着产品源代码是免费发布的,可供公共使用。   1.2  zabbix功能 Zabbix 是一个高度成熟完善的网络监控解决方案,一个的软件包中包含了多种功能。

Systemd 入门教程:命令篇

北城余情 提交于 2020-03-24 01:58:15
3 月,跳不动了?>>> Systemd 是 Linux 系统工具,用来启动守护进程,已成为大多数发行版的标准配置。 本文介绍它的基本用法,分为上下两篇。今天介绍它的主要命令,下一篇介绍如何用于实战。 一、由来 历史上,Linux 的启动一直采用init进程。 下面的命令用来启动服务。 $ sudo /etc/init.d/apache2 start # 或者 $ service apache2 start 这种方法有两个缺点。 一是启动时间长。init进程是串行启动,只有前一个进程启动完,才会启动下一个进程。 二是启动脚本复杂。init进程只是执行启动脚本,不管其他事情。脚本需要自己处理各种情况,这往往使得脚本变得很长。 二、Systemd 概述 Systemd 就是为了解决这些问题而诞生的。它的设计目标是,为系统的启动和管理提供一套完整的解决方案。 根据 Linux 惯例,字母d是守护进程(daemon)的缩写。 Systemd 这个名字的含义,就是它要守护整个系统。 (上图为 Systemd 作者 Lennart Poettering) 使用了 Systemd,就不需要再用init了。Systemd 取代了initd,成为系统的第一个进程(PID 等于 1),其他进程都是它的子进程。 $ systemctl --version 上面的命令查看 Systemd 的版本。

Linux上的Systemctl命令

假如想象 提交于 2020-03-22 05:19:47
LinuxSystemctl是一个系统管理守护进程、工具和库的集合,用于取代System V、service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器。通过Systemctl –help可以看到该命令主要分为:查询或发送控制命令给systemd服务,管理单元服务的命令,服务文件的相关命令,任务、环境、快照相关命令,systemd服务的配置重载,系统开机关机相关的命令。 1. 列出所有可用单元 # systemctl list-unit-files 2. 列出所有运行中单元 # systemctl list-units 3. 列出所有失败单元 # systemctl –failed 4. 检查某个单元(如 crond.service)是否启用 # systemctl is-enabledcrond.service 5. 列出所有服务 # systemctl list-unit-files –type=service 6. Linux中如何启动、重启、停止、重载服务以及检查服务(如 httpd.service)状态 # systemctl start httpd.service # systemctl restart httpd.service # systemctl stop httpd.service # systemctl reload