9

Thank-you for reading this. I am stuck at step three on this tutorial pertaining to installing Cassandra: http://wiki.apache.org/cassandra/GettingStarted#Step_3:_Start_Cassandra

I can only run this software as root. (shouting this over fictional helicopter noise) This seem like a terrible way to run the software.

When starting the Cassandra server as my normal user I receive the following errors:

1.) 15:46:00,147 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/var/log/cassandra/system.log,true) call failed. java.io.FileNotFoundException: /var/log/cassandra/system.log (Permission denied)

2.) ERROR 20:46:00 Doesn't have write permissions for /var/lib/cassandra/data directory

I tried changing the permissions several times and nothing has worked. I tried changing the /var/log/cassandra/system.log permissions for read/write for the cassandra group on the operating-system (OS). The command I used to do this was, sudo chmod 664 /var/log/cassandra/system.log. I found this page helpful in determining how to change the permissions:http://www.linux.org/threads/file-permissions-chmod.4094/

Then, I added my user-name to the cassandra group. From my understanding running the /usr/sbin/cassandra -f command as my user should allow me to access the /var/log/cassandra/system.log file, which would solve one of the errors, error number 1 above.

Respectfully,

user

user3808269
  • 1,321
  • 3
  • 21
  • 40

2 Answers2

14

Give the user you want permissions to the data and commitlog dirs.

sudo chown -R cassandra:cassandra /var/lib/cassandra/data


sudo chown -R cassandra:cassandra /var/lib/cassandra/commitlog
phact
  • 7,305
  • 23
  • 27
  • These things are already owned by `cassandra` user but I am trying to run the cassandra program as the normal user, lets say `foo` on my operating-system. I was looking to change the permissions on the `/var/log/cassandra/system.log` anyway not the `/var/lib/cassandra/commitlog`. – user3808269 Oct 09 '15 at 22:42
  • Why do you want to run Cassandra as a normal user? – phact Oct 09 '15 at 22:43
  • The user needs access to all the files – phact Oct 09 '15 at 22:44
  • In terms of information-security it is risky to run a server as root. – user3808269 Oct 09 '15 at 22:51
  • The cassandra user is not root. – phact Oct 09 '15 at 22:51
  • the cassandra group and cassandra user has the privileges to read and write on the `system.log` file so I am not sure why it is unable to write to that log when starting the program like so `/usr/sbin/cassandra -f` as a regular non-root operating system user. – user3808269 Oct 09 '15 at 22:55
  • The cassandra user is a regular non root os user, if you start the process as cassandra it will start given what you mentioned about the permissions you have granted. However, your other users may not have the same privileges. – phact Oct 09 '15 at 22:57
  • 'sudo su - cassandra -s /bin/bash' '/usr/bin/cassandra -f' – phact Oct 09 '15 at 22:59
  • Alternatively, just use the DataStax package install that take care of permissions for you and register cassandra as a service. 'sudo service cassandra start' – phact Oct 09 '15 at 23:00
  • I tried the `sudo su - cassandra -s /bin/bash /usr/bin/cassandra -f` command but this did not work. I just received some sort of usage prompt from `su`. Also, maybe I messed up my installation because I did use the DataStax Ubuntu Linux Debian binary and am unable to start Cassandra as a service. – user3808269 Oct 09 '15 at 23:32
  • They are two separate commands one to access the shell as the cassandra user. The next to start the service from that shell. – phact Oct 09 '15 at 23:34
  • I found a solution! I ran `sudo -u cassandra /usr/sbin/cassandra -f` and then ran into problems with the `commitlog` you mentioned in your answer. I then ran your recursive `chown` command and it started up correctly just as would as the `root` user. :D :D :D – user3808269 Oct 09 '15 at 23:42
  • Good deal glad to help – phact Oct 09 '15 at 23:43
11

I found a solution! I ran sudo -u cassandra /usr/sbin/cassandra -f and then ran into problems with the commitlog directory Phact mentions in his answer. I then ran Phact's recursive chown command, sudo chown -R cassandra:cassandra /var/lib/cassandra/commitlog and the Cassandra server started up correctly just as it would if I was running the program as the root user. :D :D :D

user3808269
  • 1,321
  • 3
  • 21
  • 40