systemd

Linux下的服务与进程管理

允我心安 提交于 2020-03-07 14:11:09
1.Linux 系统的启动过程 2、Linux 系统的运行级别 (1)Linux 为了适应不同用户对服务的启动配置要求,设置了七种不同的运行级别: 运行级别 0:关机模式。poweroff.target 运行级别 1:单用户模式,仅用于 root 用户对系统进行维护时。rescue.target 运行级别 2:多用户模式(没有 NFS)。multi-user.target 运行级别 3:完全多用户模式,即多用户文本界面模式,是标准的运行级别。 运行级别 4:特定运行级别,基本不用的用户模式。multi-user.target 运行级别 5:X11,Linux 系统的图形界面运行级别。graphical.target 运行级别 6:重新启动。reboot.target target 文件保存在:/lib/system/system 目录中。 运行级别的设置由/etc/systemd/system/default.target 文件来控制。 运行级别服务程序存放位置:/etc/rc.d/ 服务进程存放在运行级别对应的目录中:Snnxxxx 或 Knnxxxxx 服务程序的脚本文件存放位置:/etc/rc.d/init.d/ (2)系统运行级别之间的切换 查看系统的当前运行级别:runlevel 查看系统启动时的运行级别:ll /etc/systemd/system/default

SpringBoot服务无法读取系统变量,我进一步认识了profile和bashrc

百般思念 提交于 2020-03-07 12:45:31
背景 CentOS 服务器上,我们用 Systemd 部署了一个 SpringBoot 服务。关于如何部署,可以参考 这篇文章 。这个 SpringBoot 服务会用 ProcessBuilder 去调用机器上一个 C++ 的可执行文件。 问题描述 SpringBoot 程序跑得很正常,但是我们发现 C++ 程序却没有 log 输出,也就是说它从没被执行过。 查看了 ProcessBuilder 的返回值,是 127 。 127 的意思是 系统找不到对应的命令 。于是我们把 C++ 程序对应的目录(里面包括第三方动态链接库)添加到了 LD_LIBRARY_PATH 。怎么添加的呢?我们在 ~/.bash_profile 脚本中添加了命令: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/cppFoler/ 经过测试, SpringBoot 服务依然无法成功调用 C++ 程序,依然返回 127 。但奇怪的是,当我们直接使用 java -jar 命令,并且用 nohup 的方式令 SpringBoot 程序跑在后台,可以正常调用 C++ 程序: nohup java -jar mySpringBoot.jar 问题分析 这里就不得不说 Linux 中 nohup 与 service 的区别了。 nohup : 在 linux 中

SpringBoot以服务形式启动,并设置JVM启动参数

允我心安 提交于 2020-03-05 22:35:20
1 概述 SpringBoot 使得我们可以快速地上手以及开发Spring项目。我们可以把工程打成一个 jar 包,然后部署到服务器上(这里只讨论Linux,因为没多少人会拿Windows当服务器)。 nohup 命令可以让程序作为后台进程执行,但是它不好管理维护,也显得很不专业。更好的方法是将 SpringBoot 作为 Service 启动。 2 步骤 2.1 Maven打包 通过 package 命令打 jar 包: mvn clean package 这里注意一点,一定要将 org.springframework.boot plugin添加到 pom 文件里面,其中“<executable>true</executable>”一定要加,标示该 jar 为可执行,否则机器启动 SpringBoot 服务会报错。plugin如下所示: <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>true</executable> </configuration> </plugin> </plugins> </build> 2.2

Xinetd服务的安装与配置详解

家住魔仙堡 提交于 2020-03-05 07:54:29
1 .什么是 xinetd xinetd即extended internet daemon,xinetd是新一代的网络守护进程服务程序,又叫超级Internet服务器。经常用来管理多种轻量级Internet服务。xinetd提供类似于inetd+tcp_wrapper的功能,但是更加强大和安全。 2. xinetd 的特色 1 ) 强大的存取控制功能 — 内置对恶意用户和善意用户的差别待遇设定。 — 使用libwrap支持,其效能更甚于tcpd。 — 可以限制连接的等级,基于主机的连接数和基于服务的连接数。 — 设置特定的连接时间。 — 将某个服务设置到特定的主机以提供服务。 2 ) 有效防止 DoS 攻击 — 可以限制连接的等级。 — 可以限制一个主机的最大连接数,从而防止某个主机独占某个服务。 — 可以限制日志文件的大小,防止磁盘空间被填满。 3 ) 强大的日志功能 — 可以为每一个服务就syslog设定日志等级。 — 如果不使用syslog,也可以为每个服务建立日志文件。 — 可以记录请求的起止时间以决定对方的访问时间。 — 可以记录试图非法访问的请求。 4 ) 转向功能 可以将客户端的请求转发到另一台主机去处理。 5) 支持 IPv6 xinetd自xinetd 2.1.8.8pre*起的版本就支持IPv6,可以通过在./configure脚本中使用with-inet6

