Trouble Shooting/개발환경

macOS에서 VirtualBox Guest OS로 설치한 SQL Server에 연결 안될 때

Gradler 2019. 8. 1. 14:47

※ 환경

- 호스트OS : macOS Mojave (10.14.3)

- 게스트OS : Windows 10 (SQL Server 2016)

- 가상화 솔루션 : VirtualBox

 

※ 상황

윈도우 10 SQL Server 설치 개발은 맥에서 하기 위해 게스트 OS에서 실행 중인 데이터베이스 엔진에 접속해야 함.

VM 네트워크 설정에서 포트포워딩 등의 기본적인 설정은 모두 완료 했지만 SQL Operations Studio 게스트OS SQL Server 커넥션을 시도하면 아래와 같은 에러 문구가 뜨면서 연결이 안됨

 

Error Message

Error Message : 
connection timeout expired. the timeout period elapsed while attempting to consume 
the pre-login handshake acknowledgement. this could be because the pre-login handshake 
failed or the server was unable to respond back in time. the duration spent while 
attempting to connect to this server was - [pre-login] initialization=0; 
handshake=14998;

 

구글신을 이용해 해결방법을 찾다보니 아래와 같은 해결 방법이 제시 되었고, 가장 많은 사람이 추천한 솔루션!

(https://stackoverflow.com/questions/15488922/connection-to-sql-server-works-sometimes)

  • Start Sql Server Configuration Manager
  • Open the node SQL Server Network Configuration
  • Left-click Protocols for MYSQLINSTANCE
  • In the right-hand pane, right-click TCP/IP
  • Click Properties
  • Select the IP Addresses tab
  • For each listed IP address, ensure Active and Enabled are both Yes.
  • For each listed IP address, ensure TCP Dynamic Ports is empty and TCP Port = 1433 (or some other port)
  • Open windows firewall and check that the the port is Opened in Incoming connections

나는 그래도 안됨.. 사실 과정은 SQL Server에 sa 계정으로 인증하기 위해 사전에 이미 해두엇음..

 

그러다가 아래 댓글을 발견하고(추천수는 없었지만) 그래도 하나씩 체크 해보기로

 

The "Connection Timeout expired" error commonly occurs in the following cases

  • An instance of the SQL Server Database Engine is not running. > 돌고 있음
  • The SQL Server Browser service is not running. > 실행 중인 확인
  • The TCP/IP is disabled. > 위에서 이미 처리
  • The server name was typed incorrectly. > 서버이름 맞음 (서버이름이 다른 경우는 에러 메시지가 다르게 나옴)
  • There are network problems. > 네트워크 문제? 너무 추상적이라 체크해야 할지 모르겠음 일단 인터넷은 되니까 패스
  • The client and server are not configured to use the same network protocol. > 하나의 네트워크로 호스트와 게스트가 공유하고 있으니 문제도 아닌거 같음
  • The TCP/IP port for the Database Engine instance is blocked by a firewall. > 방화벽? 혹시 모르니 확인해볼까?

결론 : Guest OS Windows 10 방화벽 고급설정에서 1433 포트를 인바인드 규칙에 추가하여 해결

시댕 별것도 아닌걸로 2시간 날렸네 _

 

※ 윈도우10에서 방화벽 포트 허용 규칙 만드는 법

 

제어판 > 네트워크 > Windows 방화벽 > 고급 설정

 

인바운드 규칙 우클릭 > 새 규칙 선택
규칙 종류 "포트" 선택 후 다음
프로토콜 TCP > 특정 로컬 포트 "1433" 입력 후 다음
"연결 허용" 선택 후 다음
포트를 허용할 네트워크 체크 후 다음
방화벽 규칙의 이름 자유롭게 입력 후 마침

 

※ 여담으로 SQL Server를 설치한다는건 그렇지 않은 경우(혼자 SQL 공부하는 용도 외)도 있겠지만 대다수가 웹 어플리케이션에서 연결하기 위해 설치할텐데 SQL Server 설치가 끝나면 1433 방화벽 오픈 하겠습니까? 뭐 이런 방식의 설정 변경이 자연스러운 흐름속에서 이루어지게 UX가 설계된다면 좋지 않았을까 하는 아쉬움이 있다.