Pozdravljeni,
Uspelo mi je uspešno postaviti mirroring baze. Odločil sem se za high availability opcijo (principal, mirror, witness). Na nivoju strežnikov zgleda, da poteka vse ok. Če ugasnem en strežnik, drug avtomatko prevzamo pravo vlogo.
Zatakne pa se pri odjemalcih. S connection stringom "Data source=xxx.xxx.xxx.1;Failover Partner=xxx.xxx.xxx.2;initial catalog=pass2;integrated security=SSPI;packet size=4096" naj bi namreč povedal, da če datasource xxx.xxx.xxx.1 ni dosegljiv, da naj avtomatsko poskusi s povezavo na xxx.xxx.xxx.2. Če pa izklopim strežnik xxx.xxx.xxx.1, pa dobim spodnjo napako:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Source Error: Line 20: cmd.Parameters.AddWithValue("@p2", DateTime.Now.ToString());;
Line 21: cmd.Connection = conn;
Line 22: conn.Open();
Line 23: cmd.ExecuteNonQuery();
Line 24: conn.Close();
Koda, s katero se pa povezujem, pa je:
using System;
System;using System.Data.SqlClient;
System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data source=xxx.xxx.xxx.1;Failover Partner=xxx.xxx.xxx.2;initial catalog=pass2;integrated security=SSPI;packet size=4096");
SqlCommand cmd = new SqlCommand("INSERT INTO Categories ( creation_date, name) values(@p1,@p2)");
cmd.Parameters.AddWithValue("@p1",DateTime.Now);
cmd.Parameters.AddWithValue("@p2", DateTime.Now.ToString());; cmd.Connection = conn; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } }
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
A ima kdo kakšno idejo kje se skriva napaka?
lp,
Rok
spirit1 - sreda, 20. junij 2007
probaj protokol nastavit na tcp/ip in ne na named pipes.
Ripp - sreda, 20. junij 2007
Še to, povezava na bazo na drug strežnik dela brez problema (če zamenjam xxx.xxx.xxx.1 z xxx.xxx.xxx.2);