Linux - installation on a diffrent user than root

Hello,

Is it possible to install CockroachDB from binary using a diffrent user than root?
Also without using sudo.

Even with granting all nessery priviligies to newly created user - cockroach, I’m still not allowed to start database.

-rwxr-x—. 1 cockroach cockroach 56360696 Jun 18 18:12 cockroach
[cockroach@servername cockroach]$ ./cockroach start
-bash: ./cockroach: Permission denied

Thank you in advance!

Hello Bernard,
thank you for your interest in CockroachDB.

In addition to the permissions on the cockroach binary you must ensure that CockroachDB can write to the store directory (by default the cockroach-data sub-directory, but you can configure this with --store).

The following works for me:

$ mkdir crdb
$ chown cockroach:cockroach crdb
$ chmod 0750 crdb    # ensure the directory is writable by the new user
$ cd crdb
$ copy /path/to/cockroach .
$ chown cockroach:cockroach cockroach   # the program file
$ chmod 0750 cockroach # ensure program executable by user
$ su - cockroach 
$ ./cockroach start

Does this help?

Hi,

Thank you for the quick response!

Unfortunatelly I have already done this before and this solution did not work for me.
I tried one more time as you suggested, just to be sure.

[cockroach@servername ~] mkdir crdb [cockroach@servername ~] chown cockroach:cockroach crdb
[cockroach@servername ~] chmod 0750 crdb [cockroach@servername ~] ll
total 20184
drwxr-x—. 2 cockroach cockroach 22 Jul 27 12:37 cockroach
-rw-r-----. 1 cockroach cockroach 20665893 Jun 28 14:57 cockroach-v2.0.3.linux-amd64.tgz
drwxr-x—. 2 cockroach cockroach 6 Jul 30 09:55 crdb
[cockroach@servername ~] cd crdb [cockroach@servername crdb] cp /home/cockroach/cockroach/cockroach .
[cockroach@servername crdb] ll total 55040 -rwxr-x---. 1 cockroach cockroach 56360696 Jul 30 09:56 cockroach [cockroach@servername crdb] chown cockroach:cockroach cockroach
[cockroach@servername crdb] chmod 0750 cockroach [cockroach@servername crdb] ll
total 55040
-rwxr-x—. 1 cockroach cockroach 56360696 Jul 30 09:56 cockroach

[cockroach@servername crdb]$ ./cockroach start
-bash: ./cockroach: Permission denied

Unfortunatelly it still doesn’t work.

This needs further investigation on your side, because most of our users do the same as you do (and we do the same internally) and it always works :slight_smile:

Let me help you check a few things:

  • what operating system is this?
  • if Linux, do you have SELinux or AppArmor enabled? If yes, can you check the security logs to see if execution has been denied?
  • is there a difference between the effective user and actual user? (id -u vs id -ru)
  • can you perform syscall tracing on the execution to determine where the error occurs precisely? (run strace cockroach start on linux, or ktrace cockroach start then kdump on BSD/OSX)

@Bernard, do you still need assistance here?