Error using buildtsi with sudo

I would like to convert my tsm data to tsi. I tried using the buildtsi command but it says I need root permissions because it will create directories where I have my influx data (/var/lib/influxdb/data), but when I give it the sudo command it says I will not have access to the data unless I run influx as root. Any thoughts on how I should proceed? Thanks

sudo influx_inspect buildtsi -datadir /var/lib/influxdb/data/ -waldir /var/lib/influxdb/wal/
You are currently running as root. This will build your
index files with root ownership and will be inaccessible
if you run influxd as a non-root user. You should run
buildtsi as the same user you are running influxd.
Are you sure you want to continue? (y/N):

The sudo command lets you run programs as another user; by default, root. So when you run sudo influx_inspect buildtsi ..., it runs as the root user and any files that are created will be owned by root.

When installed properly on Linux, for example, InfluxDB runs as the influxdb user, and so it will be unable to read any files owned by root. This is why the error recommends that:

You should run buildtsi as the same user you are running influxd

influx_inspect buildtsi does not require root access; we recommend that you do not run the command as root.

If you’re running on Linux you can use the following command to run the process as the influx user:

sudo -u influxdb influx_inspect buildtsi -datadir /var/lib/influxdb/data/ -waldir /var/lib/influxdb/wal/

Super, that worked great. I was not aware that you could use sudo with -u. That’s definitely a good trick to know!

1 Like