3

When I try to start cassandra on ubuntu 12.04 (installed via Datastax's dsc20 package) as a service as follows :

$ sudo service cassandra start

it says

*could not access pidfile for Cassandra

& no other messages or anything in logs.

But when I try to run as a root user( sudo cassandra -f) it just works properly & cassandra is started. While trying to debug I found that when trying to run as a non-root user I was getting these messages:

ERROR 17:48:08,432 Exception encountered during startup
java.lang.AssertionError: Directory /var/lib/cassandra/data is not accessible.
..
java.io.FileNotFoundException: /var/log/cassandra/system.log (Permission denied)
..
java.lang.AssertionError: Directory /var/lib/cassandra/data is not accessible.

Is there some problem with the packaging ? Not properly installed/ configured by package ??

Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294

2 Answers2

8

By default the cassandra service does not and should not run as root.

My guess is you ran it in the foreground first, which automatically will create /var/lib/cassandra with root permissions instead of with the cassandra permissions. Either chown -R /var/lib/cassandra with the appropriate group and user or blow away the directory and try starting the service again.

Ryan Svihla
  • 136
  • 4
  • However is this a practical approach? should I just delete the entire folders as such & let cassandra create new folders ? Wouldn't that reduce some information from cassandra? (like the opscenter keyspaces which were there by default but wont be created by cassandra itself ? or anything else I dont know!). – Rajat Gupta Mar 10 '14 at 21:13
  • Practical approach is a big conversation. Ideally you're starting the service as it's user on a new install and not using root (where you went off the rails there). chown will work if you're concerned about retaining data. – Ryan Svihla Mar 11 '14 at 14:45
  • 2
    `sudo chown -R cassandra:cassandra /var/lib/cassandra` worked for me - thx – mujimu Jun 16 '14 at 23:19
0
$ su cassandra

then run

$ service cassandra start

It works for me.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109