Introduction
This document describes how to create service files for init.d or Systemd for the ParStream historian database.
Prerequisites
Requirements
Cisco recommends that you have knowledge of Linux.
Components Used
This document is not restricted to specific software and hardware versions.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.
Configure
The Edge Fog Processing Module (EFM) installation package does not contain service files for init.d or Systemd out of the box.
Here, you can find a simple example in order to create a service file.
For init.d
[root@cen7 ~]# cat /etc/init.d/parstream
#!/bin/bash
# parstream init script.
export PARSTREAM_HOME=/opt/cisco/kinetic/parstream/
export LD_LIBRARY_PATH=$PARSTREAM_HOME/lib:$LD_LIBRARY_PATH
PARSTREAM_SERVERNAME="parstream1"
PARSTREAM_USER="EFM"
case "$1" in
'start')
echo "Starting ParStream daemon $PARSTREAM_SERVERNAME as $PARSTREAM_USER"
sleep 2
su -c "cd $PARSTREAM_HOME;$PARSTREAM_HOME/bin/start.sh $PARSTREAM_SERVERNAME" $PARSTREAM_USER
;;
'stop')
echo "Stopping ParStream daemons for user $PARSTREAM_USER"
stopstatus=$(pkill -c -U $PARSTREAM_USER -15 parstream-serv)
echo "$stopstatus processes stopped"
;;
*)
# usage
echo "usage: $0 start|stop"
exit 1
;;
esac
Ensure that you adjust the environment variables in order to match your environment: PARSTREAM_HOME, PARSTREAM_SERVERNAME and PARSTREAM_USER.
After creating the file, ensure it is marked as executable.
For Systemd
root@cen7 ~]# cat /etc/systemd/system/parstream.service
[Unit]
Description=ParStream
After=network.target
[Service]
Type=simple
User=EFM
Environment=LD_LIBRARY_PATH=/opt/cisco/kinetic/parstream/lib:$LD_LIBRARY_PATH
WorkingDirectory=/opt/cisco/kinetic/parstream/
ExecStart=/opt/cisco/kinetic/parstream/bin/parstream-server parstream1 --confdir=/opt/cisco/kinetic/parstream/conf/
Restart=on-failure
[Install]
WantedBy=multi-user.target
Ensure that you adjust the configuration variables in order to match your environment: User= and servername on the ExecStart line.
After the creation of the service file, ensure that you update the daemon files in systemd:
[root@cen7 ~]# systemctl daemon-reload
Verify
Use this section in order to confirm that your configuration works properly.
In order to verify if the scripts/service file work as expected, you can try to start and stop the service.
For init.d
[root@cen7 ~]# /etc/init.d/parstream start
Starting ParStream daemon parstream1 as EFM
Server Process ID: 5056
Output is written to: /var/log/parstream/server-5054-20180423-1648.log
[root@cen7 ~]# ps aux |grep 5056
EFM 5056 0.8 0.7 1235292 27200 ? Sl 16:48 0:00 /opt/cisco/kinetic/parstream//bin/parstream-server parstream1
...
[root@cen7 ~]# /etc/init.d/parstream stop
Stopping ParStream daemons for user EFM
1 processes stopped
For Systemd
[root@cen7 ~]# systemctl start parstream
[root@cen7 ~]# systemctl status parstream
● parstream.service - ParStream
Loaded: loaded (/etc/systemd/system/parstream.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2018-04-23 16:49:30 CEST; 3s ago
Main PID: 5186 (parstream-serve)
CGroup: /system.slice/parstream.service
└─5186 /opt/cisco/kinetic/parstream/bin/parstream-server parstream1 --confdir=/opt/cisco/kinetic/parstream/conf/
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30]:unknown-000000:PROT-77086: **** PID: 5186 (host: cen7)
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30]:unknown-000000:PROT-71005: **** config file: "/opt/cisco/kinetic/parstream/conf/parstream.ini"
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30]:unknown-000000:WARNING-77082: Number of maximum file descriptors (1024) is lower than recommended value 98304
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30]:unknown-000000:WARNING-77113: Maximum number of mmap'ed areas (65530) is lower than recommended value 1966080.
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30.273380]:parstream1-164930:PROT-77045: Source Revision: 717e27f507aab73fdc0c3f9d4377ff658726c270
Apr 23 16:49:30 cen7 parstream-server[5186]: Local Changes:
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30.278632]:parstream1-164930:PROT-77018: cluster node config: ClusterNodeConfig(clusterId = 'localCluster', claimLeadershipInitT...geInterval = 0
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30.280474]:parstream1-164930:PROT-77018: channel instance created for accept on port: 23460
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30.281084]:parstream1-164930:PROT-77134: Entering state ClaimLeadershipState, got event InitialEvent
Apr 23 16:49:30 cen7 parstream-server[5186]: [2018-04-23T16:49:30.281243]:parstream1-164930:PROT-77065: Running cluster leader detection (limited until 2018-Apr-23 16:51:30)
Hint: Some lines were ellipsized, use -l to show in full.
[root@cen7 ~]# systemctl stop parstream
As you can see, the ParStream processes start under the user you defined in the service files and everything gets cleaned up after you request to stop the services.
Troubleshoot
This section provides information you can use in order to troubleshoot your configuration.
In case you experience issues with starting, check this:
- Configurable parameters in the init.d or Systemd service file (user, paths, ParStream servername)
- Check the output of the logfile for ParStream (in /var/log/parstream)
- For SystemD: The output of systemctl status parstream
- The output of journalctl --unit=parstream