4

For a service although a pid file exists, but still when attempting to start service, it fails saying:

$ sudo service cassandra start
* could not access pidfile for Cassandra

I verified folder permissions under /var/run (whose owner is root) and the subfolder cassandra is owned by cassandra user, but still the service cannot access pid file even though I verified that pid file exists. (Also pid is allocated). So why does it say it can't access pidfile?

And running cassandra as a standalone process just works, but not just using service cassandra start

$ sudo ls -l /var/run/cassandra 
total 4 
-rw-r--r-- 1 cassandra cassandra 4 Mar 18 07:33 cassandra.pid
$ sudo su
# ls -ld /var/run/cassandra 
dr--r----- 2 cassandra cassandra 60 Mar 18 07:38 /var/run/cassandra

How do I make this work using sudo service cassandra start ?

9
  • How did you install Cassandra?
    – Danatela
    Mar 18, 2014 at 5:50
  • sudo apt-get install cassandra dsc20 Mar 18, 2014 at 6:39
  • Then just run sudo dpkg-reconfigure cassandra
    – Danatela
    Mar 18, 2014 at 6:42
  • tried this out.. but no effect still same error.. Mar 18, 2014 at 6:56
  • Then try to remove pid file and start cassandra.
    – Danatela
    Mar 18, 2014 at 6:59

3 Answers 3

5

You have to remove /var/run/cassandra folder hence it has wrong permissions:

sudo rm -rf /var/run/cassandra

Or you can fix permissions manually:

sudo chmod 750 /var/run/cassandra

Then start Cassandra as service:

sudo service cassandra start


Some explanations

Instructions of file permissions you can find here.

  • It is safe to delete that folder because it recreates with right permissions and content. But do not delete it once it works correct. It may result in loss of data or incorrect behavior.

  • chmod 750 decrypts as rwxr-x--- permissions. It allows read-write-execute to the user, read-execute to the group and nothing to others. For Cassandra, it is enough to set permissions so.

4
  • is it safe to remove this folder ? does it get created as it was before ? Mar 18, 2014 at 7:48
  • 1
    I updated the answer.
    – Danatela
    Mar 18, 2014 at 8:02
  • Thanks, if after deleting /var/run/cassandra if it works/ runs, does that mean it has not lost any data ? Mar 18, 2014 at 8:17
  • 1
    Probably does. Sorry, I don't know the purpose of Cassandra. May be you will find info about this in it's manual.
    – Danatela
    Mar 18, 2014 at 8:21
2

This solution can be achieved the following way:

$ sudo vim /etc/init.d/cassandra;

Find the following line:

CMD_PATT="cassandra.+CassandraDaemon"

Replace by:

CMD_PATT="cassandra"

Save and stop and start again. Service will get status correctly; Tested on cassandra 2.3

Source here: https://www.digitalocean.com/community/tutorials/how-to-install-cassandra-and-run-a-single-node-cluster-on-ubuntu-14-04 (check STEP 3)

0

My solution for migration of Cassandra 2.0.9 to 2.1.4

After upgrade with

sudo apt-get install dsc21

Go to log file:

tail -f /var/log/cassandra/system.log

You can see you need to modify your cassandra configuration file.

  1. Stop Cassandra

    sudo /etc/init.d/cassandra stop
    
  2. Go to Cassandra configuration file

    sudo vi /etc/cassandra/cassandra.yaml
    
  3. Comment out these 5 lines or remove them:

    • multithreaded_compaction: false
    • preheat_kernel_page_cache: false
    • memtable_flush_queue_size: 4
    • in_memory_compaction_limit_in_mb: 64
    • compaction_preheat_key_cache: true
  4. Start Cassandra

    sudo /etc/init.d/cassandra start
    
  5. Verify

    nodetool status
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .