Title
#users-public
m

Muhammad Amal

11/17/2022, 1:51 AM
hi questdb team, I wanna ask. how to start questdb on startup linux ubuntu server. I’ve questdb on VM, but if the vm restarted questdb not running automatically. this case show when the cloud service provider maintenance and the instance must be restart.
Pei

Pei

11/17/2022, 3:08 AM
are you running QuestDB via docker or the binary directly?
m

Muhammad Amal

11/17/2022, 4:52 AM
binary @Pei
9:02 AM
@Andrey Pechkurov can you help me, please
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 9:07 AM
You should use
systemd
to create a service for QDB and run it on startup. See this instruction:https://askubuntu.com/a/976948
m

Muhammad Amal

11/17/2022, 9:10 AM
I’ve do that, but when I try to restart instance. still not working
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 9:15 AM
Could you share your systemd service conf?
m

Muhammad Amal

11/17/2022, 9:19 AM
like this
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 9:28 AM
Try adding
ExecStop=/root/qdb/bin/questdb.sh stop
9:28 AM
Right below
ExecStart
9:28 AM
This will tell systemd how to stop the service
m

Muhammad Amal

11/17/2022, 9:31 AM
i’ve done, so what next ?
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 9:32 AM
Try restarting the service via systemd
9:32 AM
It should work now
9:33 AM
don't forget to reload systemd itself first:
systemctl daemon-reload
systemctl restart
9:34 AM
otherwise it won't pick up the changes in the
.service
file
m

Muhammad Amal

11/17/2022, 9:40 AM
still not work
9:49 AM
9:49 AM
@Andrey Pechkurov
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 9:50 AM
[Unit]
Description=QuestDB

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/root/qdb/bin/questdb.sh start
ExecStop=/root/qdb/bin/questdb.sh stop
9:50 AM
try this
[Service]
config
m

Muhammad Amal

11/17/2022, 9:55 AM
but I can’t access the questdb
9:55 AM
10:02 AM
@Andrey Pechkurov
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:04 AM
does
curl <http://127.0.0.1:9000>
return anything?
10:04 AM
on the server, not on your machine
10:04 AM
If it does, then the database has started successfully and you should be looking into your network configuration
m

Muhammad Amal

11/17/2022, 10:09 AM
I’ve change the port on config questdb file. so what must i do ?
10:13 AM
@Andrey Pechkurov
10:15 AM
why config file does’t work, when run by systemd ?
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:15 AM
looks like the database has started on port 9000
10:16 AM
how do you set the port?
m

Muhammad Amal

11/17/2022, 10:16 AM
but I try access port 9000 on browser. still not work
10:17 AM
i set the port with server.conf file questdb and then expose the port
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:17 AM
where is
server.conf
located? if it's a non-default root dir, you need to pass it to
questdb.sh
10:18 AM
./questdb.sh -d <path_to_your_root_dir>
10:18 AM
default root dir is
$HOME/.questdb
m

Muhammad Amal

11/17/2022, 10:18 AM
@Andrey Pechkurov
10:21 AM
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:22 AM
I don't think systemd runs services under
root
10:23 AM
If you need to run them as root (which is not recommended), you should configure your systemd service accordingly
10:23 AM
Should be something like
User=root
Group=root
m

Muhammad Amal

11/17/2022, 10:25 AM
so what must i do @Andrey Pechkurov?
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:25 AM
edit .service file and restart systemd and the service
10:26 AM
or specify the root dir explicitly, but make sure that the default user (
ubuntu
) has the access
m

Muhammad Amal

11/17/2022, 10:27 AM
where i must add the
User=root
Group=root
?
10:30 AM
@Andrey Pechkurov
10:32 AM
like this ?
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:33 AM
yes, it should be in
[Service]
m

Muhammad Amal

11/17/2022, 10:39 AM
alright, working perfectly right now. thanks ever so much @Andrey Pechkurov for your help
Andrey Pechkurov

Andrey Pechkurov

11/17/2022, 10:40 AM
Great to hear that 🤝