systemd

常用运维工具小结

匿名 (未验证) 提交于 2019-12-02 21:56:30
运维常用工具 系统监控工具 htop 命令 默认支持图形界面的鼠标操作 可以横向或纵向滚动浏览进程列表,以便看到所有的进程和完整的命令行 可以直接通过 F9 杀死进程 # 安装htop(需要安装epel) $ yum -y install htop    安装了htop,但是习惯于敲top命令,可以去修改配置文件 $ vim /etc/bashrc # 在最后追加这个判断,如果存在htop,top=htop,如果没有安装htop,则top还是top if [ -f /usr/bin/htop ];then alias top='/usr/bin/htop' fi 多功能系统信息统计工具 dstat 命令 # 查看dstat支持的插件 $ dstat --list internal: aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm /usr/share/dstat: battery, battery-remain, cpufreq, dbus, disk-tps, disk-util,

启动tomcat 报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

匿名 (未验证) 提交于 2019-12-02 21:35:04
[root@localhost META-INF]# systemctl start tomcat Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details. [root@localhost META-INF]# systemctl status tomcat.service ● tomcat.service - Tomcat Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Tue 2019-02-19 12:12:06 EST; 11s ago Process: 7551 ExecStart=/usr/local/tomcat/bin/startup.sh (code=exited, status=1/FAILURE) Feb 19 12:12:06 localhost.localdomain systemd[1]:

Startup script with systemd in Linux

雨燕双飞 提交于 2019-12-02 20:49:22
Can I do This start up service below, there are no errors showing once run, but the server script below does not run! ln /lib/systemd/aquarium.service aquarium.service systemctl daemon-reload systemctl enable aquarium.service systemctl start aquarium.service thanks aquarium.service: [Unit] Description=Start aquarium server [Service] WorkingDirectory=/home/root/python/code/aquarium/ ExecStart=/bin/bash server.* start KillMode=process [Install] WantedBy=multi-user.target here is the server.sh script #!/bin/bash PID="" function get_pid { PID=`pidof python ./udpthread.py` } function stop { get_pid

How to create a navigation menu in dotnet application?

纵饮孤独 提交于 2019-12-02 20:19:30
问题 I have created a console application which have a menu that allow me to navigate between the menu items. I handle the navigation logic in this method: public virtual void updateMenu() { switch (Console.ReadKey(true).Key) { case ConsoleKey.UpArrow: { if (cursor > 0) { cursor--; Console.Clear(); drawWithHeader(); } } break; case ConsoleKey.DownArrow: { if (cursor < (menuItemList.Count - 1)) { cursor++; Console.Clear(); drawWithHeader(); } } break; case ConsoleKey.Escape: { if (ParentMenu !=

How to ensure that there is a delay before a service is started in systemd?

隐身守侯 提交于 2019-12-02 20:06:28
I am having a service that depends on Cassandra coming up gracefully and the cluster being up and ready. To ensure that the dependency order is met, I have the following unit file [Unit] Requires=cassandra.service After=cassandra.service [Service] Environment=JAVA_HOME=/usr/java/jre ExecStart=@bringup.instance.path@/webapps/bringup-app/bin/bringup TimeoutStartSec=0 ExecStop= PIDFile=@bringup.instance.path@/logs/bringup.pid Restart=always [Install] WantedBy=multi-user.target How do I ensure that the bringup-app process waits for 30 seconds before it attempts to start up? Currently although it

Ubuntu 16.04 systemd redis issues with ulimit

不羁岁月 提交于 2019-12-02 19:29:48
I have been having issues with our new redis server after swapping from Ubuntu 14.04 to 16.04. The configuration of the open files limit using all the guides says to change the /etc/security/limits.conf with the following settings * soft nofile 65535 * hard nofile 65535 root soft nofile 65535 root hard nofile 65535 And also to add to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive session required pam_limits.so I have made all of these changes but redis is still starting up with a file limit of 4096 which under production load we quickly reach max connections. After much

DOCKER_OPTS do not work in config file /etc/default/docker

余生长醉 提交于 2019-12-02 18:40:18
I have changed /etc/default/docker with DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock" (docker version 1.4.1 in ubuntu 14.04), but it do not take any effect for me (not listening at port 2375 ). It seems that docker do not read this initial config file because I found export http_proxy enviroment do not work too. Only sudo docker -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -d works. It really confused me! According to docker documentation , The recommended way to configure the daemon flags and environment variables for your Docker daemon is to use a systemd

Systemd node app failing to start

做~自己de王妃 提交于 2019-12-02 18:17:02
问题 I have a node app, that I'm trying to add as a service, the app works fine if I go to the directory where it's installed and do node start.js however when I do systemctl start app it just hangs for a few mins then journalctl -u darknet shows: Dec 24 01:46:33 Skynet systemd[1]: Started darknet. Dec 24 01:46:33 Skynet systemd[1]: Starting darknet... Dec 24 01:46:34 Skynet darknet[32246]: module.js:434 Dec 24 01:46:34 Skynet darknet[32246]: return process.dlopen(module, path._makeLong(filename))

Linux之systemd服务配置及自动重启

笑着哭i 提交于 2019-12-02 16:56:28
layout: post title: Linux之systemd服务配置及自动重启 date: 2019-09-09 tags: linux --- Linux之systemd服务配置及自动重启 0 背景 在linux上开发时,往往需要将自己的程序做成服务,并且实现服务开机自动重启,以及服务崩溃后自动重启功能,本文就对该功能的实现做简单介绍,实现方法很简单,使用linux系统的systemd即可实现 1 systemd介绍 历史上,linux的启动一直采用init进程,比如 $ sudo /etc/init.d/apache2 start 或者 $ service apache2 start 这种方法有两个缺点。 一是启动时间长。init进程是串行启动,只有前一个进程启动完,才会启动下一个进程。 二是启动脚本复杂。init进程只是执行启动脚本,不管其他事情。脚本需要自己处理各种情况,这往往使得脚本变得很长。 Systemd 就是为了解决这些问题而诞生的。它的设计目标是,为系统的启动和管理提供一套完整的解决方案。 根据 Linux 惯例,字母d是守护进程(daemon)的缩写。 Systemd 这个名字的含义,就是它要守护整个系统。使用了 Systemd,就不需要再用init了。Systemd 取代了initd,成为系统的第一个进程(PID 等于 1),其他进程都是它的子进程。

linux systemd 从简单的例子入门

半城伤御伤魂 提交于 2019-12-02 15:41:24
linux systemd 从简单的例子入门 网上很多相关链接,一上来就给一大堆命令和讲解,让人头都大。 我们希望有一个service(服务),让它在开机启动的时候就执行。 用 root 登陆以后: 新建service vim /etc/system/system/my-test-daemon.service 输入以下内容(有看过文章说=号前后不要有空格,有空格可不可以没测试过): [Unit] Description=my test daemon [Service] ExecStart=/usr/bin/git daemon --verbose --export-all --base-path=/var/lib/git /var/lib/git Restart=always Type=simple [Install] WantedBy=multi-user.target 例子中我用了 git daem,git daemon 需要安装的话,在 Centos 系统中的命令是 yum install -y git-deamon,不同系统有不同的安装方式。 查看是否建立成功 systemctl list-unit-files --type=service | my-test-daemon 显示输出: my-test-daemon.service disabled 可以看出目前是关闭状态