{"id":1631,"date":"2013-01-01T18:13:05","date_gmt":"2013-01-01T20:13:05","guid":{"rendered":"http:\/\/fabriciolima.net\/blog\/?p=1631"},"modified":"2016-07-23T23:34:38","modified_gmt":"2016-07-24T02:34:38","slug":"database-mirroring-tirando-o-servidor-de-witness-do-mirror-em-caso-de-falha","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2013\/01\/01\/database-mirroring-tirando-o-servidor-de-witness-do-mirror-em-caso-de-falha\/","title":{"rendered":"Database Mirroring &#8211; Tirando o servidor de Witness do Mirror em caso de falha"},"content":{"rendered":"<p>Ol\u00e1 Pessoal,<\/p>\n<p>Continuando a s\u00e9rie de posts sobre Database Mirroring que j\u00e1 tenho semi prontos (faltam mais 3 posts ap\u00f3s esse), segue mais um teste realizado.<\/p>\n<p>O objetivo desse teste \u00e9 provar que o servidor de produ\u00e7\u00e3o em um Mirror pode parar mesmo sem acontecer nenhum problema com ele. Em seguida, tamb\u00e9m \u00e9 dada uma solu\u00e7\u00e3o para evitar que isso aconte\u00e7a.<\/p>\n<p>Instancias participantes dos testes:<\/p>\n<p>1 &#8211; Instancia5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211; Servidor Principal que chamarei de Servidor A<br \/>\n2 &#8211; Instancia5\\INST1\u00a0\u00a0\u00a0 &#8211; Servidor Mirror que chamarei de Servidor B<br \/>\n3 &#8211; Instancia5\\INST2\u00a0\u00a0\u00a0 &#8211; Servidor Witness que chamarei de Servidor Witness<\/p>\n<p>Nome da database espelhada: Mirror1<\/p>\n<p>Quando o servidor de Witness est\u00e1 no ar ele possui o status CONNECTED na coluna mirroring_witness_state_desc da query abaixo:<\/p>\n<p>SELECT db.name, m.mirroring_role_desc , mirroring_state_desc,mirroring_safety_level_desc,<br \/>\nmirroring_partner_instance,\u00a0\u00a0 \u00a0mirroring_witness_state_desc<br \/>\nFROM sys.database_mirroring m<br \/>\nJOIN sys.databases db ON db.database_id = m.database_id<br \/>\nwhere Name = &#8216;Mirror1&#8217;<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1886\" title=\"Figura 1\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1.png\" alt=\"\" width=\"761\" height=\"40\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1.png 761w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-300x16.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-700x37.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-410x22.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-100x5.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-275x14.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-1-20x1.png 20w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/a><\/p>\n<p>Quando o servidor Witness fica indispon\u00edvel, essa coluna retorna: DISCONNECTED:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1887\" title=\"Figura 2\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2.png\" alt=\"\" width=\"760\" height=\"41\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2.png 760w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-300x16.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-700x38.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-410x22.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-100x5.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-275x15.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-2-20x1.png 20w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/a><\/p>\n<p>Nesse momento, caso o servidor B (Mirror) fique Offline, o servidor de produ\u00e7\u00e3o tamb\u00e9m ficar\u00e1 Offline mesmo sem ter acontecido nenhum problema com ele.<\/p>\n<p>Na execu\u00e7\u00e3o de uma simples query no servidor A: <em>Use Mirror1<\/em><\/p>\n<p>O erro abaixo \u00e9 retornado:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1888\" title=\"Figura 3\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3.png\" alt=\"\" width=\"1214\" height=\"57\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3.png 1214w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-300x14.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-1024x48.png 1024w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-768x36.png 768w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-700x33.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-410x19.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-100x5.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-275x13.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-3-20x1.png 20w\" sizes=\"auto, (max-width: 1214px) 100vw, 1214px\" \/><\/a><\/p>\n<p>Se no momento em que o servidor Witness ficar Offline, voc\u00ea retir\u00e1-lo do mirror, o seu servidor de produ\u00e7\u00e3o n\u00e3o ficar\u00e1 vulner\u00e1vel.<\/p>\n<p>Para retirar o servidor Witness, basta executar o comando:<\/p>\n<p>ALTER DATABASE mirror1 set witness off<\/p>\n<p>Eliminando o servidor Witness do mirror, agora a coluna mirroring_witness_state_desc retorna o valor : UNKNOWN<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1889\" title=\"Figura 4\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4.png\" alt=\"\" width=\"761\" height=\"40\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4.png 761w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-300x16.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-700x37.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-410x22.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-100x5.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-275x14.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2012\/11\/Figura-4-20x1.png 20w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/a><\/p>\n<p>Com isso voltamos para o Operation mode High Safety Without Failorver<\/p>\n<p>Agora o servidor B (Mirror) pode cair que o principal n\u00e3o vai parar.<\/p>\n<p>Minha sugest\u00e3o: Criar o job com a query abaixo:<\/p>\n<p>if (select mirroring_witness_state_desc<br \/>\nFROM sys.database_mirroring m<br \/>\nJOIN sys.databases db ON db.database_id = m.database_id<br \/>\nWHERE Name = &#8216;Mirror1&#8217;) = &#8216;DISCONNECTED&#8217;<br \/>\nbegin<br \/>\nALTER DATABASE mirror1 set witness off<br \/>\nEnd<\/p>\n<p>Para adicionar o witness novamente basta executar o comando abaixo:<\/p>\n<p>ALTER DATABASE Mirror1<br \/>\nSET WITNESS = &#8216;tcp:\/\/ambiente5.lab.local:5024&#8217;<\/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\/10\/31\/database-mirroring-operation-mode-high-safety-with-automatic-failover\/\" target=\"_blank\">Database Mirroring \u2013 Operation Mode High Safety with Automatic Failover<\/a><\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2012\/12\/03\/database-mirroring-tempo-failover-hs-with-automatic-failover-com-timeout\/\" target=\"_blank\">Database Mirroring \u2013 Tempo Failover \u2013 HS With Automatic Failover com Timeout<\/a><\/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>Ol\u00e1 Pessoal, Continuando a s\u00e9rie de posts sobre Database Mirroring que j\u00e1 tenho semi prontos (faltam mais 3 posts ap\u00f3s esse), segue mais um teste realizado. O objetivo desse teste \u00e9 provar que o servidor de produ\u00e7\u00e3o em um Mirror pode parar mesmo sem acontecer nenhum problema com ele. Em seguida, tamb\u00e9m \u00e9 dada uma [&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,33,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-1631","post","type-post","status-publish","format-standard","hentry","category-administracao-de-bd","category-sql-server","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\/1631","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=1631"}],"version-history":[{"count":0,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/1631\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=1631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=1631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=1631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}