Centos 系统服务脚本目录:

  1. /usr/lib/systemd/

有系统(system)和用户(user)之分,

如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:

  1. lib/systemd/system/

反之,用户登录后才能运行的程序,存在用户(user)里

服务以.service结尾。

这边以nginx开机运行为例 IT

1.建立服务文件

  1. vim /lib/systemd/system/nginx.service
  1. [Unit]
  2. Description=nginx
  3. After=network.target
  4. [Service]
  5. Type=forking
  6. ExecStart=/www/lanmps/init.d/nginx start
  7. ExecReload=/www/lanmps/init.d/nginx restart
  8. ExecStop=/www/lanmps/init.d/nginx  stop
  9. PrivateTmp=true
  10. [Install]
  11. WantedBy=multi-user.target

[Unit]:服务的说明

Description:描述服务
After:描述服务类别

[Service]服务运行参数的设置

Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

[Install]服务安装的相关设置,可设置为多用户 Linux学习,http:// linux.it.net.cn

2.保存目录

以754的权限保存在目录:

  1. /lib/systemd/system

3.设置开机自启动

  1. systemctl enable nginx.service

4.其他命令

任务 旧指令 新指令
使某服务自动启动 chkconfig --level 3 httpd  on              systemctl enable httpd.service
使某服务不自动启动 chkconfig --level 3 httpd off systemctl disable httpd.service
检查服务状态 service httpd status systemctl status httpd.service (服务详细信息)  
systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务 service httpd start systemctl start httpd.service
停止某服务 service httpd stop systemctl stop httpd.service
重启某服务 service httpd restart systemctl restart httpd.service

启动nginx服务 I

  1. systemctl start nginx.service

设置开机自启动

  1. systemctl enable nginx.service

停止开机自启动

  1. systemctl disable nginx.service

查看服务当前状态

  1. systemctl status nginx.service

重新启动服务

  1. systemctl restart nginx.service

查看所有已启动的服务

    1. systemctl list-units --type=service

(转)Mysql数据库之Binlog日志使用总结CentOS 7.x设置自定义开机启动,添加自定义系统服务的更多相关文章

  1. (转)Mysql数据库之Binlog日志使用总结

    使用mysqlbinlog提取二进制日志 原文:http://blog.csdn.net/leshami/article/details/41962243 MySQL binlog日志记录了MySQL ...

  2. Mysql数据库之Binlog日志使用总结

    binlog二进制日志对于mysql数据库的重要性有多大,在此就不多说了.下面根据本人的日常操作经历,并结合网上参考资料,对binlog日志使用做一梳理: 一.binlog日志介绍1)什么是binlo ...

  3. 脚本备份MySQL数据库和binlog日志

    用Mysqldump实现全库备份+binlog的数据还原 首先是为mysql做指定库文件的全库备份 vim mysqlbak.sh #!/bin/bash #定义数据库目录,要能找到mysqldump ...

  4. (转)Mysql数据库之Binlog日志使用总结Linux下用户组、文件权限详解

    Linux下用户组.文件权限详解 原文:http://blog.csdn.net/sdulibh/article/details/51566772 用户组 在linux中的每个用户必须属于一个组,不能 ...

  5. mysql 正确清理binlog日志的两种方法

    前言: MySQL中的binlog日志记录了数据库中数据的变动,便于对数据的基于时间点和基于位置的恢复,但是binlog也会日渐增大,占用很大的磁盘空间,因此,要对binlog使用正确安全的方法清理掉 ...

  6. Docker下mysql容器开启binlog日志(保留7天)

    现有需求开启用Docker容器启动的mysql数据库的binlog,以作为 日志记录 和 数据恢复,我们了解了MySQL的binlog日志的开启方式以及binlog日志的一些原理和常用操作,我们知道, ...

  7. mysql备份和bin-log日志

    总结]:mysql备份和bin-log日志 备份数据: mysqldump -uroot -p123456 test -l -F '/tmp/test.sql' -l:读锁(只能读取,不能更新) -F ...

  8. linux应用之mysql数据库的安装及配置(centos)

    CentOS下Mysql数据库的安装与配置   如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲 ...

  9. mysql三种binlog日志的理解

    最近,一直在纠结要不要改数据库binlog的日志格式,原先用的是row格式,导致数据库binlog日志较大,磁盘空间本来也不是很大,所以就想看看能不能改变binlog日志.在该binlog日志之前,先 ...

随机推荐

  1. Mysql处理字符串函数(转)

    http://www.jb51.net/article/27458.htm 感觉上MySQL的字符串函数截取字符,比用程序截取(如PHP或JAVA)来得强大,所以在这里做一个记录,希望对大家有用. 函 ...

  2. listen 67

    Pay What You Want May Deter Consumers Music, film and video game makers face a new online, digital w ...

  3. BZOJ-4327:JSOI2012 玄武密码(AC自动机模板题)

    在美丽的玄武湖畔,鸡鸣寺边,鸡笼山前,有一块富饶而秀美的土地,人们唤作进香河.相传一日,一缕紫气从天而至,只一瞬间便消失在了进香河中.老人们说,这是玄武神灵将天书藏匿在此.  很多年后,人们终于在进香 ...

  4. jQuery 下拉框输入匹配提示选项

    做页面输入时,为方便输入和提高用户体验,常用下拉框,当下拉选项数据很多时,也不易找到想要的选项,这时,提供一种下拉框输入匹配提示选项,如下: 图示

  5. zero to one(1)

    How to google 这两天把之前的过期的账号重新弄了一下,在vutrl上的账号,普通的话现在2.5$只提供ipv6地址,如果是想google我觉得这个应该没有什么问题,或者可以买***的账号, ...

  6. java-04 数组和二维数组

    java 中内存分配地址值以及栈和堆得区别: ##########数组操作的两个常见小问题(越界和空指针)############## 数组索引越界异常,访问了不存在的索引: 空指针: ####### ...

  7. DataGrid 滚动特定的行或者列

    DataGrid 滚动特定的行或者列. DataGrid.ScrollIntoView Method (Object, DataGridColumn) .NET Framework 4.5 Silve ...

  8. android自动连接指定wifi

    public class WifiAutoConnectManager { private static final String TAG = WifiAutoConnectManager.class ...

  9. CodeForces 484B Maximum Value (数学,其实我也不知道咋分类)

    B. Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  10. Jquery.ajax 详细解释 通过Http请求加载远程数据

    首先请看一个Jquery.ajax的例子 $.ajax({ type: "GET", url: "/api/SearchApi/GetResults", dat ...