简介
本文档介绍如何为ParStream历史数据库的init.d或Systemd创建服务文件。
先决条件
要求
Cisco建议您应具备Linux知识。
使用的组件
本文档不限于特定的软件和硬件版本。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
配置
边缘雾处理模块(EFM)安装软件包不包含init.d或Systemd开箱即用的服务文件。
在这里,您可以找到创建服务文件的简单示例。
对于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
确保调整环境变量以与环境匹配:PARSTREAM_HOME、PARSTREAM_SERVERNAME和PARSTREAM_USER。
创建文件后,请确保将其标记为可执行文件。
对于系统Md
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
确保调整配置变量以匹配您的环境:ExecStart行上的User=和servername。
创建服务文件后,请确保更新systemd中的守护程序文件:
[root@cen7 ~]# systemctl daemon-reload
验证
使用本部分可确认配置能否正常运行。
要验证脚本/服务文件是否按预期工作,您可以尝试启动和停止服务。
对于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
对于系统Md
[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
如您所见,ParStream进程以您在服务文件中定义的用户启动,在您请求停止服务后,所有内容都将清除。
故障排除
本部分提供了可用于对配置进行故障排除的信息。
如果在启动时遇到问题,请检查以下项:
- init.d或Systemd服务文件中的可配置参数(用户、路径、ParStream服务器名)
- 检查ParStream的日志文件的输出(在/var/log/parstream中)
- 对于SystemD:systemctl status parstream的输出
- journalctl —unit=parstream的输出