Issue when pointing data-dir to a different remote location

Good morning,

I have encountered a problem when trying to point data-dir to a remote location in /mnt. I have tried every possible way, but it doesn’t work. I modified the startup.sh file as indicated in the Geoserver documentation, but it still defaults to the initial data-dir location. I also tried declaring the variable within the same startup.sh file, but in this case, it creates a data folder inside webapps instead of taking the path I’m specifying. I also attempted to declare the environment variable in /etc/environment, but the same issue occurs as before. Could someone please help me? I can include screenshots if anyone needs them.

I assume you are running Debian/Ubuntu. If so, try editing the file

/lib/systemd/system/tomcat9.service

and add

ReadWritePaths=/mnt/

in the appropriate place. Then do

systemctl daemon-reload
systemctl restart tomcat9

I once solved a similar problem in this way. The reason is that Tomcat under Debian is sandboxed by systemd ( debian/README.Debian · master · Debian Java Maintainers / tomcat9 · GitLab) and that might be the problem you are having. Not sure if this is still the case in recent Debian versions.

2 Likes

Thank you very much for taking the time to answer, Mario!

I’m going to try your solution. I use Jetty, not Tomcat, but I guess the configuration will be similar.

I don’t have declared the service in the same way you indicate but I understand that creating the file jetty.service:

[Unit]
Description=Jetty Server
After=network.target

[Service]
Type=simple
User=geoserver
Group=geoserver
ExecStart=/usr/bin/java -Djetty.base=/usr/share/geoserver -DGEOSERVER_DATA_DIR=/mnt/geoserver-data -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /usr/share/geoserver/start.jar
ExecStop=/usr/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar /usr/share/geoserver/start.jar --stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

It should work.
Sorry for so many questions.

Have you tried setting the GEOSERVER_DATA_DIR environmental variable?

I was going to guess you were using the geoserver binary download… but it appears as if you are installing your own jetty service?

However you indicate:

modified the startup.sh file as indicated in the Geoserver documentation

What page is that on? I have not read those instructions… Your jetty.service file runs start.jar directly, and does not call bin/startup.sh.

Thank you for taking the time, Jody.

Yes, I have tried to declare the variable with export GEOSERVER_DATA_DIR=/var/lib/geoserver_data but it doesn’t work, in fact, if I do a $echo GEOSERVER_DATA_DIR it shows me the location I indicate but then the geoserver behaviour is not as expected.

I don’t understand very well the last part, if my configuration doesn’t call bin/startup.sh why now that I have it declared inside that file as GEOSERVER_DATA_DIR=‘/var/lib/geoserver-data’
export GEOSERVER_DATA_DIR does work, so it has to be initializing?

I have to stress that this case is different from the previous one, I can indicate a different location as long as this location is a local location, the problem is when I try to declare a location on a remote machine.

Thank you very much!

The startup.sh script you can read or add echo statements, or perhaps add some to your jetty.service file.

These feel a bit more like linux system admin questions then GeoServer questions - so I am not the best equipped to answer.

As for the difference between a local location and a remote location:

  • can you run geoserver startup.sh directly, just to see what works?
  • What user your service is running as - does that user have permission to access remote locations?