{"id":1594,"date":"2012-07-18T13:32:44","date_gmt":"2012-07-18T15:32:44","guid":{"rendered":"http:\/\/fabriciolima.net\/blog\/?p=1594"},"modified":"2016-07-24T10:22:27","modified_gmt":"2016-07-24T13:22:27","slug":"database-mirroring-operation-mode-high-safety-without-failover-parte-3","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2012\/07\/18\/database-mirroring-operation-mode-high-safety-without-failover-parte-3\/","title":{"rendered":"Database Mirroring &#8211; Operation Mode High Safety Without Failover &#8211; Parte 3"},"content":{"rendered":"<p>Fala Pessoal,<\/p>\n<p>Neste post continuarei com o teste do Operation Mode High Safety Without  Automatic Failover.  Caso ainda n\u00e3o tenham visto os posts anteriores,  sugiro que  os leia  antes de continuar:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/27\/database-mirroring-operation-mode-high-safety-without-failover-parte-1\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013 Parte 1<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/29\/database-mirroring-operation-mode-high-safety-without-failover-parte-2\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013 Parte 2<\/a><\/p>\n<p><strong>O Objetivo deste teste \u00e9 parar o servidor Principal, acabar com o Mirror, subir o servidor Principal e verificar se houve alguma perda de dados.<\/strong><\/p>\n<p>Iniciei o loop de Insert sem waitfor delay:<br \/>\nwhile 1=1<br \/>\nbegin<br \/>\nif exists (select null<br \/>\nfrom sys.databases<br \/>\nwhere name = &#8216;MIRROR1&#8217; and state_desc = &#8216;ONLINE&#8217;)<br \/>\ninsert into mirror1..Teste(texto)<br \/>\nselect @@servername<br \/>\nend<\/p>\n<p>Caso um problema aconte\u00e7a com o seu servidor A (principal) o mirror fica conforme abaixo:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1673\" title=\"Figura 1\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11.png\" alt=\"\" width=\"523\" height=\"81\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11.png 523w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11-300x46.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11-410x63.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11-100x15.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11-275x43.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/07\/Figura-11-20x3.png 20w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/a><\/p>\n<p>Nesse momento, como nesse operation mode n\u00e3o temos um failover autom\u00e1tico, o mirror fica nesse status at\u00e9 que o servidor A volte ou voc\u00ea fa\u00e7a um failover manual.<\/p>\n<p>Conforme mostrei no post anterior:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/07\/16\/database-mirroring-error-the-command-failed-because-the-database-mirror-is-busy\/\" target=\"_blank\">Database Mirroring \u2013 Error: The Command Failed Because The Database Mirror Is  Busy<\/a><\/p>\n<p>N\u00e3o \u00e9 poss\u00edvel fazer um failover manual nessa situa\u00e7\u00e3o.<\/p>\n<p>Caso voc\u00ea n\u00e3o possa esperar o servidor A voltar, a \u00fanica solu\u00e7\u00e3o \u00e9 parar o mirror conforme os scripts:<\/p>\n<p>ALTER DATABASE mirror1 SET PARTNER OFF<br \/>\nGO<br \/>\nRESTORE DATABASE mirror1 WITH RECOVERY<\/p>\n<p>Executando os comandos acima, a database mirror1 j\u00e1 fica dispon\u00edvel no servidor B.<\/p>\n<p>Ao subir novamente o servidor A, a database mirror1 desse servidor tamb\u00e9m fica dispon\u00edvel.<\/p>\n<p>Nesse momento, deve-se ter certeza que as aplica\u00e7\u00f5es e servi\u00e7os est\u00e3o apontando para apenas um servidor.<\/p>\n<p>Para verificar se houve perda de dados com a quebra do mirror, executei a seguinte query nos dois servidores para pegar o \u00faltimo registro que foi inserido no servidor A com o texto \u2018ambiente5\u2019 e comparar com o \u00faltimo registro com essa informa\u00e7\u00e3o que foi sincronizado com o servidor B:<\/p>\n<p>select top 1 Cod, Data, Texto<br \/>\nfrom mirror1..Teste<br \/>\nwhere Texto = &#8216;ambiente5&#8217;<br \/>\norder by data desc<\/p>\n<p>Resultado no servidor A (Ambiente5):<\/p>\n<p>300.866\u00a0\u00a0 \u00a02012-01-31 14:00:37.250\u00a0\u00a0 \u00a0Ambiente5<\/p>\n<p>Resultado servidor B (Ambiente5\\inst1):<\/p>\n<p>300.866\u00a0\u00a0 \u00a02012-01-31 14:00:37.250\u00a0\u00a0 \u00a0Ambiente5<\/p>\n<p>Ou seja, o \u00faltimo registro inserido no servidor A foi transferido para o servidor B. N\u00e3o tive perda de dados.<\/p>\n<p>Conforme era esperado, como meu mirror estava sincronizado e no modo High Safety, n\u00e3o tive perda de dados, entretanto, tivemos que acabar com o mirror. Caso o tamanho da database seja muito grande, a reconstru\u00e7\u00e3o de um database mirror pode demorar horas. Se n\u00e3o for poss\u00edvel esperar todo esse tempo para um ambiente cr\u00edtico, deve-se utilizar o operation mode High Safety With Automatic Failover.<\/p>\n<p>Artigos relacionados:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/15\/serie-de-posts-sobre-database-mirroring\/\" target=\"_blank\">S\u00e9rie de Posts sobre Database Mirroring<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/15\/database-mirroring-como-alterar-o-operation-mode\/\" target=\"_blank\">Database Mirroring \u2013 Como alterar o Operation Mode<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/23\/database-mirroring-testes-operation-mode-high-performance-parte-1\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Performance \u2013 Parte 1<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/28\/database-mirroring-operation-mode-high-performance-parte-2\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Performance \u2013 Parte 2<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/05\/31\/database-mirroring-operation-mode-high-performance-parte-3\/\" target=\"_blank\">Database Mirroring &#8211; Operation Mode High Performance &#8211; Parte 3<\/a><\/p>\n<p><a rel=\"bookmark\" href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/27\/database-mirroring-operation-mode-high-safety-without-failover-parte-1\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013  Parte 1<\/a><\/p>\n<p><a rel=\"bookmark\" href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/06\/29\/database-mirroring-operation-mode-high-safety-without-failover-parte-2\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013  Parte 2<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/07\/16\/database-mirroring-error-the-command-failed-because-the-database-mirror-is-busy\/\" target=\"_blank\">Database Mirroring \u2013 Error: The Command Failed Because The Database Mirror Is  Busy<\/a><\/p>\n<p>At\u00e9 o pr\u00f3ximo post.<\/p>\n<p><b>Gostou desse Post?<\/b><\/p>\n<p>Cadastre seu e-mail para receber novos Posts e curta minha <a href=\"https:\/\/www.facebook.com\/FabricioLimaSolucoesemBancodeDados\/\" target=\"_blank\">P\u00e1gina no Facebook<\/a> para receber Dicas de Leituras e Eventos sobre SQL Server.<\/p>\n<p>Abra\u00e7os,<\/p>\n<p>Fabr\u00edcio Lima<\/p>\n<p>MCITP \u2013 Database Administrator<\/p>\n<p>Consultor e Instrutor SQL Server<\/p>\n<p>Trabalha com SQL Server desde 2006<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fala Pessoal, Neste post continuarei com o teste do Operation Mode High Safety Without Automatic Failover. Caso ainda n\u00e3o tenham visto os posts anteriores, sugiro que os leia antes de continuar: Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013 Parte 1 Database Mirroring \u2013 Operation Mode High Safety Without Failover \u2013 Parte 2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,280],"tags":[604,606,391,23,607,372,613,611,612,610,608,616,49,33,50,34,605,609,614,615],"class_list":["post-1594","post","type-post","status-publish","format-standard","hentry","category-administracao-de-bd","category-virtual-pass-br","tag-alta-disponibilidade","tag-database-mirror","tag-database-mirroring","tag-dba","tag-espelhamento-de-banco-de-dados","tag-high-availability","tag-high-performance","tag-high-safety-with-automatic-failover","tag-high-safety-without-automatic-failover","tag-operation-mode","tag-perda-de-dados","tag-safety","tag-sql","tag-sql-server","tag-sql-server-2005","tag-sql-server-2008","tag-sql-server-mirror","tag-sql-server-online","tag-sys-database_mirroring","tag-witness"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/1594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/comments?post=1594"}],"version-history":[{"count":0,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/1594\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=1594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=1594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}