(Typos and grammar errors fixed. Thanks Lacey)
Part II: Slony-I basics and Slony-I configuration - slon.conf
Slony-I basics
slon is the deamon that is responsible for replication. It needs to be installed for each node, as described in the first part of the article.
Part II: Slony-I basics and Slony-I configuration - slon.conf
Slony-I basics
slon is the deamon that is responsible for replication. It needs to be installed for each node, as described in the first part of the article.
Configuration of slon daemon
In the first part of the article, I wrote about pre-installation and installation phases of Slony-I 2.0.X to RHEL/CentOS. Now I will go over the details of the configuration files.
As I mentioned in the first post, there are 2 conf files: slon.conf and slon_tools.conf . First we will talk about slon.conf
slon.conf is used for slon daemon itself. RPMs put the slon.conf file in the /etc directory. Here are some of the configuration parameters that you may want to play with (with default parameters included):
# log_timestamp_format='%Y-%m-%d %H:%M:%S %Z'
This is the setting that changes log filename suffix. An example log file name is below:
The first part of the filename is the name of the replication cluster, as defined in the cluster_name parameter in slon.conf, and/or $CLUSTER_NAME in the slon_tools.conf. The second part, which is the timestamp, is defined by the log_timestamp parameter. Some people tend to change this parameter to:
and setup appropriate log rotation in order to rotate logs. Please note that it is possible to use rotatelogs binary of Apache in order to rotate logs, too. This will be mentioned in slon_tools.conf. However, Apache may not be installed on the server, so using logrotate daemon will probably be a better choice from system administrators's point of view.
#cleanup_interval="10 minutes"
The slon daemon performs cleanup cycles while it is working, and trims data from sl_log_1 to sl_log_2. This parameter sets the interval for cleanup cycles. Depending on your work load, you may want to decrease or increase this. Please note that under high load, decreasing this parameter will cause load on server.
#vac_frequency=3
This parameter sets the number of cleanup cycles which will trigger a VACUUM. Unless you are using pg_autovacuum, you will want to set this to a value other than 0. Default value is 3. Max value is 100.
#log_level=4
This parameter defines the logging verbosity. The default value is 4. A value of 0 does not disable logging. 0 displays the following 5 log levels:
Fatal
Error
Warn
Config
Info
1 to 4 is Debug 1 to Debug 4. Slony-I 2.0 users are encouraged to use 0 as log_level, since some messages were incorporated into the log levels above.
#sync_interval=2000
This parameter defines the interval that slon checks SYNC requests. As this value decreases, slon performs updates more frequently. The update interval for slon is also affected by sync_interval_timeout parameter, so please check this, too. The default value is 2000ms. Min value for this parameter is 10ms, and max value is 60000ms. I tend to decrease this to 200 (ms), for performance under heavy load.
#sync_interval_timeout=10000
This parameter defines the time period that slon performs SYNC events between origin and slave(s). The default value is 10 seconds. Decreasing this parameter will lead to less replication lag, but it also means that both origin and slave will be more busy with replication. The max value for this parameter is 120000ms (120 seconds).
#sync_group_maxsize=6
There may be times when replication lag gets bigger, which mostly depends on work load, or network connection issues. This parameter the number of batched SYNCs, and they will be applied together to close the replication gap. There may be times when, due to the work load, or network connection issues, that there is a large amount of replication lag. This parameter controls the number of batched SYNCs that will be applied together to close the replication gap.. As soon as the lag closes to 0, each SYNC event is applied seperately. Default value is 6. Values may change between 0 and 100. Please also see desired_sync_time parameter below.
#desired_sync_time=60000
Similar to sync_group_maxsize -- this parameter defines the maximum time for the SYNC operations that are already grouped. Per definition in conf file: "If replication is behind, slon will try to increase numbers of syncs done targetting that they should take this quantity of time to process. in ms" Default value is 60000 (ms). Range is between 10000 and 600000 . Decreasing this value will increase performance under heavy load.
#cluster_name='sloncluster'
This is the name of your cluster. This is also the name of the schema with a _ prefix that has replication info. i.e., _sloncluster in this case. You can use slon_tools.conf to define this parameter, too (which is a preferred way in this article)
#conn_info='host=/tmp port=5432 user=slony'
This parameter defines connection info of slon daemon. You can use slon_tools.conf to define this parameter, too (which is a preferred way in this article)
There are several more options. All of the remaining ones and their default values are :
#vac_frequency=3
#cleanup_interval="10 minutes"
#log_level=4
#sync_interval=2000
#sync_interval_timeout=10000
#sync_group_maxsize=6
#sync_max_rowsize=8192
#sync_max_largemem=5242880
#remote_listen_timeout=300
#syslog=0
#log_pid=false
#log_timestamp=true
#log_timestamp_format='%Y-%m-%d %H:%M:%S %Z'
#pid_file='/path/to/your/pidfile'
#syslog_facility=LOCAL0
#syslog_ident=slon
#cluster_name='sloncluster'
#conn_info='host=/tmp port=5432 user=slony'
#desired_sync_time=60000
#sql_on_connection="SET log_min_duration_statement TO '1000';"
#command_on_logarchive="/usr/local/bin/movearchivetoarchive"
#lag_interval="8 minutes"
#archive_dir="/tmp/somewhere"
#quit_sync_provider=1
#quit_sync_finalsync=21341
#cleanup_deletelogs=false
In the first part of the article, I wrote about pre-installation and installation phases of Slony-I 2.0.X to RHEL/CentOS. Now I will go over the details of the configuration files.
As I mentioned in the first post, there are 2 conf files: slon.conf and slon_tools.conf . First we will talk about slon.conf
slon.conf is used for slon daemon itself. RPMs put the slon.conf file in the /etc directory. Here are some of the configuration parameters that you may want to play with (with default parameters included):
# log_timestamp_format='%Y-%m-%d %H:%M:%S %Z'
This is the setting that changes log filename suffix. An example log file name is below:
pagila-2009-07-07_15:26:59.log
The first part of the filename is the name of the replication cluster, as defined in the cluster_name parameter in slon.conf, and/or $CLUSTER_NAME in the slon_tools.conf. The second part, which is the timestamp, is defined by the log_timestamp parameter. Some people tend to change this parameter to:
log_timestamp_format='%Y-%m-%d'
and setup appropriate log rotation in order to rotate logs. Please note that it is possible to use rotatelogs binary of Apache in order to rotate logs, too. This will be mentioned in slon_tools.conf. However, Apache may not be installed on the server, so using logrotate daemon will probably be a better choice from system administrators's point of view.
#cleanup_interval="10 minutes"
The slon daemon performs cleanup cycles while it is working, and trims data from sl_log_1 to sl_log_2. This parameter sets the interval for cleanup cycles. Depending on your work load, you may want to decrease or increase this. Please note that under high load, decreasing this parameter will cause load on server.
#vac_frequency=3
This parameter sets the number of cleanup cycles which will trigger a VACUUM. Unless you are using pg_autovacuum, you will want to set this to a value other than 0. Default value is 3. Max value is 100.
#log_level=4
This parameter defines the logging verbosity. The default value is 4. A value of 0 does not disable logging. 0 displays the following 5 log levels:
Fatal
Error
Warn
Config
Info
1 to 4 is Debug 1 to Debug 4. Slony-I 2.0 users are encouraged to use 0 as log_level, since some messages were incorporated into the log levels above.
#sync_interval=2000
This parameter defines the interval that slon checks SYNC requests. As this value decreases, slon performs updates more frequently. The update interval for slon is also affected by sync_interval_timeout parameter, so please check this, too. The default value is 2000ms. Min value for this parameter is 10ms, and max value is 60000ms. I tend to decrease this to 200 (ms), for performance under heavy load.
#sync_interval_timeout=10000
This parameter defines the time period that slon performs SYNC events between origin and slave(s). The default value is 10 seconds. Decreasing this parameter will lead to less replication lag, but it also means that both origin and slave will be more busy with replication. The max value for this parameter is 120000ms (120 seconds).
#sync_group_maxsize=6
There may be times when replication lag gets bigger, which mostly depends on work load, or network connection issues. This parameter the number of batched SYNCs, and they will be applied together to close the replication gap. There may be times when, due to the work load, or network connection issues, that there is a large amount of replication lag. This parameter controls the number of batched SYNCs that will be applied together to close the replication gap.. As soon as the lag closes to 0, each SYNC event is applied seperately. Default value is 6. Values may change between 0 and 100. Please also see desired_sync_time parameter below.
#desired_sync_time=60000
Similar to sync_group_maxsize -- this parameter defines the maximum time for the SYNC operations that are already grouped. Per definition in conf file: "If replication is behind, slon will try to increase numbers of syncs done targetting that they should take this quantity of time to process. in ms" Default value is 60000 (ms). Range is between 10000 and 600000 . Decreasing this value will increase performance under heavy load.
#cluster_name='sloncluster'
This is the name of your cluster. This is also the name of the schema with a _ prefix that has replication info. i.e., _sloncluster in this case. You can use slon_tools.conf to define this parameter, too (which is a preferred way in this article)
#conn_info='host=/tmp port=5432 user=slony'
This parameter defines connection info of slon daemon. You can use slon_tools.conf to define this parameter, too (which is a preferred way in this article)
There are several more options. All of the remaining ones and their default values are :
#vac_frequency=3
#cleanup_interval="10 minutes"
#log_level=4
#sync_interval=2000
#sync_interval_timeout=10000
#sync_group_maxsize=6
#sync_max_rowsize=8192
#sync_max_largemem=5242880
#remote_listen_timeout=300
#syslog=0
#log_pid=false
#log_timestamp=true
#log_timestamp_format='%Y-%m-%d %H:%M:%S %Z'
#pid_file='/path/to/your/pidfile'
#syslog_facility=LOCAL0
#syslog_ident=slon
#cluster_name='sloncluster'
#conn_info='host=/tmp port=5432 user=slony'
#desired_sync_time=60000
#sql_on_connection="SET log_min_duration_statement TO '1000';"
#command_on_logarchive="/usr/local/bin/movearchivetoarchive"
#lag_interval="8 minutes"
#archive_dir="/tmp/somewhere"
#quit_sync_provider=1
#quit_sync_finalsync=21341
#cleanup_deletelogs=false
YinYin
I read your web pages are really helpful.
But I have confusion between slony-I and slony-II.
Is there any info or document that slony-1 vs slony-II ?
And what are the advantages or technical dependencies of using slony-II instead of slony-I ?
Thanks & Regards,
YinYin