rhel 7安装oracle 11gr2 rac 遇到的问题

 ̄綄美尐妖づ 提交于 2020-02-29 15:41:03
rhel7 安装11g r2 rac的方法跟之前的还是有很大的区别,以至于遇到很多坑,这里汇总下: 1、共享磁盘udev 绑定方式 这个跟rhel7 之前的版本不一样,特别是磁盘uuid命令方式变化了很多,udev启动方式也发生了变化, for disk in `ls /dev/sd*` do echo $disk /usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=$disk done 映射文件: cat /etc/udev/rules.d/99-oracle-asmdevices.rules KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c298981418c7e8a25a89d0f836c9", SYMLINK+="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT==

CentOS7搭建kubernetes集群环境

僤鯓⒐⒋嵵緔 提交于 2020-02-29 07:03:56
一、服务器环境准备 192.168.247.128 : k8s-master、etcd、registry 192.168.247.129 : k8s-nodeA 192.168.247.130 : k8s-nodeB 注:安装lsb_release命令:yum install redhat-lsb -y 三台机器配置相同 安装好相同版本的docker: [root @localhost ~]# docker -v Docker version 1.12.6, build 85d7426/1.12.6 三台机器上分别修改hostname: master上运行: [root @localhost ~]# hostnamectl --static set-hostname k8s-master nodeA上运行: [root @localhost ~]# hostnamectl --static set-hostname k8s-nodeA nodeB上运行: [root @localhost ~]# hostnamectl --static set-hostname k8s-nodeB 三台机器上分别配置hosts, 执行如下命令修改hosts文件: echo '192.168.247.128 k8s-master 192.168.247.128 etcd 192.168.247

k8s集群部署七(部署Node节点组件)

爱⌒轻易说出口 提交于 2020-02-28 17:08:47
在master节点执行命令 # kubectl create clusterrolebinding kubelet-bootstrap --clusterrole=system:node-bootstrapper --user=kubelet-bootstrap 将之前生成的kubeconfig文件以及pem证书拷贝到两台Node节点上。 cd /opt/kubernetes/ssl scp *.kubeconfig root @host1 :/opt/kubernetes/cfg/ scp *.kubeconfig root@host2:/opt/kubernetes/cfg/ scp *.pem root @host1 :/opt/kubernetes/ssl/ scp *.pem root@host2:/opt/kubernetes/ssl/ 将kubernetes-server-linux-amd64.tar.gz上传到两台node节点上,解压(Node节点执行以下操作) tar -xzvf kubernetes-server-linux-amd64.tar.gz cd kubernetes/server/bin mv kubelet kube-proxy /opt/kubernetes/bin/ 拉取谷歌容器的阿里云镜像,并标记 docker pull registry

1.3 systemd命令

半城伤御伤魂 提交于 2020-02-28 16:58:07
system运行级别: 0 关机 1 单用户 2 等同于级别3 3 多用户文本界面 4 等同于级别3 5 多用户图形界面 6 重启 emergency 紧急shell systemclt命令 启动:systemclt start network 重启:systemctl restart network 关闭:systemclt stop network 重新加载:systemctl reload network 查看状态:systemctl status network 开机自启:enable 开机关闭:disable 来源: 51CTO 作者: clear3515 链接: https://blog.51cto.com/13884816/2473019

Injecting structured json logs into journald

家住魔仙堡 提交于 2020-02-28 08:19:27
问题 I get the impression that there might be a way to write to the systemd journal, json data directly without first converting it to the format the sd_journal* functions expect. Is this possible or not? My suspicion is because of some comments about an inbuilt json parser. However the man pages suggest otherwise. Also, I note that if your write to stdout in the format <priority> message The priority will end up in the PRIORITY="priority" field and message will end up in MESSAGE="message" field.

Injecting structured json logs into journald

我只是一个虾纸丫 提交于 2020-02-28 08:19:04
问题 I get the impression that there might be a way to write to the systemd journal, json data directly without first converting it to the format the sd_journal* functions expect. Is this possible or not? My suspicion is because of some comments about an inbuilt json parser. However the man pages suggest otherwise. Also, I note that if your write to stdout in the format <priority> message The priority will end up in the PRIORITY="priority" field and message will end up in MESSAGE="message" field.