Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing password PostgreSQL database for advanced installation (Ubuntu 18.04) #61

Open
danjde opened this issue Oct 12, 2020 · 13 comments

Comments

@danjde
Copy link

danjde commented Oct 12, 2020

Hi Devs,
I'm trying to figure out how to change PostgreSQL database password, and I ask if possible to add them in the GeoNode Advanced Installation documentation.

These are the steps performed:

  1. changed /opt/geonode/geonode/local_settings.py -> 'PASSWORD' on:
# Backend
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'geonode',
        'USER': 'geonode',
        'PASSWORD': 'new-password',



per il DB di Geoserver:

    # vector datastore for uploads
    'datastore': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        # 'ENGINE': '', # Empty ENGINE name disables
        'NAME': 'geonode_data',
        'USER': 'geonode',
        'PASSWORD': 'new-password',
  1. Changing DB password on Postgresql:

psql -U postgres
ALTER USER geonode WITH ENCRYPTED PASSWORD 'new-password';

  1. update Geonode infrastructure:
DJANGO_SETTINGS_MODULE=geonode.local_settings python manage.py collectstatic --noinput
DJANGO_SETTINGS_MODULE=geonode.local_settings python manage.py migrate_baseurl --source-address=http://localhost --target-address=http://www.example.org
  1. reload services:
sudo systemctl daemon-reload
sudo service uwsgi restart
systemctl restart tomcat
sudo systemctl restart nginx

These steps are obviously not complete, as the Oauth2 connection with Geoserver is compromised: is possible to login to Goeserver web interface, but from Geonode is still not possible to upload layer, etc..

Kindly is it possible to clarify the right steps to be performed?

Thanks!

@danjde danjde changed the title Changing password PostgreSQL database fro advanced instalaltion (Ubuntu 18.04) Changing password PostgreSQL database fro advanced installation (Ubuntu 18.04) Oct 12, 2020
@danjde danjde changed the title Changing password PostgreSQL database fro advanced installation (Ubuntu 18.04) Changing password PostgreSQL database for advanced installation (Ubuntu 18.04) Oct 12, 2020
@afabiani
Copy link
Member

Hi @danjde sure, do you have the chance to send PRs directly to

https://github.com/GeoNode/documentation

We will review them and merge accordingly.

@danjde
Copy link
Author

danjde commented Oct 12, 2020

Maybe I wasn't clear,
I ask to you if could check the accuracy of the steps described above by me and integrate them where necessary with the missing ones.
My knowledge of these passages is sketchy and probably inaccurate.

@afabiani
Copy link
Member

Oh, I see. So ...

If you just need to update the DB password, the steps 1 and 2 are ok, the others are not strictly required.

Then, you will need to login into GeoServer admin panel, go to "stores", search for the datastore with the same name of the postgis engine (in your example 'NAME': 'geonode_data'), edit it and change the password accordingly from the connection parameters.

That's it.

@danjde
Copy link
Author

danjde commented Oct 12, 2020

[...] GeoServer admin panel, go to "stores", search for the datastore with the same name of the postgis engine (in your example 'NAME': 'geonode_data'), edit it and change the password accordingly from the connection parameters.

That's what I thought, but using a system coming from the advanced installation, "Stores" results empty as below:

Schermata del 2020-10-12 17-52-56

Is it normal? Should it be created? Is it correct to do so? Using "PostGIS - PostGIS Database"?

Thanks!

@afabiani
Copy link
Member

If the store does not exist yet (meaning that you most probably haven't uploaded any layer yet) there's no need to update it. GeoNode will create it automatically by using the settings params.

@danjde
Copy link
Author

danjde commented Oct 12, 2020

If the store does not exist yet (meaning that you most probably haven't uploaded any layer yet)

True, no layer yet

GeoNode will create it automatically by using the settings params.

But in this case, why Geonode does give me connection errors when I try to load a new layer, only after changing the two passwords?

# vector datastore for uploads

and

# Backend

Somehow I'll have to give it that I changed my passwords? Where?

Thanks

@afabiani
Copy link
Member

which installation method?

@danjde
Copy link
Author

danjde commented Oct 12, 2020

GeoNode Advanced Installation Ubuntu 18.04

Thanks

@afabiani
Copy link
Member

afabiani commented Oct 12, 2020

Uhm, that's strange, that should not happen... did you change the geoserver admin password too?

@afabiani
Copy link
Member

afabiani commented Oct 12, 2020

Oh wait... stating from your inputs above, you will need to do also

ALTER USER geonode_data WITH ENCRYPTED PASSWORD 'new-password';

Or use the same user for both databases.

Ignore this comment, I noticed that you are using the same DB user.

@danjde
Copy link
Author

danjde commented Oct 12, 2020

Yes, I've previous changed the admin Geonode and Geoserver password as described here

But everything worked well, only changing the two passwords, I couldn't load the layers anymore.

Now I rerun:

sudo PYTHONWARNINGS=ignore VIRTUAL_ENV=$VIRTUAL_ENV DJANGO_SETTINGS_MODULE=geonode.local_settings GEONODE_ETC=/opt/geonode GEOSERVER_DATA_DIR=/opt/data/geoserver_data TOMCAT_SERVICE="service tomcat" APACHE_SERVICE="service nginx" geonode_updateip -l localhost -p www.mysite.org

and verify...

Thanks

@afabiani
Copy link
Member

Whenever you change the admin password on the GeoNode settings, be sure to align the GeoServer internal admin user as well as described here

https://docs.geonode.org/en/master/install/basic/index.html#geoserver-setup

if still not working, try to look for some stacktrace or error on both GeoNode and GeoServer logs.

@t-book
Copy link
Collaborator

t-book commented Oct 12, 2020

@danjde Provided your geoserver data directory lives under /opt/data check the following:

In case Postgis stores exist you will find them by use of:
grep -R postgis /opt/data

If you find something and you need to alter it you can always open the file in question in a editor and set the password as plain value:
<entry key="passwd">plain:password</entry>

In case you set it to plain be sure to later update the value by use of the geoserver gui to encrypt the password.

However, at least you now know you need to update a password.

Furthermore, not only postgis vector stores but geofence connection needs to be updated as well. The grep from above will show you the right place.

The command you provided above takes care of updating urls not passwords. As @afabiani said my first guess as well is your admin password from local_settings does not fit the admin passwort with geoserver. Please double check the password in geoserver user section (gui) or directly set it in geoserver data dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants