MS SQL Server 2008 용 포트를 찾는 방법은 무엇입니까?
로컬 컴퓨터에서 MS SQL Server 2008을 실행하고 있습니다. 기본 포트가 1433이라는 것을 알고 있지만이 포트에서 수신하지 않는 방법이 있습니다. SQL은 Express 에디션입니다.
포트를 찾기 위해 이미 로그, SQL Server Management Studio, 레지스트리 및 확장 저장 프로 시저를 시도했습니다. 그러나 나는 그것을 찾을 수 없었다. 제발 도와주세요. 감사.
Start
Windows 에서 버튼을 클릭 합니다. 이동All Programs -> Microsoft SQL Server 2008 -> Configuration Tools -> SQL Server Configuration Manager
를 클릭 SQL Native Client 10.0 Configuration -> Client Protocols -> TCP/IP
(오른쪽 선택을 클릭 더블 클릭 Properties
)에TCP/IP
찾을 수 Default Port 1433
있습니다.
연결에 따라 포트 번호가 다를 수 있습니다.
당신은 또한 볼 수 있습니다
netstat -abn
열린 상태로 유지하는 해당 응용 프로그램과 함께 포트를 제공합니다.
편집 : 또는 TCPView .
다음은 내가 찾은 5 가지 방법입니다.
- 방법 1 : SQL Server 구성 관리자
- 방법 2 : Windows 이벤트 뷰어
- 방법 3 : SQL Server 오류 로그
- 방법 4 : sys.dm_exec_connections DMV
- 방법 5 : xp_instance_regread를 사용하여 레지스트리 읽기
방법 4 : sys.dm_exec_connections DMV
이것은 거의 가장 쉬운 방법이라고 생각합니다.
DMV는 SQL Server 인스턴스를 모니터링하는 데 사용할 수있는 서버 상태를 반환합니다. sys.dm_exec_connections DMV를 사용하여 아래 T-SQL 코드를 사용하여 SQL Server 인스턴스가 수신 대기중인 포트 번호를 식별 할 수 있습니다 .
SELECT local_tcp_port
FROM sys.dm_exec_connections
WHERE session_id = @@SPID
GO
Result Set:
local_tcp_port
61499
(1 row(s) affected)
방법 1 : SQL Server 구성 관리자
1 단계. 시작> 모든 프로그램> Microsoft SQL Server 2012> 구성 도구> SQL Server 구성 관리자를 클릭합니다.
2 단계. SQL Server 구성 관리자> SQL Server 네트워크 구성> 프로토콜로 이동합니다.
3 단계. TCP / IP를 마우스 오른쪽 버튼으로 클릭하고 속성을 선택합니다.
단계 4. TCP / IP 속성 대화 상자에서 IP 주소 탭으로 이동하여 IPAll 그룹으로 스크롤합니다.
SQL Server가 정적 포트에서 실행되도록 구성된 경우 TCP 포트 텍스트 상자에서 사용할 수 있으며 동적 포트에서 구성된 경우 현재 포트는 TCP 동적 포트 텍스트 상자에서 사용할 수 있습니다. 여기 내 인스턴스는 포트 번호 61499에서 수신 대기합니다.
다른 방법은 여기에서 찾을 수 있습니다. http://sqlandme.com/2013/05/01/sql-server-finding-tcp-port-number-sql-instance-is-listening-on/
나는 방금 원격 연결을 만드는 데 문제가 있었고 방화벽에서 1433 포트를 설정하는 것이 왜 제대로 작동하지 않는지 이해할 수 없었기 때문에 이것을 발견했습니다. 이제 드디어 전체 사진을 얻었으므로 공유 해야겠다고 생각했습니다.
먼저 SQLEXPRESS 프로토콜에서 SQL Server 구성 관리자를 사용하여 "TCP / IP"를 활성화해야합니다!
명명 된 인스턴스 (이 경우 "SQLExpress")가 사용되면 동적 포트에서 수신 대기합니다. 이 동적 포트를 찾으려면 몇 가지 옵션이 있습니다. 몇 가지를 예로 들면 :
에
ERRORLOG
위치한 SQL Server 확인'{MS SQL Server Path}\{MS SQL Server instance name}\MSSQL\Log'
(내부에는 다음과 유사한 행이 있습니다"2013-07-25 10:30:36.83 Server Server is listening on [ 'any' <ipv4> 51118]"
.-> 따라서이 경우 51118이 동적 포트입니다.레지스트리 확인 :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\{MSSQL instance name}\MSSQLServer\SuperSocketNetLib\Tcp\IPAll
, 내 경우TcpDynamicPorts=51118
.편집 :
{MSSQL instance name}
뭔가 같은 :MSSQL10_50.SQLEXPRESS
뿐만 아니라SQLEXPRESS
물론 방화벽에서이 TCP 포트를 허용하고 다음을 전달하여 원격 연결을 생성하면 "x.x.x.x,51118"
(여기서 xxxx는 서버 IP) 이미이 시점에서 해결됩니다.
But then I wanted to connect remotely by passing in the instance name (e.g: x.x.x.x\SQLExpress
). This is when SQL Browser service comes into play. This is the unit which resolves the instance name into the 51118 port. SQL Browser service listens on UDP port 1434 (standard & static), so I had to allow this also in server's firewall.
To extend a bit the actual answer: if someone else doesn't like dynamic ports and wants a static port for his SQL Server instance, should try this link.
In the ERROLOG log for a line like below. If you don't see it the SQL Server isn't enabled for remote access, or it is just not via TCP. You can change this via the SQL Server Configuration Manager.
Server is listening on [ 192.128.3.2 <ipv4> 1433].
I solved the problem by enabling the TCP/IP using the SQL Server Configuration Manager under Protocols for SQLEXPRESS2008, i restarted the service and now the "Server is listening on" shows up in the ERRORLOG file
Try this (requires access to sys.dm_exec_connections
):
SELECT DISTINCT
local_tcp_port
FROM sys.dm_exec_connections
WHERE local_tcp_port IS NOT NULL
USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on', 'any', NULL, NULL, N'asc'
GO
[Identify Port used by Named Instance of SQL Server Database Engine by Reading SQL Server Error Logs]
You can use this two commands: tasklist
and netstat -oan
Tasklist.exe
is like taskmgr.exe
but in text mode.
With tasklist.exe
or taskmgr.exe
you can obtain a PID of sqlservr.exe
With netstat -oan
, it shows a connection PID, and you can filter it.
Example:
C:\>tasklist | find /i "sqlservr.exe"
sqlservr.exe 1184 Services 0 3.181.800 KB
C:\>netstat -oan | find /i "1184"
TCP 0.0.0.0:1280 0.0.0.0:0 LISTENING 1184
In this example, the SQLServer port is 1280
Extracted from: http://www.sysadmit.com/2016/03/mssql-ver-puerto-de-una-instancia.html
I use the following script in SSMS
SELECT
s.host_name
,c.local_net_address
,c.local_tcp_port
,s.login_name
,s.program_name
,c.session_id
,c.connect_time
,c.net_transport
,c.protocol_type
,c.encrypt_option
,c.client_net_address
,c.client_tcp_port
,s.client_interface_name
,s.host_process_id
,c.num_reads as num_reads_connection
,c.num_writes as num_writes_connection
,s.cpu_time
,s.reads as num_reads_sessions
,s.logical_reads as num_logical_reads_sessions
,s.writes as num_writes_sessions
,c.most_recent_sql_handle
FROM sys.dm_exec_connections AS c
INNER JOIN sys.dm_exec_sessions AS s
ON c.session_id = s.session_id
--filter port number
--WHERE c.local_tcp_port <> 1433
This may also be done via a port scan, which is the only possible method if you don't have admin access to a remote server.
Using Nmap (http://nmap.org/zenmap/) to do an "Intense TCP scan" will give you results like this for all instances on the server:
[10.0.0.1\DATABASE]
Instance name: DATABASE
Version: Microsoft SQL Server 2008 R2 RTM
Product: Microsoft SQL Server 2008 R2
Service pack level: RTM
TCP port: 49843
Named pipe: \\10.0.0.1\pipe\MSSQL$DATABASE\sql\query
Important note: To test with query analyzer or MS SQL Server Management Studio you must form your server name and port differently than you would normally connect to a port, over HTTP for instance, using a comma instead of a colon.
- Management Studio Server Name:
10.0.0.1,49843
- Connection String:
Data Source=10.0.0.1,49843
however
- JDBC Connection String:
jdbc:microsoft:sqlserver://10.0.0.1:49843;DatabaseName=DATABASE
This works for SQL Server 2005 - 2012. Look for event id = 26022 in the error log under applications. That will show the port number of sql server as well as what ip addresses are allowed to access.
In addition to what is listed above, I had to enable both TCP and UDP ports for SQLExpress to connect remotely. Because I have three different instances on my development machine, I enable 1430-1435
for both TCP and UDP.
PS solution, will cover all instances on the host + will give you all of the addresses of the connected clients, all nice and clean:
ForEach ($SQL_Proc in Get-Process | Select-Object -Property ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
Get-NetTCPConnection | `
Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
Select-Object -Property `
@{Label ="Process_Name";e={$SQL_Proc.ProcessName}}, `
@{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }}, `
@{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
Format-Table
}
Second solution, for some might be easier is to open resource monitor
and go to the Network>TCP Connections
from there you will be able to see something like that, just look for your SQLSERVER process:
참고 URL : https://stackoverflow.com/questions/1518823/how-to-find-the-port-for-ms-sql-server-2008
'program story' 카테고리의 다른 글
printf ()에서 후행 0을 피하십시오. (0) | 2020.08.15 |
---|---|
nServiceBus vs Mass Transit vs Rhino Service Bus vs 기타? (0) | 2020.08.15 |
Spring-현재 스레드에 사용할 수있는 실제 트랜잭션이있는 EntityManager가 없습니다. '지속성'호출을 안정적으로 처리 할 수 없습니다. (0) | 2020.08.14 |
중복 된 코드는 단위 테스트에서 더 견딜 수 있습니까? (0) | 2020.08.14 |
JavaScript를 사용하여 브라우저 언어를 얻는 방법 (0) | 2020.08.14 |