cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

Installation Tip: How to add services for systemd based Distros

antonio_villar1
Participant

Hi,

Here is the list of steps to add a service in linux servers that uses systemd instead of the old chkconfig (Red Hat 7, latest Centos and ubuntu, etc).

- Make sure the DT_INSTALL/init.d/dynaTrace* init scripts does not specify a value for the variable

DT_RUNASUSER=

- Download the samples scripts dynatrace provides in the installation instructions (systemdSamples.zip).

- Unzip into a temporaty directory.

- Important: For each script change the name from dt<something>.service to dyna<something>.service. Example:

dtserver.service to dynaserver.service

- In the pragma Service, edit the parameters to specify the installation path, and also the username used for the installation

Example, for dynaserver.service

[Service]

Type=forking


ExecStart=/opt/dynatrace-6.5/init.d/dynaTraceServer start

ExecStop=/opt/dynatrace-6.5/init.d/dynaTraceServer stop

#Restart=on-failure

User=dynatrace


Group=dynatrace

Do this for all the services you need (server, collectors, analysis)

- Now, as root copy the modified files to /etc/systemd/system

- As root, add the service so it will be started at server boot:

systemctl enable <service file>.service

- To start/stop the service manually (testing)

systemctl start <service file>.service

systemctl stop <service file>.service

Example:

systemctl enable dynaserver.service


systemctl start dynaserver.service

Hope it helps!

Antonio V.

10 REPLIES 10

andreas_grabner
Dynatrace Guru
Dynatrace Guru

Thanks for the tip!

jean_louis_lorm
Dynatrace Pro
Dynatrace Pro

Hello,

Where can I find the file systemdSamples.zip to download it ?

Regards,

JLL

Bonjour,
je prendrai connaissance de votre message à mon retour. Pour toutes demandes urgentes, je vous prie de les adresser à :

messieurs Chawky Kheddam "chawky.kheddam@rcibanque.com"-- Mustapha Guerda "Mustapha.guerda@rcibanque.com" --


Bonne journée.


Bonjour,






Je suis absente aujourd'hui. Pour toute urgence veuillez contater list.RCI-RESEAU@rcibanque.com.










Cordialement,






antonio_villar1
Participant

Hi,

You can find the link in the dynatrace server installation manual (search for systemd string).

Anyway, this is the address:

https://community.dynatrace.com/community/download/attachments/221381207/systemdSamples.zip?version=1&modificationDate=1468855637817&api=v2

tahir_faqir
Newcomer

For me the manual step (systemctl start dynaserver.service) didn't work until I performed the systemctl enable dynaserver.service before executing systemctl start dynaserver.service. Any idea why that might be so?...maybe it's the systemd related symlinks that are created...I'm not sure. Thanks to Antonio for this great post...I would like to copy the link to this post to the comments under the documentation page that discusses the systemd topic.

You are right:

sudo systemctl enable application.service
This will create a symbolic link from the system's copy of the service file (usually in /lib/systemd/systemor /etc/systemd/system) into the location on disk where systemd looks for autostart files (usually /etc/systemd/system/some_target.target.wants).

david_stephens
Newcomer

How would I setup systemd service scripts for multiple instances. I got the first collector working using this post but when I copied it and adjusted to control second instance it fails to work, no errors.

Working service:

Name:dynacollector.service

[Unit]
Description=Dynatrace Collector service
After=network.target

[Service]
Type=forking
ExecStart=/data01/dynatrace-6.5/init.d/dynaTraceCollector start
ExecStop=/data01/dynatrace-6.5/init.d/dynaTraceCollector stop
#Restart=on-failure
User=dynatrace
Group=dynatrace
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target

Non-working service:

Name: dynacollector_2.service

Changes: ExecStart/ExecStop point to dynaTraceCollector_2 init.d script.

Thank you for your help.

Disregard, I figured it out.

glen_wallace1
Inactive

That rename step is rather important. It wasn't immediately obvious to me why the scripts needed to be renamed and why things break when they aren't, so I thought a quick note might be useful.

The DT_INSTALL/init.d/dynaTraceServer script sniffs for a running process if there is no valid value in the *.pid file. This sniffing will misidentify a service start command like "sudo service dtserver start" as a running DT server process and skip starting it.

See the 'PROCESSPID=$(ps -ef | grep -v "instance" ...' lines