programing

SQL Server Management Studio를 사용하여 Azure Virtual Machine에서 호스팅되는 SQL Server Express 인스턴스에 원격으로 연결

randomtip 2021. 1. 16. 09:31
반응형

SQL Server Management Studio를 사용하여 Azure Virtual Machine에서 호스팅되는 SQL Server Express 인스턴스에 원격으로 연결


초기 시도

SQL Server 2012 Express 데이터베이스 엔진 구성 요소를 방금 설치 한 Windows Server 2012가있는 Azure VM이 있습니다. 그런 다음 여기있는 지침에 따라 SQL Server Management Studio에 원격으로 연결했습니다.

  1. 가상 머신에 대한 TCP 엔드 포인트 생성
  2. Windows 방화벽에서 TCP 포트 열기
  3. TCP 프로토콜에서 수신하도록 SQL Server 구성
  4. 혼합 모드 인증을위한 SQL Server 구성
  5. SQL Server 인증 로그인 생성
  6. 가상 머신의 DNS 이름 확인
  7. 다른 컴퓨터에서 데이터베이스 엔진에 연결

7 단계 후에 다음 오류가 발생했습니다.

SQL Server에 연결하는 동안 네트워크 관련 오류 또는 인스턴스 관련 오류가 발생했습니다. 서버를 찾을 수 없거나 액세스 할 수 없습니다. 인스턴스 이름이 올 바르고 SQL Server가 원격 연결을 허용하도록 구성되어 있는지 확인하십시오. (공급자 : 명명 된 파이프 공급자, 오류 : 40-SQL Server에 대한 연결을 열 수 없음) (Microsoft SQL Server, 오류 : 53)

원격으로 연결하기 전에 무엇을 구성해야합니까?

문제 해결

여기 에서 문제 해결 지침을 따랐습니다 . 아래의 각 인용구는 해당 링크를 설명하는 단계입니다.

SQL Server 데이터베이스 엔진의 인스턴스가 설치되어 실행 중인지 확인합니다.

끝난. SQL Server Express를 설치했으며 SQLEXPRESS라는 명명 된 인스턴스로 실행 중입니다.

명명 된 인스턴스에 연결하려는 경우 SQL Server Browser 서비스가 실행 중인지 확인합니다.

끝난. 여기있는 단계 에 따라 SQL Server Browser 서비스를 설정했습니다.

컴퓨터의 IP 주소를 가져옵니다.

끝난. 나중에 연결을 테스트하고 SQLEXPRESS에 대한 정적 포트를 설정하는 데 사용할 것입니다.

10.241.62.155

fe80 :: 45c : 8c29 : e19f : f78b % 15

SQL Server에서 사용하는 TCP 포트 번호를 가져옵니다.

끝난. SQL Server 관리 Studio의 서버 로그는 서버가 포트 49169에서 수신 된 것으로 나타났다.

프로토콜 활성화

끝난. 구성 관리자에서 이미 TCP / IP를 활성화했지만 만일을 대비하여 SQL Server 서비스를 다시 시작했습니다.

TCP / IP 연결 테스트

끝난. tcping.exe사용 하여 연결을 테스트했습니다 (cmd ping은 Azure에서 빠르게 작동하지 않음). 포트 80에 연결할 수있었습니다.

  • tcping.exe buddha.cloudapp.net> 성공
  • tcping.exe buddha.cloudapp.net 80> 성공

로컬 연결 테스트

끝난. 우리 는 명령 프롬프트에서 sqlcmd.exe사용 했으며 사용자 이름과 암호로 TCP를 통해 로컬로 연결할 수있었습니다.

  • sqlcmd -S Buddha \ SQLEXPRESS (공유 메모리 프로토콜을 통한 성공)
  • sqlcmd -S tcp : Buddha \ SQLEXPRESS (TCP를 통한 성공)
  • sqlcmd -S tcp : Buddha \ SQLEXPRESS -U sa -P (사용자 이름으로 TCP를 통한 성공)
  • sqlcmd -S tcp : 10.241.62.155 \ SQLEXPRESS -U sa -P (내부 IP로 성공)

방화벽에서 포트 열기

SQLEXPRESS가 수신하는 포트를 열었습니다. 서버 로그 (위)는 SQLEXPRESS가 포트 49169에서 수신 대기하고 있음을 보여 주었지만 이것은 많은 동적 포트 중 하나 일 뿐이며 정적 포트 1435를 설정하려고했습니다.

  • WF.msc를 사용하여 포트 1435에 대한 인바운드 TCP 규칙을 만듭니다.
  • Azure 관리 포털을 사용하여 포트 1435에 대한 TCP 끝점을 만듭니다.

문제 해결 지침에도 다음 내용이 나와 있습니다.

명명 된 인스턴스 또는 TCP 포트 1433 이외의 포트에 연결하는 경우 SQL Server Browser 서비스 용 UDP 포트 1434 도 열어야합니다 .

SQLEXPRESS (명명 된 인스턴스)를 연결하고 있으므로 UDP 용 포트 1434를 열어야했습니다.

  • WF.msc를 사용하여 포트 1434에 대한 인바운드 UCP 규칙 을 만듭니다 .
  • Azure 관리 포털을 사용하여 포트 1434에 대한 UDP 끝점 만들기

명명 된 인스턴스 연결에 대한 추가 연구에서 동적 포트 문제가 밝혀졌습니다. 포트 49169 (많은 효과적인 옵션 중 하나) 대신 포트 1435 (정적)를 사용하는 이유입니다.

SQL Server Express, SQL Server Compact 및 데이터베이스 엔진의 명명 된 인스턴스는 동적 포트를 사용합니다. 특정 포트를 사용하도록 이러한 인스턴스를 구성하려면 특정 TCP 포트에서 수신하도록 서버 구성 (SQL Server 구성 관리자)을 참조하세요. 그리고 여기 .

끝난. SQL 구성 관리자> SQL Server 네트워크 구성> SQLEXPRESS의 프로토콜> TCP / IP로 이동하여 다음을 수행했습니다.

프로토콜 탭> 모두 듣기> 아니오.

IP 주소 탭> 나열된 각 주소에 대해

  • 사용> 예
  • TCP Dynamic Ports > Blank (delete the zero)
  • TCP Port > 1435 (or your choice)

After restarting the SQLEXPRESS service, we again looked in the SQL Server Management Studio logs, and found that the Server is Listening on port 1435!!! Hooray!

Testing the Connection

Done. We opened SQL Server Management Studio on our local (non-Azure) computer and connected.

  • buddha.cloudapp.net,1435 OR buddha.cloudapp.net\SQLEXPRESS
  • sa
  • password

Success.


Here are the three web pages on which we found the answer. The most difficult part was setting up static ports for SQLEXPRESS.

Provisioning a SQL Server Virtual Machine on Windows Azure. These initial instructions provided 25% of the answer.

How to Troubleshoot Connecting to the SQL Server Database Engine. Reading this carefully provided another 50% of the answer.

How to configure SQL server to listen on different ports on different IP addresses?. This enabled setting up static ports for named instances (eg SQLEXPRESS.) It took us the final 25% of the way to the answer.


The fact that you're getting an error from the Names Pipes Provider tells us that you're not using the TCP/IP protocol when you're trying to establish the connection. Try adding the "tcp" prefix and specifying the port number:

tcp:name.cloudapp.net,1433

I too struggled with something similar. My guess is your actual problem is connecting to a SQL Express instance running on a different machine. The steps to do this can be summarized as follows:

  1. Ensure SQL Express is configured for SQL Authentication as well as Windows Authentication (the default). You do this via SQL Server Management Studio (SSMS) Server Properties/Security
  2. In SSMS create a new login called "sqlUser", say, with a suitable password, "sql", say. Ensure this new login is set for SQL Authentication, not Windows Authentication. SSMS Server Security/Logins/Properties/General. Also ensure "Enforce password policy" is unchecked
  3. Under Properties/Server Roles ensure this new user has the "sysadmin" role
  4. In SQL Server Configuration Manager SSCM (search for SQLServerManagerxx.msc file in Windows\SysWOW64 if you can't find SSCM) under SQL Server Network Configuration/Protocols for SQLExpress make sure TCP/IP is enabled. You can disable Named Pipes if you want
  5. Right-click protocol TCP/IP and on the IPAddresses tab, ensure every one of the IP addresses is set to Enabled Yes, and TCP Port 1433 (this is the default port for SQL Server)
  6. In Windows Firewall (WF.msc) create two new Inbound Rules - one for SQL Server and another for SQL Browser Service. For SQL Server you need to open TCP Port 1433 (if you are using the default port for SQL Server) and very importantly for the SQL Browser Service you need to open UDP Port 1434. Name these two rules suitably in your firewall
  7. Stop and restart the SQL Server Service using either SSCM or the Services.msc snap-in
  8. In the Services.msc snap-in make sure SQL Browser Service Startup Type is Automatic and then start this service

At this point you should be able to connect remotely, using SQL Authentication, user "sqlUser" password "sql" to the SQL Express instance configured as above. A final tip and easy way to check this out is to create an empty text file with the .UDL extension, say "Test.UDL" on your desktop. Double-clicking to edit this file invokes the Microsoft Data Link Properties dialog with which you can quickly test your remote SQL connection

ReferenceURL : https://stackoverflow.com/questions/15956465/use-sql-server-management-studio-to-connect-remotely-to-an-sql-server-express-in

반응형