I have a Kuberenetes cluster and telegraf is running on each node. Telegraf is collecting data and storing into InfluxDB. Now I want to run another instance of telegraf which will use one of the pods namespace and collect stats from Apache server running inside the pod and store the stats in the same InfluxDB storage.
I followed this link (https://community.influxdata.com/t/multiple-telegraf-configs/245/6) but couldn't figure out how can I implement this in my setup.
I am using Debian GNU/Linux 9 (stretch) and telegraf_1.12.5-1.
I created two service file as follows:
cat /usr/lib/telegraf/scripts/telegraf.service
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target
[Service]
EnvironmentFile=-/etc/default/telegraf
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group
[Install]
WantedBy=multi-user.target
cat /usr/lib/telegraf/scripts/telegraf_xyz.service
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target
[Service]
EnvironmentFile=-/etc/default/telegraf_xyz
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group
[Install]
WantedBy=multi-user.target
But when I try to run the second instance it's giving error:
Failed to start telegraf_xyz.service: Unit telegraf_xyz.service not found.
What else changes I need to do as part of this? I see the telegraf.service file in many other locations (/sys/), I am not sure where else I need to configure the second telegraf instance. I am very new in this.
Is there any other better way to implement this in my setup?
NOTE: I have created two service file and able run that in my host. Now the real challange is running the instance in another net namespace. Can anyone help me to implement this?
Please put your service file here: /etc/systemd/system/. Then reload systemd with systemctl daemon-reload. Your service should now be found.
Related
On a Virtual Maching running on Centos7, using root privileges, I want to create a service to launch a Python (Python 3.9) webservice and restart it every hour.
Here's what i did:
creating a directory /etc/systemd/system/dlweb_doc_webservice.service.d
creating a file dlweb_db_generate_report.service like this
[Unit]
Description=dlweb_db_generate_report_webservice
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Type = simple
ExecStart=/usr/local/bin/python3.9 /opt/scripts/dlweb_db_generate_report_webservice/dlweb_db_generate_report.py
Restart=on-failure
RestartSec=5s
StartLimitIntervalSec=3600
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
running systemctl daemon-reload
running systemctl --type=service --all doesn't display my service
and
running systemctl enable dlweb_db_generate_report_webservice returned a Failed to execute operation: No such file or directory
What did i miss or do wrong?
I just downloaded jbpm server from JBPM.
it starts by running "jbpm-server/bin/standalone.sh" this. But i want to start jbpm as ubuntu's service like---> systemctl start jbpm.
can anyone provide me details to create startup script for this.
You should create a file in your systemd directory, for example /etc/systemd/system/change_me.service and fill it with a basic setup like:
[Unit]
Description=Your service's description
[Service]
ExecStart=/path/to/executable.sh
[Install]
WantedBy=multi-user.target
Then you should reload your systemd configuration in order to update it with the new service via
sudo systemctl daemon-reload
And then start it
sudo systemctl start change_me
If you want a more granular control over your systemd's service file you should read the man page via:
man systemd.service
Paths are correct, I don't know why I can't start kafka service, all lines, log files, etc and do not say what the Issue is... :/
I'm trying to install kafka on my Centos 7/8 and there is no Issue description I can figure out.
zookeeper.service file:
[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simpleUser=kafka
ExecStart=/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.shRestart=on-abnormal
[Install]
WantedBy=multi-user.target
kafka.service file:
[Unit]
Requires=zookeeper.service
After=zookeeper.service
[Service]
Type=simple
User=kafka
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/kafka-server-start.sh /home/kafka/kafka/config/server.properties > /home/kafka/kafka/kafka.log 2>&1'
ExecStop=/home/kafka/kafka/bin/kafka-server-stop.shRestart=on-abnormal
[Install]
WantedBy=multi-user.target
UPDATE: I was trying to solve kafka Issue when I sould check zookeeper service first. Please check the workaround below.
Ok I found the solution and I'm posting it because I saw a lot of questions regarding this Issue hoping I can also help them.
So, please check out the new command line ExecStart:
zookeeper.service file:
[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simpleUser=kafka
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties'
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
On Centos (7/8/ X Version) it needs to specify the batch like this (using /bin/sh -c ''):
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties'
After this, you can run the kafka service! :)
From Kafka docs Quickstart
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if
you don't already have one. You can use the convenience script
packaged with kafka to get a quick-and-dirty single-node ZooKeeper
instance.
Start zookeeper server with default settings
$ bin/zookeeper-server-start.sh config/zookeeper.properties
Start Kakfa server with default settings
$ bin/kafka-server-start.sh config/server.properties
If you had already done this step and still getting this error, Kafka server is unable to reach zookeeper service. Please check zookeeper server is running and listening on port mentioned (clientPort, default port: 2181) in zookeeper.properties file using anyone of the following commands - netstat, lsof, and telnet
I used to run my pyramid server as a daemon with the pserve --daemon command.
Given that it's deprecated, I'm looking for the best replacement. This link recommends to run it with screen or tmux, but it seems too heavy to just run a web server. Another idea would be to launch it with setsid.
What would be a good way to run it ?
Create a service file in /etc/systemd/system. Here a example (pyramid.service):
[Unit]
Description=pyramid_development
After=network.target
[Service]
# your Working dir
WorkingDirectory=/srv/www/webgis/htdocs/app
# your pserve path with ini
ExecStart=/srv/www/app/env/bin/pserve /srv/www/app/development.ini
[Install]
WantedBy=multi-user.target
Enable the service:
systemctl enable pyramid.service
Start/Stop/Restart the service with:
systemctl start pyramid.service
systemctl restart pyramid.service
systemctl stop pyramid.service
The simplest option is to install supervisord and setup a conf file for the service. The program would just be env/bin/pserve production.ini. There are countless examples online of how to do this.
The best option is to integrate with your system's process manager (systemd usually, but maybe also upstart or sysvinit or openrc). It is very easy to write a systemd unit file for starting pserve and then it will be started/stopped along with the rest of your system. Log files are even handled automatically in these cases.
I am provisioning a cluster of CoreOS machines. But I am having trouble downloading the kubernetes tar ball because of its size (~450MB). I have managed to use this same techinique to download the latest etcd2, fleet and flannel, but when downloading such a big file as kubernetes my service fails or stop without any stack strace. It think is something related with the fact systemd is neither waiting nor restarting the service as I would expect.This is my service file:
[Unit]
Description=updates kubernetes v1.2
[Service]
Type=oneshot
User=root
WorkingDirectory=/home/core
ExecStart=/usr/bin/mkdir -p /opt/bin
ExecStart=/usr/bin/mkdir -p /home/core/kubernetes
ExecStart=/bin/wget https://github.com/kubernetes/kubernetes/releases/download/v1.2.0/kubernetes.tar.gz
ExecStart=/usr/bin/tar zxf /home/core/kubernetes -C /home/core/kubernetes --strip-components=1
ExecStart=/usr/bin/mv kubernetes/platforms/linux/amd64/kubectl /opt/bin/kubectl
ExecStart=/usr/bin/tar zxf kubernetes/server/kubernetes-server-linux-amd64.tar.gz
ExecStart=/usr/bin/chmod a+x kubernetes/server/bin/*
ExecStart=/usr/bin/mv kubernetes/server/bin/* /opt/bin
ExecStart=/usr/bin/rm -f /home/core/kubernetes
I bet you need to set/increase the TimeoutStartSec= parameter which is probably defaulted to 30 seconds or something like that.