Guest User

Untitled

a guest
Nov 16th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.77 KB | None | 0 0
  1. # Install
  2. - mkdir -p /var/log/bucardo
  3. - touch /var/log/bucardo/log.bucardo
  4.  
  5. # Misc
  6.  
  7. bucardo is the main interface to Bucardo - it is used to start, stop, and control Bucardo.
  8.  
  9. You can tell bucardo where to find the main Bucardo database by use of the following arguments:
  10.  
  11. ` --dbport --dbhost --dbname --dbuser`
  12.  
  13. Additional bucardo arguments include:
  14.  
  15. ```
  16. --quiet=0
  17. --verbose=0
  18. --bcverbose=1
  19. --sendmail=0
  20. --extraname=''
  21. --debugfilesep=0
  22. --debugdir='.'
  23. --debugname=''
  24. --debugsyslog=1 # Enables/Disables Syslog
  25. --debugfile=1 # Enables/Disables local log file ./log.bucardo
  26. --cleandebugs=0
  27. ```
  28.  
  29. Rather than enter those every time, you may place the arguments into a bucardorc file. All of the arguments below, except for “install”, require that enough options exist to find the main Bucardo database.
  30.  
  31. ## Installing and upgrading Bucardo
  32. To install Bucardo for the first time, simply enter
  33.  
  34. ` bucardo install`
  35.  
  36. See the Bucardo installation page for complete details.
  37.  
  38. To upgrade Bucardo, use:
  39.  
  40. ` bucardo upgrade`
  41.  
  42. See the Bucardo upgrade page for complete details.
  43.  
  44. ## Controlling Bucardo
  45. ### Starting Bucardo
  46. To start Bucardo, simply enter:
  47.  
  48. ` bucardo start "Reason for starting"`
  49.  
  50. The reason is optional but recommended.
  51.  
  52. ### Stopping Bucardo
  53. To stop Bucardo, simply enter:
  54.  
  55. ` bucardo stop "Reason for stopping"`
  56.  
  57. Again, the reason is optional but recommended.
  58.  
  59. ### Restarting Bucardo
  60. Restarting is just:
  61.  
  62. ` bucardo restart "Reason for restart"`
  63.  
  64. ### Checking that Bucardo is alive
  65. To send a “ping” to the MCP process of a running Bucardo, use:
  66.  
  67. ` bucardo ping [timeout]`
  68.  
  69. If successful, an exit value of 0 will be returned. The string returned by this command is Nagios-friendly, and will start with either OK or CRITICAL. The optional timeout argument indicates how long to wait for a response before giving up and returning a critical failure. The default time is 15 seconds. To wait forever, enter a timeout of 0.
  70.  
  71. ## Bucardo configuration
  72. Bucardo stores important configuration variables in the database inside the bucardo_config table. See the Bucardo configuration page for a complete list.
  73.  
  74. ### Viewing configuration values
  75. To view all of the configuration settings:
  76.  
  77. ` bucardo show all`
  78.  
  79. To view one or more specific items, enter their names:
  80.  
  81. ` bucardo show kick_sleep log_showline`
  82.  
  83. Note that names are actually regular expressions, so that entering:
  84.  
  85. ` bucardo show kid`
  86.  
  87. will list all configuration parameters that have the letters ‘kid’ inside of them.
  88.  
  89. ### Changing configuration values
  90. To change a configuration, use:
  91.  
  92. ` bucardo set name=value`
  93.  
  94. For example, to change the syslog logging facility to LOG_LOCAL3:
  95.  
  96. ` bucardo set syslog_facility=LOG_LOCAL3`
  97.  
  98. ### Reloading the configuration settings
  99. To tell a running Bucardo to re-read the configuration table:
  100.  
  101. ` bucardo reload_config`
  102.  
  103. ## Controlling syncs
  104. Bucardo works by running one or more replication events called syncs. The main interface for controlling these is bucardo
  105.  
  106. ### Kicking a sync
  107. Syncs are fired by changes to the underlying tables, or manually started by kicking them. To kick a sync, use:
  108.  
  109. ` bucardo kick [timeout]`
  110.  
  111. The optional timeout argument tells how long bucardo will wait for a response from Bucardo indicating that the sync has finished. If no timeout argument is given, the program sends the kick signal and returns immediately. If a value of “0” is given, bucardo will wait indefinitely for the sync to finish, and also give a running tab of how long the sync has taken.
  112.  
  113. Multiple syncs arguements can be given. If not timeout is given, they will all be kicked at once. Otherwise, they will be kicked in the order given, each starting when the previous one has completed. For example, to kick the syncs “sales” and “marketing”, while while waiting for each to finish, you could use:
  114.  
  115. ` bucardo kick sales marketing 0`
  116.  
  117. ### Reloading a sync
  118. To reload a sync:
  119.  
  120. ` bucardo reload`
  121.  
  122. One or more named syncs can be reloaded this way. Each will be reloaded in turn, and bucardo will let you know when each has been reloaded. When a sync is reloaded, the MCP process will stop the existing sync, reload information about the sync from the database, and start it up again. This is typically used when you want to make changes to an existing sync that is already running, e.g. the onetimecopy attribute.
  123.  
  124. ### Activating a sync
  125. To activate a sync that is not currently running, use:
  126.  
  127. ` bucardo activate`
  128.  
  129. ### Deactivating a sync
  130. To deactivate a sync that is currently active and running, use:
  131.  
  132. ` bucardo deactivate`
  133.  
  134. ## Viewing information
  135. To view general status about the currently running Bucardo process, use:
  136.  
  137. ` bucardo status`
  138.  
  139. This will list general information about each sync
  140.  
  141. ### Detailed sync information
  142. ` bucardo status`
  143.  
  144. This will show detailed information about a specific sync, including the last time it successfully ran, the number of rows transferred, and the last time it failed.
  145.  
  146. ### Listing syncs
  147. To get a list of all syncs:
  148.  
  149. ` bucardo list syncs`
  150.  
  151. This list will show the sync name, it’s type (fullcopy, pushdelta, or swap), the source herd, the target database (or database group), and current status. For more details on a specific sync, use the ‘status’ command above.
  152.  
  153. ### Listing databases
  154. To get a list of all known databases:
  155.  
  156. ` bucardo list dbs`
  157.  
  158. This will show the name of the database (as used by Bucardo, not its actual name in Postgres), its status, and the connection string used by Bucardo to connect to it.
  159.  
  160. ### Listing database groups
  161. To get a list of all known database groups:
  162.  
  163. ` bucardo list dbgroups`
  164.  
  165. ### Listing tables
  166. To list all known tables:
  167.  
  168. ` bucardo list tables`
  169.  
  170. ### Listing sequences
  171. To list all known sequences:
  172.  
  173. ` bucardo list sequences`
  174.  
  175. ### Listing herds
  176. To list all herds:
  177.  
  178. ` bucardo list herds`
  179.  
  180. To list only one or more specific herds, add their names:
  181.  
  182. ` bucardo list herd`
  183.  
  184. To get a list of all tables that belong to a herd, use the verbose argument:
  185.  
  186. ` bucardo list herd --verbose`
  187.  
  188. ## Adding things
  189. To add new items, the general syntax is:
  190.  
  191. ` bucardo add [additional_information]`
  192.  
  193. ### Adding a database
  194. Bucardo needs to know how to connect to each database involved in replication. You can teach it about a new database by using:
  195.  
  196. ` bucardo add db [options]`
  197.  
  198. The “dbname” is the name of the database inside of Postgres. The other optional arguments are entered in the format name=value and can include:
  199.  
  200. name: the internal name used by Bucardo to refer to this database
  201. port: the port this database runs on. Defaults to 5432.
  202. host: the host this database is on. Defaults to no host (Unix socket)
  203. user: the user to connect as. Defaults to ‘bucardo’
  204. pass: the password to connect with. Don’t use this, use a .pgpass file instead!
  205. conn: Any additional information add to the connection string, e.g. sslmode=require
  206. sourcelimit: The maximum number of replication events that can run at one time using this database as a source. Defaults to 0 (no limit)
  207. targetlimit: The maximum number of replication events that can run at one time using this database as a target. Defaults to 0 (no limit)
  208. pgpass: Full path and filename of a Bucardo/pgpass file to use for this connection
  209. For example, to add three new databases on different hosts:
  210.  
  211. ` bucardo add database sales name=sales_master host=int-db-sales1`
  212. ` bucardo add database sales name=sales_slave1 host=int-db-sales2`
  213. ` bucardo add database sales name=sales_slave2 host=int-db-sales3`
  214.  
  215. ### Adding a database group
  216. Databases can be grouped together, so that one master can push to a group of slave databases rather than a single database. To create a new named group:
  217.  
  218. ` bucardo add dbgroup [db db]`
  219.  
  220. An optional list of databases to add to this group can be given. For example:
  221.  
  222. ` bucardo add dbgroup sales sales_slave1 sales_slave2`
  223.  
  224. ### Adding tables
  225. Bucardo needs to know about all tables that might be used in replication. Adding a tables is simply:
  226.  
  227. ` bucardo add table db=dbname`
  228.  
  229. The tablename can be schema qualified, but does not have to be. The “dbname” refers to the internal name Bucardo uses to identify databases. The “db=dbname” can be left off if there is only one database in the db table. Note that you only need to add tables from the source database(s).
  230.  
  231. An easier way to add tables is to simply run:
  232.  
  233. ` bucardo add all tables [db=dbname]`
  234.  
  235. This will not actually change these tables or replicate them, it will merely tell Bucardo about them. Thus, it is safe to run this command at any time.
  236.  
  237. ### Adding sequences
  238. Bucardo can also replicate sequences that it knows about. To add a sequence:
  239.  
  240. ` bucardo add sequence db=dbname`
  241.  
  242. To add all sequences:
  243.  
  244. ` bucardo add all sequences [db=dbname]`
  245.  
  246. All the notes that apply to ‘add table’ above apply here as well.
  247.  
  248. ### Adding a herd
  249. A herd is a named group of tables that are replicated together. To add a herd:
  250.  
  251. ` bucardo add herd [goat goat]`
  252.  
  253. The list of goats are tables or sequences that should be part of this herd.
  254.  
  255. ### Adding a sync
  256. To add a sync:
  257.  
  258. ` bucardo add sync source=[source] type=[type] [target]`
  259.  
  260. The name is simply an internal name used by Bucardo. Keep it short but descriptive: it is used quite often in day to day use. The source is the name of the herd that we are replicating from. The type is one of fullcopy, pushdelta, or swap. The target is either a database (targetdb=) or a database group (targetgroup=.
  261.  
  262. As a shortcut for creating new syncs, you can also give a comma-separated list of tables, like so:
  263.  
  264. ` bucardo add sync abc source=db1 targetdb=db2 tables=sales,marketing,userdb`
  265.  
  266. This will create a herd of the same name as the sync if it does not already exist, add the tables to it, and then create the sync.
  267.  
  268. Other options that can be added to ‘add sync’, in the format name=value:
  269.  
  270. onetimecopy: set the onetimecopy value for this sync
  271. status: set the initial status for the sync. Defaults to ‘active’
  272. lifetime: set the lifetime for this sync - how long to run before the sync is restarted
  273. maxkicks: sets the maxkicks for this sync - how many times it runs before being restarted
  274. makedelta: set the makedelta value for this sync. Defaults to 0.
  275. ## Other actions
  276. ### Sending a message to the log file
  277. To write a custom message to the log file that a current Bucardo process is writing to, use:
  278.  
  279. ` bucardo message "Your message here"`
  280.  
  281. The message will be written by the MCP process to the logs in the format:
  282.  
  283. ` MESSAGE (date): string`
  284.  
  285. where date is the timestamp the message was added, and string was the message provided
  286.  
  287. # Service
  288. Create service
  289. ```
  290. cat <<EOD > /etc/systemd/system/bucardo.service
  291. [Unit]
  292. Description=Bucardo
  293. After=network.target
  294. StartLimitIntervalSec=0
  295.  
  296. [Service]
  297. Type=simple
  298. Restart=always
  299. RestartSec=10
  300. User=root
  301. SyslogIdentifier=bucardo
  302. ExecStart=/usr/local/bin/bucardo start --debugsyslog=1 --debugfile=1
  303. ExecStop=/usr/local/bin/bucardo stop
  304. ExecReload=/usr/local/bin/bucardo restart
  305.  
  306. [Install]
  307. WantedBy=multi-user.target
  308. EOD
  309. ```
  310. ` systemctl daemon-reload`
  311.  
  312. ` systemctl enable bucardo`
  313.  
  314. ` systemctl start bucardo`
Add Comment
Please, Sign In to add comment