-
-
Save s0undt3ch/969b744d3d7b88c29cba to your computer and use it in GitHub Desktop.
# /usr/lib/systemd/system/cassandra.service | |
[Unit] | |
Description=Cassandra | |
After=network.target | |
[Service] | |
PIDFile=/var/run/cassandra/cassandra.pid | |
User=cassandra | |
Group=cassandra | |
ExecStart=/usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid | |
StandardOutput=journal | |
StandardError=journal | |
LimitNOFILE=100000 | |
LimitMEMLOCK=infinity | |
LimitNPROC=32768 | |
LimitAS=infinity | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
Hi. Can I use this method in ubuntu server(AWS instance) too?
Thank you! Big help in my chef recipe.
how come there is no ExecStop command?
how come there is no ExecStop command?
You can put this in file:
ExecStop=/bin/kill -s 15 $MAINPID
Thank you!! This was helpful.
worth adding:
EnvironmentFile=-/etc/default/cassandra
Thank you, it's very helpfull ! :)
Thank you, very helpfull,
I was facing with a strange problem with Cassandra, nomore managed correctly as service on Centos7 because such file was missing after a yum update.
Putting that file under /usr/lib/systemd/system/ and doing a "systemctl daemon-reexec" solved my problem :-)
Not sure why a PID file is being set if the unit is left to default to simple?
After some tries I've created upgraded version of this unit file.
Changes:
- use background run +
Type=forking
because-p
works only without-f
- use CASSANDRA_* env variables to load cassandra configs from /etc/cassandra/conf, those are created by cassandra RPM package
- upd 28.08.2020: add stop timeout
- upd 28.08.2020: set successful exit code
Tested with cassandra 3.11.5 & centos 7.7
# /usr/lib/systemd/system/cassandra.service
[Unit]
Description=Cassandra
After=network.target
[Service]
RuntimeDirectory=cassandra
PIDFile=/var/run/cassandra/cassandra.pid
Environment=CASSANDRA_HOME=/usr/share/cassandra
Environment=CASSANDRA_CONF=/etc/cassandra/conf
Environment=CASSANDRA_INCLUDE=/usr/share/cassandra/cassandra.in.sh
Environment=CASSANDRA_OWNR=cassandra
User=cassandra
Group=cassandra
Type=forking
ExecStart=/usr/sbin/cassandra -p /var/run/cassandra/cassandra.pid
StandardOutput=journal
StandardError=journal
LimitNOFILE=100000
LimitMEMLOCK=infinity
LimitNPROC=32768
LimitAS=infinity
Restart=always
TimeoutStopSec=180
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Tested on CentOS 8, works!
On my sysV file I call the following command when stopping cassandra:
nodetool -u cass** -pw pass** -h 127.0.0.1 decommission
Do I need to do this in systemd file as a ExecStopPost command?
Should be useful in forking mode:
TimeoutStartSec=300
But foreground mode seems more stable (imho).
Do you have an updated cassandra.service for version 3.10?