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 ?

karel
  • 110,292
  • 102
  • 269
  • 299
Rajat Gupta
  • 521
  • 2
  • 10
  • 23

3 Answers3

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.

Danatela
  • 13,581
  • 11
  • 44
  • 70
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)

Joepreludian
  • 121
  • 2
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
    
Byte Commander
  • 105,631
  • 46
  • 284
  • 425
Fred
  • 1
  • 1