[GeoNode-users] GeoNode-Project Docker Postgres Access
Julierme Pinheiro
juliermeopensourcedeveloper at gmail.com
Tue Jan 15 04:09:29 PST 2019
Hi Francesco,
I got it. I do not know if makes sense. GeoNode-Project at 2.7 had HOST:'db'
in its local_settings. In my case, in order to have GeoNode -Project
working after setting docker-compose.override.yml to 172.21.14.02, I had to
change from HOST: 'localhost' to HOST: 'db'.Now, it is working.
I appreciated your time and patience
Kind regards
Julierme
On Mon, Jan 14, 2019 at 7:46 PM Francesco Bartoli <xbartolone at gmail.com>
wrote:
> Right but I believe that is optional, and if applied you have to make sure
> to understand what are the consequences in overriding some variables of
> base settings.
>
> Ciao
> Francesco
> Il 14 gen 2019, 22:35 +0100, Julierme Pinheiro <
> juliermeopensourcedeveloper at gmail.com>, ha scritto:
>
> Hi Francesco,
>
> I went through step 4 and 5 because there is note on the guide(
> https://github.com/GeoNode/geonode-project/tree/2.8): that says:
>
> Run docker-compose to start it up (get a cup of coffee or tea while you
> wait)
>
> *2 - Remember to update "wsgi.py" in case you are using "local_settings"
> vim my_geonode/wsgi.py --> os.environ.setdefault("DJANGO_SETTINGS_MODULE",
> "my_geonode.local_settings")*
>
> I appreciated your time
>
>
> Julierme
>
>
>
> On Mon, Jan 14, 2019 at 7:28 PM Francesco Bartoli <xbartolone at gmail.com>
> wrote:
>
>> Actually I don’t understand why you are doing steps 4. And 5.
>>
>> Ciao
>> Francesco
>> Il 14 gen 2019, 22:05 +0100, Julierme Pinheiro <
>> juliermeopensourcedeveloper at gmail.com>, ha scritto:
>>
>> ... output for docker ps:
>>
>> 0edbae6e9989 geonode/nginx:geoserver "nginx -g 'daemon of…" 6
>> minutes ago Up 6 minutes 0.0.0.0:80->80/tcp
>> nginx4my_geonode
>> f71aed729615 my_geonode_django "/usr/src/my_geonode…" 6
>> minutes ago Restarting (1) 21 seconds
>> ago django4my_geonode
>> d1307b6eca5a my_geonode_celery "/usr/src/my_geonode…" 6
>> minutes ago Restarting (1) 59 seconds
>> ago celery4my_geonode
>> 9865b9317a98 geonode/geoserver:2.13.x "/usr/local/tomcat/t…" 6
>> minutes ago Up 6 minutes
>> 8080/tcp geoserver4my_geonode
>> b63b3eed5560 geonode/postgis:9.6 "docker-entrypoint.s…"
>> 16 minutes ago Up 6 minutes
>> 5432/tcp db4my_geonode
>> c70325c1f57e elasticsearch:2.4.1 "/docker-entrypoint.…"
>> 16 minutes ago Up 6 minutes 9200/tcp,
>> 9300/tcp elasticsearch4my_geonode
>> 4412fd012ca9 rabbitmq "docker-entrypoint.s…"
>> 16 minutes ago Up 6 minutes 4369/tcp,
>> 5671-5672/tcp, 25672/tcp rabbitmq4my_geonode
>>
>> and out put for docker-compose ps
>>
>> celery4my_geonode /usr/src/my_geonode/entryp ...
>> Restarting
>> db4my_geonode docker-entrypoint.sh postgres Up
>> 5432/tcp
>> django4my_geonode /usr/src/my_geonode/entryp ...
>> Restarting
>> elasticsearch4my_geonode /docker-entrypoint.sh elas ... Up
>> 9200/tcp, 9300/tcp
>> geoserver4my_geonode /usr/local/tomcat/tmp/entr ... Up
>> 8080/tcp
>> gsconf4my_geonode /bin/true Exit
>> 0
>> nginx4my_geonode nginx -g daemon off; Up
>> 0.0.0.0:80->80/tcp
>> rabbitmq4my_geonode docker-entrypoint.sh rabbi ... Up
>> 25672/tcp, 4369/tcp, 5671/tcp, 5672/tcp
>>
>> Kind Regards
>>
>> Julierme
>>
>>
>> On Mon, Jan 14, 2019 at 7:02 PM Julierme Pinheiro <
>> juliermeopensourcedeveloper at gmail.com> wrote:
>>
>>> Hi Francesco,
>>>
>>> Thank you very much for your reply. After our discussion in here. I
>>> started all over again and I will report the installation step by step.
>>>
>>> 1 - docker-compose down
>>>
>>> 2 - docker system prune -a
>>>
>>> 3 - docker-compose.override.yml is in its default pattern
>>>
>>> version: '2'
>>> services:
>>> django:
>>> environment:
>>> DEBUG: 'True'
>>> GEONODE_LB_HOST_IP: localhost
>>> GEONODE_LB_PORT: 80
>>> SITEURL: http://localhost/
>>> ALLOWED_HOSTS: "['localhost']"
>>> GEOSERVER_PUBLIC_LOCATION: http://localhost/geoserver/
>>>
>>> celery:
>>> environment:
>>> DEBUG: 'True'
>>> GEONODE_LB_HOST_IP: localhost
>>> GEONODE_LB_PORT: 80
>>> SITEURL: http://localhost/
>>> ALLOWED_HOSTS: "['localhost']"
>>> GEOSERVER_PUBLIC_LOCATION: http://localhost/geoserver/
>>>
>>> geoserver:
>>> environment:
>>> GEONODE_LB_HOST_IP: localhost
>>> GEONODE_LB_PORT: 80
>>> NGINX_BASE_URL:
>>>
>>> 4 - cp ...my_geonode/local_settings.py.sample my_geonode/local_settings.py
>>>
>>> 5 - vim ... my_geonode/wsgi.py
>>>
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_geonode.local_settings")
>>>
>>> 6 - docker-compose build --no-cache
>>>
>>> 7 - docker-compose up -d
>>>
>>> 8 - docker-compose stop
>>>
>>>
>>> 9 - vim docker-compose.override.yml
>>>
>>> version: '2'
>>> services:
>>> django:
>>> environment:
>>> DEBUG: 'True'
>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>> GEONODE_LB_PORT: 80
>>> SITEURL: http://172.21.14.02/
>>> ALLOWED_HOSTS: "['172.21.14.02']"
>>> GEOSERVER_PUBLIC_LOCATION: http://172.21.14.02/geoserver/
>>>
>>> celery:
>>> environment:
>>> DEBUG: 'True'
>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>> GEONODE_LB_PORT: 80
>>> SITEURL: http://172.21.14.02/
>>> ALLOWED_HOSTS: "['172.21.14.02']"
>>> GEOSERVER_PUBLIC_LOCATION: http://172.21.14.02/geoserver/
>>>
>>> geoserver:
>>> environment:
>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>> GEONODE_LB_PORT: 80
>>> NGINX_BASE_URL:
>>>
>>> 10 - docker-compose up --build -d
>>>
>>> 11 - docker ps
>>>
>>> 12 - docker-compose ps
>>>
>>> 13 - docker-compose logs -f django
>>> django4my_geonode | django.db.utils.OperationalError: could not connect to server: Connection refused
>>> django4my_geonode | Is the server running on host "localhost" (127.0.0.1) and accepting
>>> django4my_geonode | TCP/IP connections on port 5432?
>>> django4my_geonode | could not connect to server: Network is unreachable
>>> django4my_geonode | Is the server running on host "localhost" (::1) and accepting
>>> django4my_geonode | TCP/IP connections on port 5432?
>>>
>>> 14 - docker-compose logs -f celery
>>>
>>> celery4my_geonode | django.db.utils.OperationalError: could not connect to server: Connection refused
>>> celery4my_geonode | Is the server running on host "localhost" (127.0.0.1) and accepting
>>> celery4my_geonode | TCP/IP connections on port 5432?
>>> celery4my_geonode | could not connect to server: Network is unreachable
>>> celery4my_geonode | Is the server running on host "localhost" (::1) and accepting
>>> celery4my_geonode | TCP/IP connections on port 5432?
>>>
>>> I am still having the issue related to database connection.
>>>
>>> Kind regards
>>>
>>> Julierme
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Jan 14, 2019 at 3:51 PM Francesco Bartoli <xbartolone at gmail.com>
>>> wrote:
>>>
>>>> Some questions inline to figure out your environment.
>>>> Il 14 gen 2019, 18:26 +0100, Julierme Pinheiro <
>>>> juliermeopensourcedeveloper at gmail.com>, ha scritto:
>>>>
>>>> Hi Francesco,
>>>>
>>>> Thank you very much for your reply.
>>>>
>>>> I changed the docker-compose.override.yml from localhost to
>>>> 172.21.14.02 (Centos7 VM IP running GeoNode-Project installed via docker).
>>>> After doing that, geonode django and celery container logs point to the
>>>> error:
>>>>
>>>> django4my_geonode | django.db.utils.OperationalError: could not connect
>>>> to server: No route to host
>>>> django4my_geonode | Is the server running on host "localhost" (::1)
>>>> and accepting
>>>> django4my_geonode | TCP/IP connections on port 5432?
>>>>
>>>> Trying to solve this issue, as localhost corresponds to 172.21.14.02, I
>>>> went to local_settings and changed from DATABASES: { HOST: 'localhost' ,
>>>> to DATABASES: { HOST: '172.21.14.02'}, geonode django and celery container
>>>> logs point to the error:
>>>>
>>>> django4my_geonode | django.db.utils.OperationalError: could not connect
>>>> to server: No route to host
>>>> django4my_geonode | Is the server running on host "172.21.14.02"
>>>> and accepting
>>>> django4my_geonode | TCP/IP connections on port 5432
>>>>
>>>> The error remains the same.
>>>>
>>>> Yes. db4my_geonode is up and running. And find bellow the outcome for
>>>> docker-compose ps:
>>>>
>>>> celery4my_geonode /usr/src/my_geonode/entryp ...
>>>> Restarting
>>>> db4my_geonode docker-entrypoint.sh postgres
>>>> Up 5432/tcp
>>>> django4my_geonode /usr/src/my_geonode/entryp ...
>>>> Restarting
>>>> elasticsearch4my_geonode /docker-entrypoint.sh elas ...
>>>> Up 9200/tcp, 9300/tcp
>>>> geoserver4my_geonode /usr/local/tomcat/tmp/entr ...
>>>> Up 8080/tcp
>>>> gsconf4my_geonode /bin/true Exit
>>>> 0
>>>> nginx4my_geonode nginx -g daemon off;
>>>> Up 0.0.0.0:80->80/tcp
>>>> rabbitmq4my_geonode docker-entrypoint.sh rabbi ...
>>>> Up 25672/tcp, 4369/tcp, 5671/tcp, 5672/tcp
>>>>
>>>>
>>>> In order to access geonode site from my workstation, I am supposed to
>>>> configure DATABASES as HOST:'172.21.14.02'. Am I correct? If so, why the
>>>> database connection has been refused?
>>>>
>>>>
>>>> Just to avoid confusion here. If your host where you want to navigate
>>>> GeoNode is 172.21.14.02 then your docker-compose override yaml file should
>>>> look like:
>>>>
>>>> version: '2'
>>>> services:
>>>> django:
>>>> environment:
>>>> DEBUG: 'True'
>>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>>> GEONODE_LB_PORT: 80
>>>> SITEURL: http://172.21.14.02/
>>>> ALLOWED_HOSTS: "['172.21.14.02']"
>>>> GEOSERVER_PUBLIC_LOCATION: http://172.21.14.02/geoserver/
>>>>
>>>> celery:
>>>> environment:
>>>> DEBUG: 'True'
>>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>>> GEONODE_LB_PORT: 80
>>>> SITEURL: http://172.21.14.02/
>>>> ALLOWED_HOSTS: "['172.21.14.02']"
>>>> GEOSERVER_PUBLIC_LOCATION: http://172.21.14.02/geoserver/
>>>>
>>>> geoserver:
>>>> environment:
>>>> GEONODE_LB_HOST_IP: 172.21.14.02
>>>> GEONODE_LB_PORT: 80
>>>> NGINX_BASE_URL:
>>>>
>>>>
>>>>
>>>> Talking to some IT colleagues, they said that I may be having problem
>>>> because, the geonode server IP (172.21.14.02) is in our network, however
>>>> db4my_geonode container IP 172.27.0.6 is out of our network. But as
>>>> docker-compose ps showed the server 172.21.14.02, port 5432 is being used
>>>> by db4my_geonode container. I can not really figure out what is going
>>>> on!!!!
>>>>
>>>> Given that configuration the database container has a different network
>>>> address because it is running on the internal network established by
>>>> docker. Therefore from your host machine, I mean the CentOS, it is correct
>>>> that you are not allowed to reach the db container. If you want to reach
>>>> that you have to run your psql within the django container in such a way:
>>>>
>>>> psql -h db -U geonode -d geonode (please note that the hostname is
>>>> right the service name given in the docker-compose file ;) )
>>>>
>>>>
>>>> Any help on that will be very appreciated.
>>>>
>>>> Kind regards
>>>>
>>>> Julierme
>>>>
>>>>
>>>>
>>>> Hope this helps
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Jan 14, 2019 at 1:22 PM Francesco Bartoli <xbartolone at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Julierme,
>>>>>
>>>>> Where are you trying to run the test? Is the container related to the
>>>>> service “db” running? What’s the output of docker-compose ps?
>>>>> Il 14 gen 2019, 16:09 +0100, Julierme Pinheiro <
>>>>> juliermeopensourcedeveloper at gmail.com>, ha scritto:
>>>>>
>>>>> Trying to answer question 3, I ran a test:
>>>>> psql -h 172.21.14.02 -U geonode -d geonode
>>>>>
>>>>> psql: could not connect to server: No route to host
>>>>> Is the server running on host "172.21.14.02" and accepting
>>>>> TCP/IP connections on port 5432?
>>>>>
>>>>> Though /var/lib/postgresql/data/pg_hba.conf is set to trust (see
>>>>> bellow), I can not understand why the connection to postgres is not
>>>>> successful.
>>>>>
>>>>> local all all trust
>>>>>
>>>>> Any comment on this matter will be very appreciated.
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Julierme
>>>>>
>>>>>
>>>>> On Mon, Jan 14, 2019 at 12:30 PM Julierme Pinheiro <
>>>>> juliermeopensourcedeveloper at gmail.com> wrote:
>>>>>
>>>>>> Regarding my previous questions:
>>>>>> 1 - When installing geonode-project via docker, is postgres
>>>>>> configuration set automatically as in here
>>>>>> <http://docs.geonode.org/en/master/tutorials/install_and_admin/geonode_install/create_geonode_db.html>
>>>>>> ?
>>>>>>
>>>>>> I think so. Because I found all the databases and user configured
>>>>>> into db4my_geonode container.
>>>>>>
>>>>>> 2 - Could the error in the log file (geonode-project server
>>>>>> 172.21.14.02) be related to pg_hba.conf file (local connections)?
>>>>>>
>>>>>> I do not think so. Because looking at
>>>>>> /var/lib/postgresql/data/pg_hba.conf in db4my_geonode, the cofiguration is
>>>>>> set as:
>>>>>>
>>>>>> local all all trust
>>>>>>
>>>>>> Within these two answers I should not have gotten any problem by
>>>>>> configuring HOST: '172.21.14.02' in local_settings / DATABASES: {...}
>>>>>>
>>>>>> I am still thinking about question 3:
>>>>>>
>>>>>> Is there any postgres (db4my_geonode container) configuration in
>>>>>> geonode-project server 172.21.14.02 that I must do, before using it as HOST
>>>>>> value in local_settings / DATABASES = {...}?
>>>>>>
>>>>>> Thank you for your time in advance
>>>>>>
>>>>>> Kind regards
>>>>>>
>>>>>> Julierme
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jan 14, 2019 at 12:01 PM Julierme Pinheiro <
>>>>>> juliermeopensourcedeveloper at gmail.com> wrote:
>>>>>>
>>>>>>> Deal all,
>>>>>>>
>>>>>>> This is not an issue, but a question regarding postgres
>>>>>>> configuration in GeoNode-Project Docker installation.
>>>>>>>
>>>>>>> I have 2 servers and 1 client server.
>>>>>>>
>>>>>>> Server 1: postgres server - IP: 172.21.14.01
>>>>>>>
>>>>>>> I installed postgres in Server 1 (172.21.14.01) and I configured
>>>>>>> postgres as in here
>>>>>>> <http://docs.geonode.org/en/master/tutorials/install_and_admin/geonode_install/create_geonode_db.html>.
>>>>>>> I created in postgres:
>>>>>>>
>>>>>>> a user: geonode with password osgeo;
>>>>>>> a db: geonode owned by geonode user;
>>>>>>> a db: geonode_data owned by geonode user;
>>>>>>> and so on.
>>>>>>>
>>>>>>> Server 2 (CentOS7): geonode-project server - IP: 172.21.14.02
>>>>>>>
>>>>>>> I installed geonode-project at 2.8 via Docker in server 2 and changed
>>>>>>> localhost to 172.21.14.02 in docker-compose.override.yml file in order to
>>>>>>> access the geonode site from the client server.
>>>>>>>
>>>>>>> Client server: my_workstation - IP: 172.21.14.03
>>>>>>>
>>>>>>> GeoNode-Project installation via Docker is successful if I change
>>>>>>> localhost to 172.21.14.01 (postgres remote server) as in:
>>>>>>> # Backend
>>>>>>> DATABASES = {
>>>>>>> 'default': {
>>>>>>> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
>>>>>>> 'NAME': 'geonode',
>>>>>>> 'USER': 'geonode',
>>>>>>> 'PASSWORD': 'geonode',
>>>>>>> 'HOST': '172.21.14.01',
>>>>>>> 'PORT': '5432',
>>>>>>> 'CONN_TOUT': 900,
>>>>>>> },
>>>>>>> # vector datastore for uploads
>>>>>>> 'datastore': {
>>>>>>> 'ENGINE': 'django.contrib.gis.db.backends.postgis',
>>>>>>> # 'ENGINE': '', # Empty ENGINE name disables
>>>>>>> 'NAME': 'geonode_data',
>>>>>>> 'USER': 'geonode',
>>>>>>> 'PASSWORD': 'geonode',
>>>>>>> 'HOST': '172.21.14.01',
>>>>>>> 'PORT': '5432',
>>>>>>> 'CONN_TOUT': 900,
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> However if I configure HOST:'172.21.14.02' or HOST: 'localhost',
>>>>>>> geonode-project django and celery container will not go up and the log file
>>>>>>> says respectively for HOST:'172.21.14.02' and HOST: 'localhost'
>>>>>>> configuration:
>>>>>>>
>>>>>>> django4my_geonode | Is the server running on host "172.21.14.45"
>>>>>>> and accepting
>>>>>>> django4my_geonode | TCP/IP connections on port 5432?
>>>>>>>
>>>>>>> django4my_geonode | Is the server running on host "localhost"
>>>>>>> (::1) and accepting
>>>>>>> django4my_geonode | TCP/IP connections on port 5432?
>>>>>>>
>>>>>>> Though geonode-project installation is successful, by using postgres
>>>>>>> remote server IP: 172.21.14.01, configured manually, I do not want to use
>>>>>>> it.
>>>>>>>
>>>>>>> I want to use geonode-project server IP:172.21.14.02. Said that, I
>>>>>>> came out with the following questions:
>>>>>>>
>>>>>>> 1 - When installing geonode-project via docker, is postgres
>>>>>>> configuration set automatically as in here
>>>>>>> <http://docs.geonode.org/en/master/tutorials/install_and_admin/geonode_install/create_geonode_db.html>
>>>>>>> ?
>>>>>>>
>>>>>>> 2 - Could the error in the log file (geonode-project server
>>>>>>> 172.21.14.02) be related to pg_hba.conf file (local connections)?
>>>>>>>
>>>>>>> 3 - Is there any postgres (geonode/postgis container) configuration
>>>>>>> in geonode-project server 172.21.14.02 that I must do, before using it as
>>>>>>> HOST value in local_settings / DATABASES = {...}?
>>>>>>>
>>>>>>> My apologies for the long e-mail and thank you very much for your
>>>>>>> time and patience.
>>>>>>>
>>>>>>> Kind regards
>>>>>>>
>>>>>>> Julierme
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>> geonode-users mailing list
>>>>> geonode-users at lists.osgeo.org
>>>>> https://lists.osgeo.org/mailman/listinfo/geonode-users
>>>>>
>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20190115/72296dfa/attachment-0001.html>
More information about the geonode-users
mailing list