Connect netbox to the postgres Cluster

55 views
Skip to first unread message

Марат Сибгатулин

unread,
Sep 24, 2018, 10:05:01 AM9/24/18
to NetBox
Has anybody met such challenge?

In netbox/configuration.py I can fill in just a single host of DB. But actually I have DB cluster with 3 nodes.
There are workarounds:

1) Run a postgres proxy and configure it as a host.
2) Run some script which will check who is a master now, change configuration and restart netbox
3) Make netbox/psycopg2/libpq to work with cluster, but it probably requires to change the code and therefore do it each time after upgrading netbox.

Any ideas?

Jeremy Stretch

unread,
Sep 24, 2018, 3:31:20 PM9/24/18
to euca...@gmail.com, NetBox
I can't speak to this specifically, but I'll note that NetBox utilizes the built-in database connection logic provided by the Django platform: https://docs.djangoproject.com/en/2.0/ref/databases/#postgresql-notes Hope that helps!

Jeremy

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/c249111b-9685-41b2-bd17-b3e13925a312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Марат Сибгатулин

unread,
Sep 25, 2018, 10:51:41 AM9/25/18
to NetBox
Hooray. I did it.

The problem was I tried to put
 ['host1','host2','host3']

in HOST var in configuration.py, while right way was to put
'host1,host2,host3'

Thank you.



понедельник, 24 сентября 2018 г., 22:31:20 UTC+3 пользователь Jeremy Stretch написал:

Марат Сибгатулин

unread,
Sep 26, 2018, 8:53:45 AM9/26/18
to NetBox
Unfortunately, netbox has eaten it, but actually it doesn't work.
It selects just first node and works with it. If it is master - it's good, otherwize - I get 
<class 'django.db.utils.InternalError'>
cannot execute UPDATE in a read-only transaction

I continue my investigations.

вторник, 25 сентября 2018 г., 17:51:41 UTC+3 пользователь Марат Сибгатулин написал:

Марат Сибгатулин

unread,
Sep 26, 2018, 9:45:48 AM9/26/18
to NetBox
And I did it again.

So, the working configuration looks like this:
DATABASE = {
   
'NAME': 'netbox',
   
'USER': 'netbox',
   
'PASSWORD': 'netbox',
   
'HOST': 'host1,host2,host3',
   
'OPTIONS': {'target_session_attrs': 'read-write'},
   
'PORT': '5432',
}


May I suggest to add it as a commented part to configuration.py? For those who are new to postgresql it will be  dramatically helpful.


среда, 26 сентября 2018 г., 15:53:45 UTC+3 пользователь Марат Сибгатулин написал:
Reply all
Reply to author
Forward
0 new messages