我已经为DataStax企业4.8.5配置了一个systemd单元:
### /etc/systemd/system/dse1.service
[Unit]
Description=DataStax Enterprise
[Service]
User=cassandra
ExecStart=/opt/dse/dse1/bin/dse cassandra -k
ExecStop=/opt/dse/dse1/bin/dse cassandra-stop当我执行sudo systemctl start dse1时,如果之后立即执行status,则得到:
● dse1.service - DataStax Enterprise 1
Loaded: loaded (/etc/systemd/system/dse1.service; static; vendor preset: disabled)
Active: active (running) since Wed 2016-03-23 13:47:57 EDT; 1s ago
Main PID: 31699 (cassandra)
CGroup: /system.slice/dse1.service
├─31699 /bin/sh /opt/dse/dse1/resources/cassandra/bin/cassandra -k -Djava.library.path=:/opt/dse/dse1/resources/hadoop/native...
├─31894 /bin/java -cp :/opt/dse/dse1/lib/dse-core-4.8.5.jar:/opt/dse/dse1/lib/dse-hadoop-4.8.5.jar:/opt/dse/dse1/lib/dse-hive...
└─31895 grep -q Error: Exception thrown by the agent : java.lang.NullPointerException如果我再等几秒钟,再试一次,我会得到:
● dse1.service - DataStax Enterprise 1
Loaded: loaded (/etc/systemd/system/dse1.service; static; vendor preset: disabled)
Active: inactive (dead)
Mar 23 13:34:28 pspldsea01p.fleet.ad systemd[1]: Started DataStax Enterprise 1.
Mar 23 13:34:28 pspldsea01p.fleet.ad systemd[1]: Starting DataStax Enterprise 1...
Mar 23 13:38:33 pspldsea01p.fleet.ad systemd[1]: Started DataStax Enterprise 1.
Mar 23 13:38:33 pspldsea01p.fleet.ad systemd[1]: Starting DataStax Enterprise 1...
Mar 23 13:47:41 pspldsea01p.fleet.ad systemd[1]: Started DataStax Enterprise 1.
Mar 23 13:47:41 pspldsea01p.fleet.ad systemd[1]: Starting DataStax Enterprise 1...
Mar 23 13:47:44 pspldsea01p.fleet.ad dse[31267]: nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused'.
Mar 23 13:47:57 pspldsea01p.fleet.ad systemd[1]: Started DataStax Enterprise 1.
Mar 23 13:47:57 pspldsea01p.fleet.ad systemd[1]: Starting DataStax Enterprise 1...
Mar 23 13:48:01 pspldsea01p.fleet.ad dse[32004]: nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused'.
Hint: Some lines were ellipsized, use -l to show in full.如果我只是作为/opt/dse/dse1/bin/dse cassandra -k用户执行cassandra,它可以正常工作。
在正常的日志记录位置或使用sudo journalctl -u dse1,我似乎找不到任何额外的日志记录
有什么想法吗?谢谢!
发布于 2016-03-28 10:53:48
不幸的是,DataStax企业没有提供一个systemd服务文件来使用systemctl。但是,它确实附带了init脚本。完整的文档可在文档上获得。
基本上你有两个选择。第一个方法是通过启动服务直接使用init.d:
sudo service dse start不过,我现在也习惯于使用systemctl来回过头来了。这是我的systemd服务文件
[Unit]
Description=DataStax Enterprise
After=network.target
[Service]
PIDFile=/var/run/dse/dse.pid
ExecStart=/etc/init.d/dse start
ExecStop=/etc/init.d/dse stop
SuccessExitStatus=143
TimeoutSec=300
[Install]
WantedBy=multi-user.targetinit脚本有许多配置选项。为了简单起见,直接在脚本中使用这些可能是明智的。例如,在systemd服务文件中指定用户。这给我带来了问题,直到我注意到脚本中已经指定了用户。不需要重复选项。
SucessExitStatus=143选项是Java应用程序的常见配置。
如果没有在包管理器中安装DSE,则可能必须调整脚本的位置。
发布于 2020-06-08 17:28:49
添加这一点,以防迟发,但如果这可能有用的话。添加附加参数RemainAfterExit
/etc/systemd/system/dse1.服务
[Unit]
Description=DataStax Enterprise
[Service]
User=cassandra
RemainAfterExit=yes
ExecStart=/opt/dse/dse1/bin/dse cassandra -k
ExecStop=/opt/dse/dse1/bin/dse cassandra-stop
[Install]
WantedBy=multi-user.targethttps://stackoverflow.com/questions/36186819
复制相似问题