governor
governor copied to clipboard
Changes I've done to get Governor to work other then localhost
I had to change some things to get governor work with something other then localhost. First I had to change etcd so it uses init and my own config:
In /etc/init/etcd.override:
# Override file for etcd Upstart script providing some environment variables
env ETCD_INITIAL_CLUSTER="sql1=http://10.0.0.75:2380,sql2=http://10.0.0.76:2380,etcd=http://10.0.0.77:2380"
env ETCD_INITIAL_CLUSTER_STATE="new"
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.75:2380"
env ETCD_DATA_DIR="/var/lib/postgresql/governor/data/etcd"
env ETCD_LISTEN_PEER_URLS="http://10.0.0.75:2380"
env ETCD_LISTEN_CLIENT_URLS="http://10.0.0.75:2379"
env ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.75:2379"
env ETCD_NAME="sql1"
In helpers/postgresql.py I added the following line:
f.write("host all all %(self)s trust\n" % {"self": self.replication["self"]} )
right after:
def write_pg_hba(self):
f = open("%s/pg_hba.conf" % self.data_dir, "a")
and lastly added:
self: 10.0.0.0/24
to the postgresX.yml files. This not ideal as now the hole 10.0.0.0/24 network is trusted. But it did the trick for now. I would like to know you guys thought on this.
I'm thinking we should add rows for pg_hba.conf to the postgresX.yml files. As part of the initialization process, Governor should create the proper pg_hba.conf records. That would allow people to customize the cluster based on their needs.
postgres:
pg_hba:
- type: local
database: all
user: all
method: trust
- type: host
database: all
user: all
address: 127.0.0.1/32
method: trust
- type: host
database: all
user: all
address: "::1/128"
method: trust
- type: hostssl
database: all
user: all
address: 0.0.0.0/0
type: md5
The replication user should automatically be added when creating the pg_hba.conf.
@Winslett yes that would be a nice start.
I think we need to (re)write the postgresql.conf as well for this to work:
Note: Remote TCP/IP connections will not be possible unless the server is started with an appropriate value for the
listen_addressesconfiguration parameter, since the default behavior is to listen for TCP/IP connections only on the local loopback address localhost.
Thank for interesting HA solution!
I tried to implement Postgres HA solution with governor not on localhost and that is not implement, there are many errors, fault's and etc ( I think bug need to prioritize.
It is not really a bug. I have it working now on non-localhost ip addresses. I had to change the helpers/postgresql.py file so it will write the correct listen_addresses to postgresql.conf and had to move the write_pg_hba() en the extra write_postgresql_conf() function before the pg_ctl start function together with the changes in the first post to get postgres to start correctly.
def initialize(self):
if os.system("initdb -D %s" % self.data_dir) == 0:
# start Postgres without options to setup replication user indepedent of other system settings
self.write_postgresql_conf()
self.write_pg_hba()
os.system("pg_ctl start -w -D %s" % self.data_dir)
the postgresql_conf function itself:
def write_postgresql_conf(self):
f = open("%s/postgresql.conf" % self.data_dir, "a")
f.write("listen_addresses = '%s'" % self.host )
f.close()
@tvb, do you have the non-localhost code available somewhere, like a fork or a branch? I'd love to take a look at it ;-)
@wkielas sorry. I do not :(