systemd

systemctl 命令完全指南

拈花ヽ惹草 提交于 2019-12-18 00:37:47
systemctl 命令完全指南 2015-07-31 08:00 译自: http://www.tecmint.com/manage-services-using-systemd-and-systemctl-in-linux/ 作者: Avishek Kumar 原创: LCTT https://linux.cn/article-5926-1.html 译者: joeren Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。 Systemd是一个系统管理守护进程、工具和库的集合,用于取代System V初始进程。Systemd的功能是用于集中管理和配置类UNIX系统。 在Linux生态系统中,Systemd被部署到了大多数的标准Linux发行版中,只有为数不多的几个发行版尚未部署。Systemd通常是所有其它守护进程的父进程,但并非总是如此。 使用Systemctl管理Linux服务 本文旨在阐明在运行systemd的系统上“如何控制系统和服务”。 Systemd初体验和Systemctl基础 1. 首先检查你的系统中是否安装有systemd并确定当前安装的版本 # systemctl --version systemd 215 +PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP

Can't detach child process when main process is started from systemd

余生颓废 提交于 2019-12-17 11:43:50
问题 I want to spawn long-running child processes that survive when the main process restarts/dies. This works fine when running from the terminal: $ cat exectest.go package main import ( "log" "os" "os/exec" "syscall" "time" ) func main() { if len(os.Args) == 2 && os.Args[1] == "child" { for { time.Sleep(time.Second) } } else { cmd := exec.Command(os.Args[0], "child") cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} log.Printf("child exited: %v", cmd.Run()) } } $ go build $ ./exectest ^Z [1]+

postgrep修改存储目录

萝らか妹 提交于 2019-12-17 10:21:53
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 此篇文档为转载,来自赵熠东的csdn博客,地址暂时未找到 安装yum源 yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm 安装客户端和服务端 yum install -y postgresql10-server postgresql10 安装完会在系统中创建postgres用户,并在其.bash_profile中设置PGDATA=/var/lib/pgsql/10/data 在/usr/lib/systemd/system/目录创建postgresql-10.service用于支持 systemd 调用 systemd设置开机启动原理 支持 systemd 启动的程序会在/usr/lib/systemd/system/下建立.service启动脚本 systemctl enable postgresql-10.service Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-10.service to /usr/lib/systemd

Centos7系统启动流程

非 Y 不嫁゛ 提交于 2019-12-17 07:53:06
Centos7系统启动流程 1 、 uefi或BIOS初始化,开始post(power on self test)开机自检 这个过程是开机后,BIOS或UEFI进行硬件检查的阶段。检测:CPU, 内存,硬盘等硬件信息。 2、 加载MBR到内存 ,这里以BIOS为例,BIOS将会直接找硬盘的第一个扇区,找到前446字节,将MBR加载到内存中,MBR将告诉程序下一阶段去哪里找系统的grub引导。此阶段属于grub第一阶段。grub还有1.5阶段和2阶段。 分区符MBR(512字节) 三部分组成: 引导程序: 446字节(bootloader) 分区表: 64字节 魔数: 2字节(55AA) 3、 GRUB阶段 grub第1.5和第2阶段,信息默认存放在扇区中,如果使用grub-install生成的第2阶段的文件是存放在/boot分区中的。 为了加载内核系统,不得不加载/boot分区,而加载/boot分区,要有/boot分区的驱动,/boot分区驱动是放在/boot分区中的啊,我们好像进入死循环了,Linux是怎么解决的呢?就是靠放在1.5阶段中的数据,放在第一个扇区后的后续扇区中,第1.5阶段和2阶段总共27个扇区。 第1.5阶段:mbr之后的扇区,识别stage2所在的分区上的文件系统。 第2阶段:开机启动的时候看到Grub选项、信息,还有修改GRUB背景等功能都是stage2提供的

Linux系统服务

梦想与她 提交于 2019-12-15 18:49:39
(整理自《鸟哥的Linux私房菜》基础篇) 1.systemd 使用的 unit 分类 1.1 systemd 的配置文件放置目录 systemd 将过去所谓的 daemon 执行脚本通通称为一个服务单位 (unit),而每种服务单位依据功能来区分时,就分类为不同的类型 (type)。几个比较重要的目录: • /usr/lib/systemd/system/:每个服务最主要的启动脚本设定,有点类似以前的 /etc/init.d 底下的文件; • /run/systemd/system/:系统执行过程中所产生的服务脚本,优先序要比 /usr/lib/systemd/system/ 高; • /etc/systemd/system/:依据主机系统需求所建立的执行脚本,优先序又比/run/systemd/system/ 高。 • /etc/sysconfig/*:几乎所有的服务都会将初始化的一些选项设定写入到这个目录下,举例来说,网络的设定则写在/etc/sysconfig/network-scripts/ 这个目录内。 • /var/lib/:一些会产生数据的服务都会将他的数据写入到 /var/lib/ 目录中。 • /run/:放置了好多 daemon 的缓存文件,包括 lock file 以及 PID file 等 。 1.2 systemd 的 unit 类型分类说明 常见的

centos7最大进程数修改

☆樱花仙子☆ 提交于 2019-12-14 16:19:55
之前我们按照原先的修改/etc/security/limits.d/90-nproc.conf,发现修改完后最大进程数显示为15088 CentOS 7 使用systemd替换了SysV。Systemd目的是要取代Unix时代以来一直在使用的init系统,兼容SysV和LSB的启动脚本,而且够在进程启动过程中更有效地引导加载服务。因为这样你会发现在/etc/systemd目录下有一个系统的默认管理配置,这里有登陆、日志、服务、系统等。 因为上面的配置并不能实现我们的效果,所以还要编辑一个配置文件:/etc/systemd/system.conf 快速修改: sed -i '/^#DefaultLimitNOFILE=/aDefaultLimitNOFILE=65535' /etc/systemd/system.conf sed -i '/^#DefaultLimitNPROC=/aDefaultLimitNPROC=65535' /etc/systemd/system.conf 效果就是在匹配的行下添加一行数据: [root@*********** ~]# egrep -v "^#" /etc/systemd/system.conf [Manager] DefaultLimitNOFILE=65535 DefaultLimitNPROC=65535 此时重启就会发现max user

Kernel booting frozen due to mounting failure

纵饮孤独 提交于 2019-12-14 03:25:03
问题 I built a new yocto image for a custom board. I flashed it to an SD card and tried booting it, but freezes while booting Kernel. The image has SYSTEMD feature enabled. If I disable SYSTEMD, it boots fine. Do i need to configure anything ? like in fstab? I am stuck at this point for a long time, so please advice. 回答1: I was able to resolve this error. I enabled CONFIG_CGROUPS related features as mentioned in (link) in my machine's defconfig and the Kernel boots fine :) 来源: https:/

Centos 7 - service from /etc/systemd/system/san.service not running with systemctl start san.service

半城伤御伤魂 提交于 2019-12-13 20:48:41
问题 I followed instructions from this link: https://www.thegeekdiary.com/centos-rhel-7-how-to-make-custom-script-to-run-automatically-during-boot/ But I have issue because my service is not being run. I created one script startSanic2.sh which invokes startSanic.sh script (I need this because when I start it manually with & only in this case session is not expired) This is my script startSanic2.sh # cat /opt/horses/startSanic2.sh #!/bin/bash cd /opt/horses ./startSanic.sh & This is my script

[安装] 创建asmlib 磁盘失败

天大地大妈咪最大 提交于 2019-12-13 17:46:22
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> [root@db01 mapper]# oracleasm createdisk vot01 /dev/mapper/votdsk01 oracleasm module not loaded or /dev/oracleasm not mounted. [root@db01 mapper]# ll [root@db01 ~]# systemctl status oracleasm ● oracleasm.service - Load oracleasm Modules Loaded: loaded (/usr/lib/systemd/system/oracleasm.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2019-11-25 04:59:08 CST; 23min ago Process: 63194 ExecStart=/usr/sbin/oracleasm.init start_sysctl (code=exited, status=1/FAILURE) Main PID: 63194 (code=exited, status=1/FAILURE) Nov 25 04

Disable a standard systemd service in Yocto build

邮差的信 提交于 2019-12-13 12:32:45
问题 I need to start my own systemd service, let's call it custom.service . I know how to write a recipe for it to be added and enabled on boot: SYSTEMD_SERVICE_${PN} = "custom.service" SYSTEMD_AUTO_ENABLE_${PN} = "enable" However, it conflicts with one of the default systemd services - systemd-timesyncd.service . Is there a nice preferred way to disable that default systemd service in my bitbake file even though the systemd_XX.bb actually enables it? I can create a systemd_%.bbappend file to