{"id":1058,"date":"2021-04-05T12:19:16","date_gmt":"2021-04-05T10:19:16","guid":{"rendered":"https:\/\/devpath.pro\/?p=1058"},"modified":"2021-04-05T12:19:16","modified_gmt":"2021-04-05T10:19:16","slug":"save-yourself-from-a-disaster-3-redundancy-of-database","status":"publish","type":"post","link":"https:\/\/fabiocicerchia.it\/web\/save-yourself-from-a-disaster-3-redundancy-of-database","title":{"rendered":"Save yourself from a disaster #3: Redundancy of Database"},"content":{"rendered":"
This is the third part of the series Save yourself from a disaster: Redundancy on a budget<\/a>.<\/p>\n How can we make sure our most important asset (which is the DB) is safely secured in case of a disaster?<\/p>\n We could do mainly 2 things (and you better do both of them):<\/p>\n Create a cluster to have at least a structure like Spin up a secondary node<\/strong><\/p>\n Create another VM somewhere else (better if in another availability zone\/region\/provider), then configure a MySQL\/MariaDB\/Percona\/… instance and plug it in as a secondary node<\/a>. Balancing requests<\/strong><\/p>\n I prefer to use something like HAProxy as a TCP load balancer, or (even better) using ProxySQL (which has a nice query caching capability). I’d go with ProxySQL load balancing<\/a> the 2 nodes created, then just change the database connection string in the application and the setup is done (we could even partition the queries and define to which node they should be sent).<\/p>\n In my case, a primary\/secondary topology could more than enough, but I went for a primary\/primary configuration (you can follow a\u00a0simple tutorial<\/a> or a more structured configuration<\/a>)\u00a0without balancing (because each web node will access their local DB instance).<\/p>\n Security<\/strong><\/p>\n The replica must be done over a secure connection, so you need to generate a certificate and use it<\/a>.<\/p>\n The next post will be about Redundancy of\u00a0Storage, Stay Tuned.<\/p>\n Check out the whole version of this post in the ebook. This is the third part of the series Save yourself from a disaster: Redundancy on a budget. How can we make sure our most important asset (which is the DB) is safely secured in case of a disaster? We could do mainly 2 things (and you better do both of them): Backups Redundancy<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","footnotes":""},"categories":[14],"tags":[122,123,124,125],"aioseo_notices":[],"author_meta":{"display_name":"fabio","author_link":"https:\/\/fabiocicerchia.it\/author\/fabio"},"featured_img":null,"coauthors":[],"tax_additional":{"categories":{"linked":["Web<\/a>"],"unlinked":["Web<\/span>"]},"tags":{"linked":["disaster recovery<\/a>","ovh<\/a>","redundancy<\/a>","sbg2<\/a>"],"unlinked":["disaster recovery<\/span>","ovh<\/span>","redundancy<\/span>","sbg2<\/span>"]}},"comment_count":"0","relative_dates":{"created":"Posted 3 years ago","modified":"Updated 3 years ago"},"absolute_dates":{"created":"Posted on April 5, 2021","modified":"Updated on April 5, 2021"},"absolute_dates_time":{"created":"Posted on April 5, 2021 12:19 pm","modified":"Updated on April 5, 2021 12:19 pm"},"featured_img_caption":"","series_order":"","_links":{"self":[{"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/posts\/1058"}],"collection":[{"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/comments?post=1058"}],"version-history":[{"count":0,"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/posts\/1058\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/media?parent=1058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/categories?post=1058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabiocicerchia.it\/wp-json\/wp\/v2\/tags?post=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
<\/h3>\n
\nThis guide won’t cover everything, it won’t be a comprehensive guide, and the steps that are shown need to be carefully reviewed and tested in your development\/pre-production environment. I don’t take any responsibility for any damage, interruption of service nor leak\/loss of data for the use of the instructions in the ebook (nor from any external website I’ve mentioned).<\/small><\/div>\nRedundancy<\/h2>\n
master\/slave<\/del> primary\/secondary, 3 nodes<\/a> will be recommended so we’ll have the flexibility to do planned maintenance without suffering and\/or affecting the performance of the whole cluster.<\/p>\n
\nWe can set it up even with fewer resources and make it the write-only node (in case we have less writing activity, otherwise the read-only one).<\/p>\n
\n
\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"