我试图与Cloudera一起启动Kafka Connect组件,并希望将Kafka Connect启动脚本包装在systemd
服务文件中,以便一旦Cloudera服务启动就可以在启动时启动。
出于某种奇怪的原因,如果我在systemd
之外启动此脚本,它就可以正常工作,但是当我通过systemctl start kafka-connect
启动它时,它只是挂在以下日志输入行。
[Unit]
Description=Kafka Connect - Distributed
After=network.target cloudera-scm-agent
[Service]
Type=forking
ExecStart=/bin/bash -c "/app/cloudera/parcels/KAFKA/lib/kafka/bin/connect-distributed.sh -daemon /app/cloudera/kafka-connect/connect-distributed.properties"
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
2019-07-18 13:40:27,962 INFO (main) [ConnectDistributed(main:69)] Scanning for plugin classes. This might take a moment ...
2019-07-18 13:40:27,992 INFO (main) [DelegatingClassLoader(registerPlugin:184)] Loading plugin from: /app/cloudera/kafka-connect/plugins/splunk-kafka-connect.jar
2019-07-18 13:40:27,993 DEBUG (main) [DelegatingClassLoader(registerPlugin:191)] Loading plugin urls: [file:/app/cloudera/kafka-connect/plugins/splunk-kafka-connect.jar]
2019-07-18 13:40:29,206 DEBUG (main) [VersionUtils(getVersionFromProperties:63)] found git version string=v1.1.0 in version.properties file
2019-07-18 13:40:29,219 INFO (main) [DelegatingClassLoader(scanUrlsAndAddPlugins:207)] Registered loader: PluginClassLoader{pluginLocation=file:/app/cloudera/kafka-connect/plugins/splunk-kafka-connect.jar}
2019-07-18 13:40:29,220 INFO (main) [DelegatingClassLoader(addPlugins:136)] Added plugin 'com.splunk.kafka.connect.SplunkSinkConnector'
2019-07-18 13:40:29,220 INFO (main) [DelegatingClassLoader(addPlugins:136)] Added plugin 'org.apache.kafka.connect.storage.StringConverter'
我的下一个想法是尝试做一些简单的事情,只需在init.d
处创建一个/etc/init.d/kafka-connect
脚本,就可以了,因为它只不过是一个Shell脚本包装器 UNTIL 我在/etc/init.d/functions
文件中获取资源,该文件再次通过systemd
启动。
两个主要问题-
systemctl
与常规的shell脚本有什么不同,常规的shell脚本会导致该shell脚本(依次启动一个Java进程)每次都挂在相同的步骤。/etc/init.d/kafka-connect
脚本有效,可以在RHEL7上使用吗?如果是这样,是否有办法在服务器启动时加载该init.d
脚本?谢谢!