2019년 산업용 네트워크 기술별 시장동향 및 시장점유율
점점 더 많은 산업용 장비들이 네트워크에 연결되고 있다. 2019년에는 새롭게 연결되는 노드의 수가 10% 증가할 것으로 예상된다. 그러나 기술들간 희비는 교차한다.

예를 들면 산업용 이더넷 및 무선은 계속 빠르게 성장을 하고 있지만, 필드버스 시장은 올해 처음으로 점유율 감소를 면치 못할 것으로 보인다. 이러한 현상은 산업용 네트워크 기술도 고속으로 전환되고 있다는 것을 의미한다.

특히 전세계적으로 불고 있는 스마트팩토리 추진에 대한 열풍으로 기존의 필드버스 기술은 그 한계를 분명히 노출한 반면, 보다 고속으로 데이터를 전송할 수 있는 이더넷은 더욱 각광받고 있다.


HMS 네트웍스(HMS Networks)가 발표한 산업용 네트워크 마켓에 따르면, 산업용 이더넷 시장은 현재 새로 설치된 노드의 59%(작년 52%)를 차지하고 있는 반면, 필드버스는 35%로 지난해 42%에 비해 감소세를 기록했다.

EtherNet/IP는 여전히 가장 광범위하게 설치된 네트워크로 점유율이 15%에 달하며, PROFINET은 14%대에 머물렀다. 무선 기술은 지속적으로 개발이 이뤄지면서 마켓의 6%대를 유지하고 있다(작년 6%).


산업용 이더넷의 지속적인 성장
지난해 HMS는 산업용 이더넷이 처음으로 전통적인 필드버스 시장을 능가했다는 결론을 내렸다. 그리고 이러한 흐름은 2019년에도 계속되고 있는 것으로 분석했다.

산업용 이더넷은 20%(지난해 22%)의 안정적인 성장률을 기록하며 현재 세계 시장의 59%를 차지하고 있다(지난해 52% 대비). 이중 EtherNet/IP는 시장의 15%를 차지하는 가장 큰 산업용 이더넷 네트워크이지만, PROFINET 또한 현재 14%의 점유율을 기록하면서 이 차이를 좁히고 있다.

그 뒤를 이어 EtherCAT이 7%, POWERLINK가 5%, Modbus-TCP가 4%를 차지하고 있는데, 이들은 모두 안정적인 성장세를 보이고 있다.


HMS 네트웍스가 분석한 2019년 산업용 네트워크의 시장 점유율: 필드버스, 산업용 이더넷 및 무선
2019년 5월 7일, 할름스타드(Halmstad)
 

필드버스 시장의 감소
필드버스는 처음으로 -5%(지난해 6% 성장)의 성장률을 기록하면서 새로 설치된 노드의 35%를 차지했다. 필드버스 기술 중에서는 PROFIBUS이 가장 높은 점유율을 기록하고 있는데, 그 비중은 세계 시장의 10%를 차지하고 있다. 그 다음으로 CC-Link 6%, Modbus-RTU 5%를 기록하고 있다.

HMS의 CMO(Chief Marketing Officer)인 앤더스 한손(Anders Hansson)은 “산업용 이더넷으로의 전환은 계속되고 있는데, 이는 높은 성능에 대한 요구와 공장 설비 및 IT 시스템/IIoT 애플리케이션 간의 통합 필요성에 의해 주도되고 있다”고 말했다.

그는 이어 “이 같은 업계 변화에 의해 처음으로 전통적인 필드버스가 새로 설치된 노드에서 실제 감소했음을 확인할 수 있었다. 하지만 산업용 이더넷은 기존 Ethernet/IP, PROFINET, EtherCAT, POWERLINK, Modbus-TCP뿐만 아니라 ‘기타 이더넷’으로 간주되는 네트워크를 포함해 많은 네트워크들이 모두 양호한 성장세를 보이고 있다”고 강조했다.


강력한 추진력의 무선 솔루션
무선 기술은 30%(지난해 32%)의 지속적인 성장률을 기록하며, 전체 시장의 6%(지난해 6%)를 차지하고 있다. 무선 기술 중 WLAN이 가장 많이 사용되고 있으며, 블루투스가 그 뒤를 따르고 있다.

앤더스 한손은 “머신 빌더 및 시스템 통합업체들은 새롭고 혁신적인 자동화 아키텍처를 실현하기 위해 무선 기술을 채택하고 있다”며, “이를 통해 사용자는 배선을 줄이고, 연결 및 제어를 위한 새로운 솔루션을 구현할 수 있다”고 말했다.

그는 더불어 전세계적으로 스마트하고 유연한 팩토리를 구현하기 위해 셀룰러 기술(예, 사설 LTE/5G 네트워크)을 활용하는 사례도 증가하고 있다고도 덧붙였다.


HMS 네트웍스가 분석한 2018년 산업용 네트워크의 시장 점유율: 필드버스, 산업용 이더넷 및 무선
 

지역별로 다분화되는 네트워크
네트워크의 점유율은 지역별로 다소 차이를 보이고 있다. 유럽 및 중동에서는 EtherNet/IP 및 PROFINET이 주도하고 있으며, PROFIBUS 또한 여전히 널리 사용되고 있다. 이외에도 EtherCAT 및 이더넷 POWERLINK 등이 많이 적용되고 있다.

미국 시장은 CIP 네트워크가 주도하고 있지만, EtherNet/IP로의 전환이 뚜렷하게 나타나고 있다. EtherCAT 또한 시장 점유율을 지속적으로 유지하고 있다.

아시아의 경우 시장을 확실하게 주도하는 네트워크는 없지만, PROFINET, EtherNet/IP, PROFIBUS, EtherCAT, Modbus, CC-Link 등이 널리 사용되고 있으며, 이더넷 버전인 CC-Link IE Field 또한 잠재력을 확대해 나가고 있다.

오늘날에는 업체들이 주도하는 여러 산업용 통신 프로토콜이 존재한다. 이들 산업용 프로토콜을 알아보고, 실시간성과 시간결정성 그리고 낮은 대기시간이라는 요소를 충족하는 표준에 대해 살펴본다.

오늘날에는  ‘연결된 세계Connected World’가 실현됨에 따라 생산현장에서 역시 연결을 중요시하고 있다. 인간 기계 인터페이스(HMI)·프로그래머블 로직 컨트롤러(PLC)·모터 및 센서 등의 장비들이 확장과 효율성을 위해 서로 연결되고 있다.

지금까지 공장을 구성하는 요소들은 크게 제어 영역 네트워크(CAN)·Modbus·PROFIBUS·CC-Link 등의 필드버스 프로토콜을 통해 연결되어왔다.

최근에는 산업용 이더넷이 인기를 얻고 있다. 연결이 간편하고 속도가 빠르며, 연결거리 또한 길고 보다 많은 장비와 연결할 수 있기 때문이다.

오늘날에는 다양한 업체들이 주도하는 여러 산업용 이더넷 프로토콜이 존재한다. 최근 부상한 산업용 이더넷 프로토콜 표준에 대해 살펴본다.

산업자동화의 구성요소

산업자동화를 구성하는 요소로는 크게 PLC 컨트롤러와 HMI 패널, 산업용 드라이브 그리고 센서 등 네 가지가 있다. 

1. PLC 컨트롤러

PLC 컨트롤러는 산업자동화 시스템의 ‘뇌’를 담당한다. 릴레이 제어와 모션컨트롤, 입출력 및 공정제어 그리고 분산제어 시스템과 네트워크 제어 등을 실현한다. 
PLC는 열기·냉기·수분·진동을 비롯한 혹독한 환경에서 정밀도와 결정성 그리고 실시간 제어를 유지할 수 있어야 한다. 여타 제품군에게 신뢰성 있는 통신 연결을 제공해야 하기 때문이다.

2. HMI

HMI는 그래픽 사용자 인터페이스(GUI)를 제공한다. 명령 입력과 피드백 출력을 통해 산업용 장비 등을 제어한다. HMI는 통신 연결을 통해 여타 산업용 시스템과 소통한다.

3. 산업용 드라이브

산업용 드라이브는 모터 작동 제어를 최적화할 수 있는 컨트롤러다. 산업용 드라이브는 여러 산업분야에서 사용되며, 다양한 전압 및 전력을 제어할 수 있다. AC 및 DC 드라이브뿐 아니라 모터 피드백 시스템을 장착해 서보 메커니즘의 동작 및 성능을 제어할 수 있는 서보 드라이브도 존재한다.

4. 센서

센서는 산업자동화 시스템의 손과 발 역할을 한다. 작업 상태를 실시간으로 관찰하고 감시하며 측정하는 등의 작업을 수행한다. 시스템 제어 측면에서 센서는 트리거가 되는 지점을 명확하게 지정할 수 있고, 피드백 기능 역시 제공한다.

5. 통신

은 모든 구성요소를 잇는 중추 역할을 한다. 보다 효율적인 자동 생산 시스템을 구축하는 열쇠다.  

기존 산업용 통신 프로토콜
산업용 통신은 시리얼 인터페이스를 기반으로 개발되었다. 초기에는 다양한 기업에 의해 기술이 개발되고, 이후 표준화 작업을 거쳤다. 오늘날 시장에는 여러 표준이 공존하고 있다.

현재는 몇몇 기업들이 각각의 표준을 관장하고 있으며, 이로 인해 산업자동화 장비 제조업체들은 산업 표준 대부분을 구현해야 한다는 숙제를 안게 되었다. 그러다가 PROFIBUS와 CAN 버스 그리고 Modbus와 CC-LInk 같은 시리얼 통신 기반의 프로토콜이 등장했다. 이들 프로토콜로 인해 마스터와 슬레이브라는 구성이 보편화되었다.

1. PROFIBUS는 공장자동화 및 공정자동화를 비롯한 산업자동화 시스템 분야에서 활발하게 활약하고 있다. PROFIBUS는 공정 데이터 및 보조 데이터 전송에 디지털 통신 방식을 활용하고, 최대 12Mbps 속도를 낼 수 있으며, 최대 126개 어드레스를 지원한다.

2. CAN 버스는 고 집적 시리얼 버스 시스템이다. 자동차 산업을 겨냥하여 만든 시스템이지만, 이후 산업자동화용 필드버스로 그 범위를 넓혔다. CAN 버스는 최대 1Mbps 속도로 물리 링크 계층 및 데이터 링크 계층을 제공하는 시리얼 통신을 제공한다.

CANopen 및 DeviceNet 프로토콜은 CAN 버스의 상위 개념으로, 동일한 산업용 네트워크를 활용하는 장치와의 상호운용을 보장한다.

CANopen 네트워크는 최대 127개의 노드를 지원한다. 반면 DeviceNet은 64개의 노드를 지원한다.

3. Modbus는 사용이 단순하고 강하며 공개적인(Openly Published), 즉 로열티 지불이 불필요한 시리얼 버스다. 동일한 링크 내에서 최대 247개의 노드를 연결할 수 있다. 

Modbus는 구현이 용이하며, RS-232 및 RS-485 물리 연결을 실현함과 동시에 최대 115K보(baud) 속도를 낸다.

4. CC-Link는 일본 미쓰비시가 개발한 개방형 구조의 산업용 네트워크 프로토콜이다. 일본을 비롯한 아시아 지역에서 특히 강세를 보인다. 

CC-Link는 RS-485를 그 기반으로 하고 있다. 동일한 네트워크에서 최대 64개의 노드를 연결할 수 있으며, 최대 속도는 10Mbps에 달한다.


 
산업용 이더넷 통신 프로토콜
오늘날 이더넷은 높은 비용효율성을 자랑한다. 단순한 물리적 연결만으로도 향상된 속도를 제공하기 때문이다. 많은 산업용 통신이 이더넷 기반 솔루션으로 변모하는 이유이다. 

TCP/IP를 활용한 이더넷 통신은 일반적으로 비 결정적이며 반응 시간은 100㎳ 남짓이다. 산업용 이더넷 프로토콜은 수정을 거친 매체 접근 제어(Media Access Control, MAC) 층을 활용해 대기시간을 낮추고 결정적 응답성(Deterministic Responses)을 한층 높였다. 

이더넷을 활용하면 네트워크 토폴로지를 유연하게 선택할 수 있으며, 하나의 시스템에서 여러 개의 노드를 유연하게 구성할 수 있다. 

최근 인기를 끌고 있는 산업용 네트워크를 살펴보자.

1. EtherCAT은 Beckhoff가 개발한 네트워크 프로토콜이다. EtherCAT은 보다 빠른 패킷 처리를 실현하며, 실시간 이더넷을 자동화 응용사례에 접목시켜 PLC부터 I/O 및 센서에 이르는 자동화 시스템의 전반적 연결성을 확장한다.

EtherCAT은 IEEE 802.3 이더넷 프레임 표준을 활용한다. 각 슬레이브 노드는 각자 가지고 있는 데이터그램을 처리하고, 슬레이브가 운반하는 프레임에 새 데이터를 삽입한다. 하드웨어가 이러한 공정을 관장하며, 이를 통해 각 노드가 처리에 따른 지연시간을 최소화하고 응답시간을 극대화한다.

EtherCAT은 MAC 계층 프로토콜이며, 따라서 TCP/IP·UDP·웹 서버 등 다양한 이더넷 프로토콜로서 작용할 수 있다.
EtherCAT은 하나의 시스템에서 최대 65,535개의 노드를 연결할 수 있다. 

EtherCAT 마스터는 표준 이더넷 컨트롤러로 작용하며, 이를 통해 네트워크 구성을 간소화한다. EtherCAT의 각 슬레이브 노드는 대기시간이 낮아 유연하고 비용이 낮은 산업용 이더넷 솔루션을 구축하기에 적합하다.

2. EtherNet/IP는 로크웰 오토메이션을 주축으로 개발된 산업용 이더넷 프로토콜이다. MAC 계층 프로토콜인 EtherCAT과는 달리 응용 계층 프로토콜(Application-Layer Protocol)이다. EtherNet/IP가 TCP/IP의 상위 개념이기도 한 이유다.

EtherNet/IP는 표준 이더넷 물리 연결 및 데이터 연결, 네트워크 및 전송 계층을 사용한다. 또한 TCP/IP를 활용한 Common Industrial Procotol(CIP) 구조에 기반을 두고 있다. CIP는 산업자동화 시스템에서 사용할 수 있는 공통 메시지 및 서비스를 제공하며, 이를 통해 다양한 물리적 매체를 활용할 수 있다. 예를 들어 CAN 버스를 통한 CIP는 DeviceNet이라 부르며, 전용망(Dedicated Network)을 활용한 CIP는 ControlNet, Ethernet을 활용한 CIP는 EtherNet/IP라고 일컫는다.

EtherNet/IP는 TCP 방식을 활용한 CIP 연결을 통해 한 애플리케이션 노드에서 다른 노드로의 통신을 보장한다. 하나의 TCP 연결을 통해 다수의 CIP 연결을 구축할 수도 있다.

EtherNet/IP는 표준 이더넷 및 스위치를 활용한다. 따라서 연결할 수 있는 노드 수에 제한이 없다. 공장의 다양한 장치들을 하나의 네트워크만으로 연결할 수 있음을 의미한다. EtherNet/IP은 또한 효율적인 슬레이브 간의 직접 연결(피어 투 피어)을 보장한다. 

EtherNet/IP는 다양한 표준 인터넷 및 이더넷 프로토콜과 호환할 수 있지만, 여러 프로토콜과 혼용할 경우 실시간성 및 시간결정성에 제약이 생긴다. 

3. PROFINET은 지멘스·GE 등의 산업용 장비 제조업체가 주도하고 있는 산업용 이더넷 프로토콜이다.
PROFINET은 세 종류의 등급(클래스)을 가지고 있다.

PROFINET 클래스 A는 프록시와 이더넷 브릿징 그리고 FROFIBUS를 통해 PROFIBUS 연결을 지원한다. TCP/IP에서 원격 절차 호출(Remote Procedure Calling)을 실행하는 것이 특징이다. 사이클 타임은 약 100㎳가량이며, 이 사이클 타임은 대부분 데이터 패러미터 설정 및 I/O의 주기적 순환에 사용된다. PROFINET 클래스 A의 일반적인 응용사례로는 시설 및 건물 자동화 등이 있다. 

PROFINET Real-Time(PROFINET RT)라고도 불리는 PROFINET 클래스 B는 소프트웨어 기반의 실시간 접근을 실현하며, 사이클 타임을 약 10㎳가량으로 줄였다. 클래스 B는 공장자동화 및 공정자동화 분야에서 주로 사용한다. 

PROFINET Isochronous and Real-Time(IRT)라고도 부르는 PROFINET 클래스 C는 특별한 하드웨어를 필요로 한다. 사이클 타임을 1㎳ 미만으로 낮추기 위해서다. 고사양 하드웨어를 통해 모션컨트롤에 사용되는 실시간 산업용 이더넷의 충분한 성능을 보장한다. PROFINET RT는 PLC 기반 응용사례에 적합한 솔루션이며, PROFINET IRT는 모션컨트롤 응용사례에 적절한 선택이다.

PROFINET에는 가지형(Branch) 및 별형(Star) 토폴로지가 흔히 쓰인다. 시스템이 필요로 하는 적절한 성능을 달성하기 위해서는 신중한 토폴로지 선택이 필요하다.

4. Ethernet POWERLINK는 B&R이 개발한 이더넷 프로토콜이다. Ethernet POWERLINK는 IEEE 802.3를 기반으로 한 솔루션이며, 따라서 네트워크 토폴로지 선택과 교차 연결 그리고 핫 플러그(전원 연결을 유지한 채 장치를 연결하고 제거하는 것) 등이 자유롭다. POWERLINK는 폴링 방식 및 타임 슬라이싱 방식을 활용해 실시간 데이터 교환을 구현한다.

POWERLINK의 마스터(‘마스터 노드’라고도 부르는)는 패킷 지터를 통해 시간 동기화를 제어한다. 제어 가능한 시간은 10㎱ 수준에 달한다. 이러한 구조로 인해 POWERLINK는 PLC 대 PLC 통신부터 시각화, 모션컨트롤과 I/O제어까지 자동화 시스템의 다양한 장치에 적절한 솔루션을 제시할 수 있다.

POWERLINK 구현에 대한 진입장벽은 매우 낮은 편이다. 파워링크협회에서 오픈소스 스택 소프트웨어를 제공하기 때문이다. CANopen을 포용하고 있어 기존 필드버스 프로토콜에서 쉽게 업그레이드할 수 있다는 점 또한 장점이다.

5. Sercos Ⅲ는 시리얼 실시간 통신 시스템(Serial Real-time Communication System), 즉 Sercos의 3세대 표준이다. Sercos Ⅲ는 빠른 패킷 처리를 통한 실시간 이더넷 통신을 제공하며, 표준 TCP/IP 통신을 활용하여 대기시간이 낮은 산업용 이더넷을 구현한다. 

Sercos Ⅲ는 EtherCAT과 마찬가지로 슬레이브가 데이터를 추출해 이더넷 프레임에 삽입하는 방식으로 패킷을 생성한다. 낮은 대기시간을 실현하는 비결이다. 

Sercos Ⅲ는 데이터 입력과 출력을 두 개의 프레임을 활용해 해결한다. 하나의 프레임에서는 입력을, 다른 프레임에서는 출력을 수행하는 것. 이러한 방식을 활용하는 Sercos Ⅲ의 사이클 시간은 31.25㎳가량으로, EtherCAT 및 PROFINET IRT보다 빠르다.

Sercos Ⅲ는 원형(Ring) 토폴로지 혹은 선형(Line) 토폴로지를 활용한다. 원형 토폴로지를 활용했을 때의 장점 중 하나는 통신 이중화다. 하나의 슬레이브가 작업 오류를 일으켜 원형 구조가 깨지더라도 남아있는 슬레이브가 Sercos Ⅲ 프레임을 활용해 데이터를 입·출력한다. Sercos Ⅲ는 하나의 네트워크에 511개의 슬레이브 노드를 가지고 있다. 이러한 장점은 서보 드라이브 제어에서 크게 부각된다.

6. CC-Link IE는 CC-Link에 산업용 이더넷 기술을 도입한 프로토콜이다. 이 프로토콜 역시 미쓰비시가 개발했다. 

CC-Link IE에는 두 가지 버전이 존재한다. CC-Link IE Control과 CC-Link IE Field가 그것이다. CC-Link IE Control은 컨트롤러 대 컨트롤러 연결을 위해 개발된 프로토콜로, 네트워크 당 최대 120개의 노드를 연결할 수 있다. CC-Link IE Field는 I/O 통신과 모션컨트롤을 대상으로 개발되었으며, 네트워크 당 최대 254개의 노드를 연결할 수 있다. CC-Link IE는 이더넷 데이터 링크 계층을 활용하며, 제어 프레임을 이더넷 프레임에 삽입한 형태를 띤다. 

CC-link는 기본적으로 원형 토폴로지만을 지원한다. 이는 CC-Link IE가 네트워크 이중화를 지원하기는 하지만, 상대적으로 노드 개수에 제한이 있으며, 사이클 타임 역시 네트워크에 연결된 노드 수에 따라 달라짐을 의미한다.

7. Modbus/TCP는 Modbus가 한 단계 발전한 버전이다. 슈나이더 일렉트릭이 개발한 이 프로토콜은 TCP/IP를 활용해 Modbus 메시지 전송을 구현한다. Modbus/TCP는 표준 이더넷 네트워크를 통해 쉽게 구현할 수 있는 것이 장점이지만, 실시간성 및 시간결정성을 보장하지는 못한다.

미래를 손에 쥐다
우리는 지금 세 번째 산업혁명의 새벽을 보고 있다. 산업자동화가 다시 한 번 세계 경제에 활력을 불어넣을 것이라고 판단한다. 

산업자동화의 성공은 신뢰성과 효율성을 갖춘 통신 네트워크에 달려있다. 공장 내의 모든 구성요소가 함께 호흡할 수 있도록 만드는 것이야말로 산업자동화의 성공을 좌우한다.

이더넷이 점차 보편화되고 인기를 끎에 따라, 오늘날 다양한 산업용 이더넷 프로토콜이 현장에 구현되고 있다.

미래의 산업용 이더넷 프로토콜은 계속해서 발전을 거듭한다. 이들 모두가 뛰어난 실시간성과 시간결정성, 그리고 높은 신뢰성과 통합 안전을 향한다.

  • 모니터링 위해서 Data interface가 반드시 필요하다. 
  • 모니터링 Data를 중앙의 다른 시스템으로 전송하기 위해서도 Data interface가 필요하다. 
  • 아래와 같이 Sensor의 값을 EES로 전송하기 위해서 많은 conversion과 interface가 필요하다. 
  • 그래서 interface를 이해하는게 중요하다.

 

  1.  Sensor
  2. (AI module) PLC (Ethernet Module)
  3. Kepware Server
  4. (Communication Driver) HMI (DB Logger)
  5.  MSSQL
  6. EES interface module
  7. EES Server

 

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

이더넷이란 무엇인가?

1970년대에 처음 개발된 이더넷은 이후에 IEEE 802.3으로 표준화되었다. 이더넷은 IEEE(Institute of Electrical and Electronics Engineers) 802.3, 즉, 무선 이더넷 매체 접근 제어를 위한 물리 레이어와 데이터 링크 레이어를 정의하는 IEEE 표준을 준수하는 근거리 통신망(LAN) 제품을 말한다1. 이러한 표준은 이더넷 네트워크의 구성 규칙과 네트워크 요소들의 상호 작용 방식도 규정한다2.



컴퓨터는 이더넷을 통해 하나의 네트워크를 제어한다. 이더넷이 없었다면 지금의 세계에서 장치들 간의 통신이 이루어지지 않았을 것이다. 이더넷은 여러 대의 컴퓨터와 장치, 기기 등을 단체의 단일 네트워크에서 결합하여 모든 컴퓨터 사이에 통신이 이루어질 수 있도록 하기 위한 유선 및 케이블 시스템에 사용하는 국제 표준이다. 처음에는 하나의 케이블에서 시작해 여러 장치가 하나의 네트워크에서 서로 연결되도록 했지만, 현재는 이더넷 네트워크가 필요에 따라 새로운 장치로 확대될 수 있다. 이더넷은 현재 세계에서 가장 선호되는 동시에 널리 사용되는 네트워크 기술이다3.

이더넷의 원리

최신 기술은 산업 환경에서 특정 제조 데이터가 정확히 송수신되도록 하는 데 필요하다. 병을 채우는 공장을 예로 들면, 산업용 이더넷 자동화 기술을 사용해 네트워크로 관련 데이터를 전송하면 원하는 대로 병을 채울 수 있다.

이더넷에서 데이터 스트림은 잘게 분리(프레임화)되어서 각각이 데이터의 출발과 도착 등의 특정 정보를 담는다. 그러한 데이터는 네트워크가 필요할 때마다 데이터를 주고 받는데 필요하다.

이더넷 기술에서 사용되는 기타 용어에는 다음과 같은 것들이 있다.

• 매체(medium): 데이터 이동 경로를 제공하기 위해 이더넷 장치 연결에 필요한 이선식 동축 케이블이나 광섬유 케이블
• 세그먼트(segment): 공유되는 매체 하나
• 노드(node): 세그먼트에 연결되는 장치

표준 이더넷은 10 ~ 100Mbps의 속도로 데이터를 전송할 수 있다. 기가비트 이더넷은 IEEE 802.3 표준에서 1Gbps의 속도로 데이터를 전송한다. 기가비트 이더넷은 처음에는 기간망 전송과 고성능 또는 고용량 서버에 일반적으로 사용되지만, 시간이 지남에 따라 데스크톱 연결과 PC에서도 기가비트 이더넷를 지원하게 되었다.



이더넷에 대한 사실


이더넷은 Wi-Fi와 다르다. PC매거진 설명에 따르면 이더넷은 케이블을 사용해 컴퓨터와 장치를 연결하는데4 네트워크나 LAN 연결은 거의 대부분 이더넷으로 구성된다.

산업용 이더넷이란 무엇인가?

산업용 이더넷은 보통 더 튼튼한 커넥터와 케이블이 요구되며, 무엇보다 결정성(determinism, 네크워크를 통해 전송되는 메세지가 성공적으로 도달했는지를 규정)이 향상되어야 한다. 산업용 이더넷은 이 결정성을 높이기 위해서 특수한 프로토콜도 함께 사용한다. 더 많이 사용되는 산업용 이더넷 프로토콜에는 PROFINET, EtherNet/IP, EtherCAT, SERCOS III, POWERLINK가 있다.

산업용 이더넷의 경우 데이터 전송 속도가 10Mbps ~ 1Gbps다. 그러나 산업용 이더넷 애플리케이션에서는 100Mbps의 속도가 가장 흔히 사용된다5.

산업용 이더넷의 경우 고려해야 할 사항이 사무실에서 사용하는 일반 이더넷에 비해 많다. 공장에 설치한 제조 장비가 노출되는 온도, 진동, 방해가 되는 진동 수준 등 여러 요소들이 있다.



산업용 이더넷의 원리


PROFINET이나 EtherCAT 같은 산업용 이더넷용 프로토콜은 표준 이더넷을 변경해 특정 제조 데이터를 정확히 주고 받을 수 있을 뿐 아니라 특정한 조작을 수행하는 데 필요한 데이터를 제때 주고 받을 수도 있도록 해 준다. 예를 들어, 병의 속을 채우는 공장의 경우 산업용 이더넷 자동화 기술로 해당 데이터를 네트워크로 전송해서 원하는 대로 병을 채울 수 있다. 리얼 타임 오토메이션(Real Time Automation) 보고서에 따르면 병이 가득 찼을 때는 네트워크를 통해 중단명령이 전송된다6.

사실 사무실에서는 그런 메시지가 크게 중요하지 않다. 홈페이지를 찾을 수 없다는 화면이 뜨면 사용자는 그냥 새로고침 버튼을 누르면 된다. 그러나 공장에서는 사소한 일이 큰 문제가 될 수도 있다. 기업은 누군가가 그러한 오류를 발견해 직접 버튼을 누를 때까지 기다릴 수 있는 시간적 여유가 없다. 산업용 이더넷 자동화 네트워크는 병을 채우는 과정에서 발생하는 오류를 감지 및 자동으로 해당 공정을 중단시켜 시간, 제품, 비용의 낭비를 막는다.

일반 이더넷과 산업용 이더넷의 차이

리얼 타임 오토메이션 보고서는 이더넷이 산업 환경보다는 사무실에서 더 많이 사용될 수 있다고 말한다. 사무실용 이더넷은 기본적인 사용 수준을 고려해 설계되는 반면, 산업용 이더넷은 다층적인 부분을 고려해 훨씬 더 험준한 업무 환경에 적용될 수 있다.

산업용 이더넷은 공장 소음, 공정에서 필요한 사항, 더 험준한 환경을 처리하는 데 적합하며, 현장에서 데이터 충돌이 발생했을 때 더 적절히 대응할 수 있다.

산업용 이더넷 기술에서 사용되는 케이블과 커넥터는 일반 이더넷과 다를 수도 있다. 리얼 타임 오토메이션 보고서는 예를 들어 산업 환경에서 사용되는 커넥터는 끼워 결합시키는(snap-in lock) 기본적인 방식이 아니라고 말한다. 산업 환경에서는 더 확실한 잠금 방식이 필요하다. 험준한 환경에서 사용되는 애플리케이션의 경우 밀폐식 커넥터를 필요로 하는 경우가 많다.

케이블의 경우도 상업용이나 사무실용 이더넷과 산업용 이더넷이 서로 다를 수 있다. 비교적 안정적인 환경의 산업용 이더넷이라 하더라도 케이블의 피복 품질이 일반 이더넷 케이블보다 뛰어날 수도 있다. 또, 예상하는 것처럼 험준한 환경에서 사용되는 산업용 이더넷의 경우는 피복과 사용되는 금속의 품질을 높여 내구성을 향상시킨다.

결정성은 산업용 이더넷을 정의하고 일반 이더넷과 구별할 때 중요한 요인이다. 표준 이더넷은 그 자체로 결정성을 가지지 않지만7, 산업 환경에서는 결정성이 요구된다. 산업용 이더넷은 데이터 패킷을 정해진 시간에 전송하고 수신해야 하며, 데이터가 매번 전송될 것임을 보장할 수 있어야 한다.

그렇지 않고 산업 환경에서 장치 간에 데이터가 손실되거나 데이터 전송이 지연되면 제조 공정에서 커다란 결함이 발생한 것과 같은 수준의 심각한 문제가 될 수 있다. 이러한 실시간 정보 전송은 기업이 설치할 이더넷 솔루션 유형을 선택할 때 중요한 요인이 되는 경우가 많다. 기업은 구체적인 요건을 평가한 뒤 최적의 이더넷 솔루션을 결정해야 한다.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

4-1.산업용 통신 프로토콜  (0) 2021.05.23
4-0. 왜 interface가 필요한가?  (0) 2021.05.22
4-5. Kepware의 장점.  (0) 2021.05.22
8-9.Database mail  (0) 2021.05.20
8-7. View  (0) 2021.05.20
  • Data Interface에 최적화 된 프로그램이다. 
  • 성능이 아주 우수하다. 
  • 가격정책이 투명하다. 
  • PLC에서 Data를 읽어서, DB에 저장하는 프로젝트를 실행 한다고 하면, 
  • PLC프로토콜 분석 등 개발에만 몇개월이 소요될 수 있다. 
  • 그러나 Kepware의 2~3가지 제품만 구매하면, 수 일 만에 해결 할 수 있다. 
  • 모니터링 화면이 필요하지 않은 프로젝트에 저렴한 가격으로 공급 가능하다. 

 

[kepware] OPC 제품설명

 

kepware (http://www.kepware.com)

 

■ KEPServerEX - OPC Server

   Link : http://www.kepware.com/kepserverex/

 

자동화 통신

KEPServerEX는 관리, 연결, 모니터링 및 다양한 자동화 장치와 소프트웨어 응용 프로그램을 제어하기위한 유연하고 확장 가능한

솔루션입니다. 통신은 같은 OPC, 타당성 통신 프로토콜, API의, 각종 자동화 시스템의 인터페이스와 같은 개방형 표준의 배열을

지원하는 강력한 플랫폼을 통해 관리됩니다.KEPServerEX이 개선 운영 및 조직의 모든 수준에 걸쳐 의사 결정을 할 수 있습니다.

 

옵션기능

  OPC Driver List - http://www.kepware.com/Products/products_OPCServers.asp

KEPServerEX의 일관된 단일 인터페이스는 정말 OPC의 약속을 극대화 할 수 있습니다. 당신은 새로운 통신 프로토콜을 

학습하거나 새로운 응용 프로그램을 이해하는 시간을 지출에 대한 걱정없이 모두 하나의 통신 서버 내에서 여러 OPC 드라이버 플러그인을 추가 할 수 있습니다. 드라이버의 목록은 PLC 및 장치 드라이버, 데이터베이스 및 애플리케이션 특정 드라이버가 포함되어 있습니다.

 

Advanced Tag - http://www.kepware.com/Products/advanced_tag_option.asp

KEPServerEX을위한 고급 태그 옵션은 높은 수준의 보관 및 분석을위한 적절한 정보에 새로운 데이터 및 집계 기존 데이터를 생성하는 편리하고 효율적인 비용, 간단한 방법을 제공합니다. 고급 태그를 통해 사용자는 작업의 지속 시간을 측정 이벤트를 적산, 데이터 수집을위한 트리거 조건을 설정, 센서 그룹을 통해 평균을 수행하고, 전반적인 시스템 상태를 생성하는 기계 조건을 결합 할 수 있습니다. 이러한 기능은 향후 분석을 위해 매우 중요합니다.

  

Alarms and Events (A&E) - http://www.kepware.com/Spec_Sheets/alarms_and_events.asp

 Kepware의 경보 및 KEPServerEX에 대한 이벤트 플러그인은 비용을 절감하고 성능을 향상시킬 수 있습니다. 

 OPC AE 클라이언트는 직접 KEPServerEX의 경보 및 이벤트 플러그인에서 프로세스 알람, 운전자 동작, 정보 메시지 및 

 추적 / 감사 메시지를 수신하고 모니터링 할 수 있습니다. 장비의 안전 한계, 이벤트 감지 및 비정상 상황; 정의 임계 값과 같은 충족 될 때 운영자의주의가 필요할 수 있습니다 프로세스의 영역을 모니터링합니다. 경보 및 이벤트 플러그인은 유지 보수 작업 주문을 생성하고 운영자의 효율성 개선, 결함이있는 장비를 식별하는 데 도움이 될 수 있습니다. 경보 및 이벤트 처리 연산자 또한, 플러그인은 감사에 대한 알람 및 이벤트 정보를 수집하고 기록하는 데 사용할 수있는 다른 기록 데이터와 상관 관계에 사용됩니다. 

OPC 경보 및 이벤트에 대한 플러그인 모듈 통신 서버 KEPServerEX 및 KEPServerEX의 무료 AE (경보 및 이벤트)

클라이언트 인터페이스와 함께 작품을 선도하는 업계. 알람을 만들기 KEPServerEX에서 기존 태그 검색 및 알람으로 사용할 항목을 선택하는 것만 큼 간단합니다. 항목이 선택되면, 상태 및 하위 상태 항목에 대해 설정해야합니다. 트리거는 다음 현재의 데이터 값과 임계 값을 비교 설정됩니다. 상태의 트리거가 충족 될 때 알람이 해당 경보 및 고유의 알람 입력, 출력 및 승인 메시지를 사용자에게 제공하는 이벤트 클라이언트 응용 프로그램으로 전송됩니다.

 

DataLogger - http://www.kepware.com/Products/OPC_Data_Logger.asp

데이터 로거는 ODBC 호환 데이터베이스에 OPC 서버에서 데이터를 기록하는 구성하기 쉬운 응용 프로그램입니다. 

KEPServerEX와 데이터 로거의 긴밀한 통합은 간단한 설치, 고효율 성능 및 OPC 찾아 공간에 태그를 쉽게 브라우징과 같은 실질적인 독특한 이점을 제공합니다

 

EFM Exporter - http://www.kepware.com/spec-sheets/efm-exporter.asp

 

 

SNMP Agent - http://www.kepware.com/Spec_Sheets/snmp-agent.asp

 

■ LinkMaster - OPC Bridging Software

 Link : https://www.kepware.com/en-us/products/linkmaster/

 LinkMaster 는 OPC 시스템을위한 범용 다리 역할을하며, OPC 서버 사이에 데이터를 연결하는 방법을 제공합니다. 또한,  LinkMaster는 기존의 DDE 시스템과 새로운 OPC를 사용하는 응용 프로그램 사이의 다리 역할을 할 수 있도록 

OPC 및 DDE 서버입니다.

   

산업용 강도 신뢰성 

LinkMaster 는 산업전반에 사용될수 있습니다. : 우주 항공, 자동차, 빌딩 자동화, 자재 운반, 의료, 발전, 차 금속, 펄프 및 제지,  정유, 목재, 유틸리티.

 

프로그래밍 기술 선택 

LinkMaster는 별도의 프로그래밍 지식이 필요없는 빠르고 강력한 Windows 응용 프로그램입니다, 간단하게 "드래그 앤 드롭"으로 링크  를 만들 수 있습니다. 내장 스케일링, 사용자 액세스 관리자, 오류 추적 및 최적화 기능을 쓰기 데이터 흐름과 애플리케이션 액세스의 전체 제어를 제공합니다.

 

링크 그룹과 제어 데이터 전송

연결 그룹은 지정된 속도로 OPC 서버간에 이동 될 OPC 항목의 컬렉션을 형성하는 데 사용됩니다. 여러 링크 그룹을 사용하여, LinkMaster는 빠른 데이터가 다른 하나의 OPC 서버에서 전송되는 방법을 제어 할 수 있습니다. 당신이 맞게 데이터가 응용 프로그램의 요구에 맞게 전송 할 수있는 다양한 업데이트 속도로 링크 그룹을 사용하여. 하나의 항목이 고속으로 전송해야 할 수도 있지만, 응용 프로그램의 다른 항목이 느린 업데이트 속도가 필요할 수 있습니다. 연결 그룹은 당신이 제어 할 수 있습니다. 이점은 네트워크 트래픽 증가 및 신뢰성을 향상 시킵니다.

 

■ RedundancyMaster - OPC 이중화 소프트웨어

    Link : https://www.kepware.com/en-us/products/redundancymaster/

    RedundancyMaster

여러 OPC 서버가 중복 쌍으로 구성 할 수 있도록하여 OPC 데이터의 안정성과 가용성을 향상시킵니다. 

각 중복 쌍 완벽 하 게 모든 OPC 클라이언트 응용 프로그램에 하나의 OPC 서버로 나타납니다. RedundancyMaster는 

모든 다운 시간이 초과하여 프로세스가는 유지하는 응용 프로그램의 재구성하지 않고 기존의 클라이언트 / 서버 응용 

프로그램에 추가 할 수 있습니다.

 

산업용 강도 신뢰성 (Industrial Strength Reliability)

OPC 데이터 액세스 (OPC DA) 기술은 기기 및 시스템에 일관된 데이터 액세스를 필요로하는 거의 모든 가능한 상황에서 신뢰할 수 입증되었습니다. 그러나, 시스템의 무결성을 위협 할 수있는 다른 요인이있다, 심지어되는 소프트웨어,

하드웨어 및 인간 요소입니다. OPC 이중화 기술을 사용하여 이러한 시스템은보다 안정적이고 효율적으로 만들 수 있습니다.

 

투자 수익 (ROI)을 증가 및 시스템을 감소 다운 타임 (Increase ROI & Reduce System Down-time)

추가 시스템의 신뢰성이 요구를 채우려면 Kepware는 RedundancyMaster을 개발했습니다. RedundancyMaster는 OPC 

클라이언트 시스템에 상주하며 클라이언트와 서버 사이 OPC 호출에 '후크'하여 시스템의 네트워크에서 기본 및 보조 OPC 서버에 연결을 용이하게합니다. 어떤 이유로 OPC 클라이언트는 기본 OPC 서버와의 통신 연결을 잃게하거나 사용자가 지정한 조건이 충족되는 경우 (항목을 예를 들어 업데이트를 수신하지 않는 경우, 특정 항목의 값을 충족하거나, 품목의 질 나쁜로 설정되어 있습니다) RedundancyMaster는 기본을 삭제하고 네트워크에 보조 OPC 서버를 촉진 - 시간을 시스템을 줄이고 돈을 절약.

 

사용의 용이성 (Ease of Use)

RedundancyMaster이 될 수있는 드롭 인 (drop-in) 당신의 OPC 클라이언트 또는 서버 응용 프로그램을 변경할 필요가 없습니다. 응용 프로그램입니다. 직관적 인 구성은 분을 소요하고 당신은, 두통 실행 중복 OPC 시스템을 가지고 할 수 있습니다. 단순히 검색하고 선택하여 기본 및 보조 OPC 서버 및 시스템이 실행. 우리는 이메일 통지, 객체와 연결 모니터링 및 진단 로깅 등의 기능이 내장되어 있습니다. 당신은 동일한 OPC 서버 공급 업체를 활용 중복되는 OPC 서버 쌍을 필요로하는 상황에서, 우리는 별칭 기능을 추가 한 * OPC 서버의 ProgID를 (프로그램 ID).

    *참고 : 별칭 사소한 OPC 클라이언트 수정을 요구할 수 있습니다

 

신뢰성 (Reliability)

데이터와 OPC 시스템은 OPC 서버에 대한 연결을 잃을 수있는 더 많은 방법의 품질과 신뢰성에 영향을 미칠 수있는 많은 변수가 있습니다. 가장 일반적인은 다음과 같습니다

  • OPC 서버를 실행하는 PC가 종료됩니다
  • 사용자 오류로 OPC 서버가 종료 될
  • OPC 서버로의 네트워크 연결이 손실되거나 신뢰할 수 없을 때
  • 네트워크 링크설정 변경시 failur를 일으키는 경우
  • OPC 서버 자체 알려진 어떤 이유나, 또는 그렇지 않은이유로 실패시
  • OPC 서버의 PC에서 로그인 된 계정이 변경될시

위 대부분의 경우에, OPC DA 서버는 OPC 서버 또는 해당 서버에 대한 연결을 기본 실제 오류로 인해 데이터를 제공하는 데 실패합니다. 이러한 유형의 실패는 우리가 "객체 지향"실패라고 부르는 수 있습니다. 귀하의 OPC 클라이언트 응용 프로그램과 대상 OPC 서버 간의 실제 링크가 고장 때 객체 기반 오류가 발생합니다.순간 산업용 응용 프로그램이 데이터를 잃을 수있는 방법을 고려, 우리는 마음에있는 요소의 수를 유지해야합니다. 앞의 예에서, 소프트웨어는 범인이었다. 그러나 응용 프로그램에서 실제 하드웨어 고장이 극적으로뿐만 아니라 안정성에 영향을 줄 수 있습니다. 이러한 물리적 요소 중 일부는 다음과 같습니다

  •   물리적 연결 실패 (케이블 Disconnect)
  •   하드웨어 오류 (라우터 실패)
  •   전기 간섭 (높은 전류 방전)
  •   전파 신호에 의한 지연 (무선 링크)
  •   환경 요인 (번개)
  •   임의의 사고

 

■ ClientAce - OPC .NET 툴킷

    Link : https://www.kepware.com/en-us/products/clientace/

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

 

 

'ForBeginner' 카테고리의 다른 글

4-0. 왜 interface가 필요한가?  (0) 2021.05.22
4-3.일반 이더넷과 산업용 이더넷의 차이점  (0) 2021.05.22
8-9.Database mail  (0) 2021.05.20
8-7. View  (0) 2021.05.20
8-6. Linked Server (Good, bad and OPENQUERY)  (0) 2021.05.20
  • DB에 Logging 되는 Data를 이용하여 Alarm을 생성하여 Email, Text알람전송. 

How to configure Database Mail in SQL Server

 

Database Mail, as you would expect from its name, is a solution for sending e-mail messages from the SQL Server Database Engine to users. Using Database Mail, database applications can send e-mail messages that can, for example, contain query results or simply alert a user about an event that occurred in the database.

The process of Database Mail configuration has three main steps. In order to complete this successfully, we need to:

  • create a Database Mail account,
  • create a Database Mail profile,
  • and configure those two to work together

Configuring Database Mail

To create a Database Mail profile, we can use either the Database Mail Configuration Wizard or T-SQL code. Using Configuration Wizard is easier, but bear in mind that Database Mail is turned off in SQL Server Express editions.

Usually, all we need to do is go in Object Explorer, connect to the SQL Server instance we want to configure Database Mail on and expand the server tree. Then expand the Management node and double-click Database Mail or right-click and choose Configure Database Mail to open the Database Mail Configuration Wizard:

Since Microsoft SQL Server 2016 Express edition is used in this article as an example, the Management node does not have Database Mail:

This doesn’t mean we cannot use it because it’s only not available as an interface, but it’s still available in the SQL Server Database Engine itself. We just need to enable it using T-SQL.

To enable Database Mail, run the following code:

1
2
3
4
5
6


sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

In this case, running the code triggered an error:

Msg 15123, Level 16, State 1, Procedure sp_configure, Line 62 [Batch Start Line 0]
The configuration option ‘Database Mail XPs’ does not exist, or it may be an advanced option.

This is going to happen from time to time because this is an advanced option. To fix this, we need to change the show advanced options default value from 0 to 1.

To do this run the following code:

1
2
3
4
5
6
7
8
9
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO


sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

This time, the query is executed successfully. Once these two options are changed from ‘0’ to ‘1’, Database Mail is turned on:

Now we can get back to setting up the e-mail profile and adding an e-mail account. To do this we will use some stored procedures in msdb database.

To create a new Database Mail profile named ‘Notifications’ we will use the sysmail_add_profile_sp stored procedure and the following code:

1
2
3
4
5
-- Create a Database Mail profile  
EXECUTE msdb.dbo.sysmail_add_profile_sp  
    @profile_name = 'Notifications',  
    @description = 'Profile used for sending outgoing notifications using Gmail.' ;  
GO

To grant permission for a database user or role to use this Database Mail profile, we will use the sysmail_add_principalprofile_sp stored procedure and the following code:

1
2
3
4
5
6
-- Grant access to the profile to the DBMailUsers role  
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp  
    @profile_name = 'Notifications',  
    @principal_name = 'public',  
    @is_default = 1 ;
GO

To create a new Database Mail account holding information about an SMTP account, we will use the sysmail_add_account_sp stored procedure and the following code:

1
2
3
4
5
6
7
8
9
10
11
12
-- Create a Database Mail account  
EXECUTE msdb.dbo.sysmail_add_account_sp  
    @account_name = 'Gmail',  
    @description = 'Mail account for sending outgoing notifications.',  
    @email_address = 'Use a valid e-mail address',  
    @display_name = 'Automated Mailer',  
    @mailserver_name = 'smtp.gmail.com',
    @port = 465,
    @enable_ssl = 1,
    @username = 'Use a valid e-mail address',
    @password = 'Use the password for the e-mail account above' ;  
GO

To add the Database Mail account to the Database Mail profile, we will use the sysmail_add_profileaccount_sp stored procedure and the following code:

1
2
3
4
5
6
-- Add the account to the profile  
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp  
    @profile_name = 'Notifications',  
    @account_name = 'Gmail',  
    @sequence_number =1 ;  
GO

Execute the code from all stored procedures, and you should get the message that the whole code is executed successfully:

If for some reason, execution of the code above returns an error, use the following code to roll back the changes:

1
2
3
4
EXECUTE msdb.dbo.sysmail_delete_profileaccount_sp @profile_name = 'Notifications'
EXECUTE msdb.dbo.sysmail_delete_principalprofile_sp @profile_name = 'Notifications'
EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = 'Gmail'
EXECUTE msdb.dbo.sysmail_delete_profile_sp @profile_name = 'Notifications'

If anything goes wrong, executing the stored procedures individually could help in troubleshooting the issue. Just make sure to execute the ‘sysmail_add_profileaccount_sp’ stored procedure after the Database Account, and a Database Profile are created.

Test Database Mail configuration

Okay, now we’ve set up an email account, so what’s next? Well, let’s send a test e-mail and see if it works.

As we mentioned before, we could send an e-mail to alert a user about an event that occurred in the database and this is exactly what we are going to do later on using a simple DML trigger. For now, let’s just send an e-mail to the specified recipient using the sp_send_dbmail stored procedure.

1
2
3
4
5
6
EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'Notifications',
     @recipients = 'Use a valid e-mail address',
     @body = 'The database mail configuration was completed successfully.',
     @subject = 'Automated Success Message';
GO

The Results grid will show the message that the e-mail is queued and ID number:

The code above should send an e-mail using the profile that was previously created to a recipient specified @recipients argument. The subject and body are specified @body and @subject arguments.

Pretty simple, right? Well, not exactly. In this case and in most situations in the real world the mail will not be sent successfully even though every step during the configuration was successful.

Troubleshooting Database Mail

In this case, the e-mail message was successfully queued, but the message was not delivered.

First things first, check if Database Mail is enabled by executing the following code:

1
2
3
4
5
6
sp_configure 'show advanced', 1;
GO
RECONFIGURE;
GO
sp_configure;
GO

In the Results grid, make sure that the ‘run_value’ column for Database Mail XPs is set to 1:

To send e-mails, the user must also be a member of the DatabaseMailUserRole server role. Members of the sysadmin fixed server role and msdb db_owner role are members automatically. This can be easily checked by going to Security > Logins, right-click the current user and select Properties. In the Login Properties dialog click the ‘Server Roles’ page and make sure that the ‘sysadmin’ server role is checked:

The Database Mail system logs e-mail activity in the ‘msdb’ database. To view the error messages returned by Database Mail, execute the following code:

1
2
3


SELECT * FROM msdb.dbo.sysmail_event_log;

The statement will return logs and in a case like ours when e-mails are not delivered look for the errors under the ‘event_type’ column:

These logs have all sorts of useful information that could help in troubleshooting, and we are in particular interested in the ‘description’ column as it holds detailed information about the error and what went wrong.

The very first error logged says:

2 error 2017-11-13 00:18:27.800 The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 5 (2017-11-13T00:18:27). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at). ) 12092 1 NULL 2017-11-13 00:18:27.800 sa

However, this information won’t be useful unless there is some documentation e.g. in the TechNet library. There is an article about Troubleshooting Database Mail that provides information for users to quickly isolate and correct common problems with Database Mail, but going through the documentation was not helpful in this case and it took a long time without success.

One other message that was logged of this type was:

28 error 2017-11-14 16:20:01.107 The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2017-11-14T16:20:01). Exception Message: Cannot send mails to mail server. (Failure sending mail.). ) 14452 8 NULL 2017-11-14 16:20:01.107 sa

The problem, in general, is not with the Database Mail itself and its functionality. The error description messages are not predefined in the SQL Server Engine. This explains the missing Microsoft documentation. Those messages are usually authentication responses from SMTP servers that are required before allowing access to mail services.

To troubleshoot this further, we need to approach the problem from another perspective.

So far in troubleshooting, we have verified the following general steps:

  • Database Mail is enabled
  • The user is properly configured to send Database Mail
  • Sending a test e-mail doesn’t work
  • No TechNet library documentation could be found for the error messages logged

Another approach could be to setup an e-mail account used for sending outgoing notifications on another e-mail client like Microsoft Outlook. This should be fairly simple as both Gmail and MS Outlook are well-known services that should work together and there’s online documentation available on official websites.

To use the Gmail account with MS Outlook, we have to configure it to work with POP3 or IMAP.

Log onto your Gmail account at www.gmail.com and click the Settings in the top right corner:

Choose the Forwarding and POP/IMAP tab at the top of the page:

In the IMAP Access section, make sure that Enable IMAP option is selected and click the Configuration instructions link at the bottom:

This will open an instruction webpage on how to set up IMAP. Skip the 1st step as we already checked and verified that IMAP is turned on.

Fire up Outlook client to add the Gmail email account to it. Once Outlook is opened, click the File tab, and select Add Account:

In the Add Account dialog, select the Manual setup or additional server types option and click the Next button:

In the next step, choose the POP or IMAP option and click the Next button:

Use the information from the table below to set up Outlook client with the correct settings:

Incoming Mail (IMAP) Server imap.gmail.com
Requires SSL: Yes
Port: 993
Outgoing Mail (SMTP) Server smtp.gmail.com
Requires SSL: Yes
Requires TLS: Yes (if available)
Requires Authentication: Yes
Port for SSL: 465
Port for TLS/STARTTLS: 587

Under User Information section, make sure to enter a valid e-mail address. The e-mail address entered here will be automatically set as User Name for the Logon Information once the Account Type is selected from the drop-down box. Once finished, click the More Settings button on the right to configure additional settings before continuing further:

This will open the Internet e-mail settings dialog. Leave everything as it is under the General tab. Next, click the Outgoing Server tab, check the My outgoing server (SMTP) requires authentication check-box and select the Use same settings as my incoming mail server option:

Move on to the Advanced tab. Once again, use the information from the table above to set server port numbers. Set the incoming server (IMAP) to 993, and the outgoing server (SMTP) to 465. From the drop-down boxes select the SSL/TLS type of encrypted connection for both IMAP and SMTP servers. Leave the rest as it is and click the OK button to confirm settings:

Now it’s the time to test e-mail account settings to ensure that the entries are correct. Click the Next button and this will pop-up two additional dialogs. In the first dialog, Outlook will perform two tasks:

  1. Log onto incoming mail server (IMAP)
  2. Send test e-mail message

This step is crucial as this task previously failed for Database Mail. In the second dialog, Outlook will ask for the username and password. This was already configured, optionally check the Save this password in your password lint option if your Windows user account is password-protected, and no other person has access to it:

Note: The credential dialog can pop-up more than one time. Just click the OK button each time, until the server stops asking for login information. This usually happens when something is not configured right e.g. username or password, port numbers, etc.

In this case, the first task failed and sending test e-mail message failed as well right afterward:

Some applications and devices use less secure sign-in technology, which makes their respective accounts more vulnerable and Gmail will block these sign-in requests. By default, access for these applications is turned off, but we can also turn access on to use them despite the risks. In this case, we also have to.

This can be solved by logging into Gmail account and making sure that Less secure apps option is enabled for the desired account. Go to the Less secure apps section of the Gmail account and enable access for less secure applications.

Note: This setting is not available for accounts with 2-Step Verification enabled. Such accounts require an application-specific password for less secure apps access.

Since this account has 2-Step Verification enabled, we have to turn it off, so we can continue further.

Go to ’Sign in & security’ section of My Account, select 2-Step Verification, sign in using your credentials, and enter verification code if asked received via text message with a 6-digit verification code or phone call, and click the Turn off button:

A pop-up dialog will appear informing the user about security and vulnerability. We are aware of this, so just click the Turn off button to continue:

Now we can go back to the Less secure apps section and allow access for less secure applications:

Back to Outlook, click the Next button once again to test e-mail account settings and finally a message without errors. Both tasks completed successfully:

The test e-mail message is also delivered successfully which means that sending another test e-mail from Database Mail should work this time:

There is only one way to find out. Go back to SSMS and execute the code for sending the test e-mail:

1
2
3
4
5
6
EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'Notifications',
     @recipients = 'Use a valid e-mail address',
     @body = 'The database mail configuration was completed successfully.',
     @subject = 'Automated Success Message';
GO

Unfortunately, even after all this trouble, the test e-mail is not getting through. A quick look at the log files shows another error message of another type:

51 error 2017-11-18 16:21:22.803 The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 10 (2017-11-18T16:21:22). Exception Message: Cannot send mails to the mail server. (Failure sending mail.). ) 3564 14 NULL 2017-11-18 16:21:22.803 sa

At this point, let’s do a quick look up, just to make sure that the e-mail profile is configured the same as it is for Outlook. Execute the code from below:

1
2
3
4
5
6
7
SELECT [sysmail_server].[account_id],
       [sysmail_account].[name] AS [Account Name],
       [servertype],
       [servername] AS [SMTP Server Address],
       [Port]
FROM [msdb].[dbo].[sysmail_server]
     INNER JOIN [msdb].[dbo].[sysmail_account] ON [sysmail_server].[account_id] = [sysmail_account].[account_id];

This will return settings for account name, server type, server address, and port number:

Everything looks good, but the e-mail is still not getting out. A quick online lookup of the error message leads to a Stack Overflow thread in which the user has the exact same error message. In the comment section, another user says that changing the port number to 587 instead of 465, even though information from Gmail says otherwise, fixed the issue for him. As we are running out of options here, let’s try that and see what happens.

We will use the sysmail_update_account_sp stored procedure to change the port number in the existing Database Mail account.

Execute the following code:

1
2
3
4
EXECUTE msdb.dbo.sysmail_update_account_sp
        @account_name = 'Gmail',
        @port = 587;  
GO

Execute the code from the previous step to verify that the change is applied. The port number will change leaving all other account information intact:

For some reason configuration instructions for SSL provided by Google does not work on port 465 for Database Mail system, but port 587 that is specified for TLS/STARTTLS worked like a charm.

Finally, after giving it another try there is a new e-mail in the inbox sent from the Database Mail system:

Send e-mail from a trigger

To demonstrate how to send an e-mail notification to a user when a specific event occurred in the database, we can create a simple trigger.

Use the code below to create a trigger named iProductNotification on the Product table which is contained in the Production schema:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
USE AdventureWorks2014
GO


IF OBJECT_ID ('Production.iProductNotification', 'TR') IS NOT NULL
DROP TRIGGER Purchasing.iProductNotification
GO


CREATE TRIGGER iProductNotification ON Production.Product
    FOR INSERT
AS
    DECLARE @ProductInformation nvarchar(255);
    SELECT
   @ProductInformation = 'A new product, ' + Name + ', is now available for $' + CAST(StandardCost AS nvarchar(20)) + '!'
   FROM
  INSERTED i;
    EXEC msdb.dbo.sp_send_dbmail
   @profile_name = 'Notifications',
   @recipients = 'Use a valid e-mail address',
   @body = @ProductInformation,
   @subject = 'New product notification'
GO

This trigger will fire when an Insert statement is run against the Product table. The idea behind it is to collect basic information about a new product that is available like name and price and to wrap that information up in a simple e-mail message that will be sent to desired addresses using the Database Mail profile previously configured:

Once the trigger is created, refresh the ‘Triggers’ node under the ‘Product’ table just to make sure that the trigger is created on the right table:

Rather than typing the code for the Insert statement and because it’s easier, use the ‘Edit Top 200 Rows’ option from the right-click context menu on the table with the trigger. Fill in some information like working with Excel sheets. Once done, hit the Enter key to continue:

This will issue an Insert statement in the background and fire the trigger. As a result, the trigger will collect some information about the Insert statement, invoke the Database Mail profile, and use it send e-mail to the desired recipient:

Sending query results e-mail message

Another example could be sending an e-mail message that contains query results. Execute the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'Notifications',
     @recipients = 'Use a valid e-mail address,
     @query =  'USE AdventureWorks2014;
GO
SELECT Name, ProductNumber, ListPrice AS Price
FROM Production.Product
WHERE ProductLine = ''R''
AND DaysToManufacture < 4
ORDER BY Name ASC;
GO',
     @subject = 'Product list',
     @attach_query_result_as_file = 1;

This SELECT statement returns a list of products with a specific condition in mind:

But more importantly, it sends an e-mail with results of that Select statement as an attachment to the e-mail recipients:

And if we open the attachment, there it is, the result of our query:

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

4-3.일반 이더넷과 산업용 이더넷의 차이점  (0) 2021.05.22
4-5. Kepware의 장점.  (0) 2021.05.22
8-7. View  (0) 2021.05.20
8-6. Linked Server (Good, bad and OPENQUERY)  (0) 2021.05.20
2-5. Sensor와 PLC의 연결  (0) 2021.05.19
  • 자주 조회사는 Query를 View로 만들어 두면 사용하기 편리하다. 
  • 만들어진 View는 Table조회 하는것과 같이 사용할 수 있다. 
  • 보안, 간략함, 일관성을 유지 할 수 있다. 
  • Join과 Group을 이용하여 여러Table의 정보를 하나의 View로 만들수 있다. 

SQL Server Views

 

Summary: in this tutorial, you will learn about views and how to manage views such as creating a new view, removing a view, and updating data of the underlying tables through a view.

When you use the SELECT statement to query data from one or more tables, you get a result set.

For example, the following statement returns the product name, brand, and list price of all products from the products and brands tables:

 

SELECT product_name, brand_name, list_price FROM production.products p INNER JOIN production.brands b ON b.brand_id = p.brand_id;

Code language: SQL (Structured Query Language) (sql)

Next time, if you want to get the same result set, you can save this query into a text file, open it, and execute it again.

SQL Server provides a better way to save this query in the database catalog through a view.

A view is a named query stored in the database catalog that allows you to refer to it later.

So the query above can be stored as a view using the CREATE VIEW statement as follows:

 

CREATE VIEW sales.product_info AS SELECT product_name, brand_name, list_price FROM production.products p INNER JOIN production.brands b ON b.brand_id = p.brand_id;

Code language: SQL (Structured Query Language) (sql)

Later, you can reference to the view in the SELECT statement like a table as follows:

 

SELECT * FROM sales.product_info;

Code language: SQL (Structured Query Language) (sql)

When receiving this query, SQL Server executes the following query:

 

SELECT * FROM ( SELECT product_name, brand_name, list_price FROM production.products p INNER JOIN production.brands b ON b.brand_id = p.brand_id; );

Code language: SQL (Structured Query Language) (sql)

By definition, views do not store data except for indexed views.

A view may consist of columns from multiple tables using joins or just a subset of columns of a single table. This makes views useful for abstracting or hiding complex queries.

The following picture illustrates a view that includes columns from multiple tables:

Advantages of views

Generally speaking, views provide the following advantages:

Security

You can restrict users to access directly to a table and allow them to access a subset of data via views.

For example, you can allow users to access customer name, phone, email via a view but restrict them to access the bank account and other sensitive information.

Simplicity

A relational database may have many tables with complex relationships e.g., one-to-one and one-to-many that make it difficult to navigate.

However, you can simplify the complex queries with joins and conditions using a set of views.

Consistency

Sometimes, you need to write a complex formula or logic in every query.

To make it consistent, you can hide the complex queries logic and calculations in views.

Once views are defined, you can reference the logic from the views rather than rewriting it in separate queries.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

4-5. Kepware의 장점.  (0) 2021.05.22
8-9.Database mail  (0) 2021.05.20
8-6. Linked Server (Good, bad and OPENQUERY)  (0) 2021.05.20
2-5. Sensor와 PLC의 연결  (0) 2021.05.19
2-0. 왜 Sensor의 이해가 필요한가?  (0) 2021.05.19
  • 아래 보기와 같이 Remote서버에 연결하여 Proto Type의 결과물을 빨리 만들고자 할때 Linked server가 유용하다. 
  • 하지만, 속도에 문제가 있다. 
  • 그래서, 실제 Remote서버의 Data를 사용할때에는 OPENQUERY를 추천한다. 

Linked Server in SQL Server: the good, the bad, and the way to make it perfect!

 

 

Introduction (the good)

If you are not familiar with a linked server concept in SQL Server, don’t worry, you probably haven’t needed it yet. You are fortunate to source all your data needs from a single database server, and that is fine. Or maybe you are consuming your SQL Server needs from Azure Single Database or AWS RDS (both public cloud solutions don’t support linked server out of the box).

Most likely this is going to change (Azure VM and AWS EC2 have full support) and you will have to join data between multiple database servers, or even between different RDBMS systems. For example: All the transactional sales data is stored in SQL Server, but all the analytical sales data is stored on another SQL Server server (this could even be MySQL).

This is where Linked Server comes in handy, especially at the data discovery phase. When building a prototype needs to happen quickly and there is no time to adhere to the best practices, Linked Server can be the answer.

 

Linked Servers Basics

According to Microsoft, linked servers enable the SQL Server Database Engine and Azure SQL Database Managed Instance to read data from the remote data sources and execute commands against the remote database servers (for example, OLE DB data sources) outside of the instance of SQL Server. 

Linked Server is a pure convenience feature. With very little to no code changes, you can suddenly join multiple tables between local and remote/cloud servers. For example, let’s use WideWorldImporters transactional database

Figure 1

Linked Server effectively removes the need for a solution that will move and synchronize the data. You just setup a Linked Server (see Fig #2) and add a Linked Server reference in front of the three-part naming convention (see Fig #3). That’s all. A small price to pay for lots of convenience.

Figure 2

 

Figure 3

Problem (the bad)

While the Linked Server feature makes it easy to join tables between two or more different servers, it’s not free and it comes with a price tag: performance overhead. While joining a few small tables might not add noticeable pressure to the server, joining 3-5 fairly large remote tables might introduce locking and blocking and increase the run-time from seconds to minutes.

The main problem occurs when you run queries against a remote server, which is not healthy. When SQL Server runs a query with Linked Server, it will use the least optimal execution plan due to lack of knowledge of those remote tables. Meaning, your local SQL Server is clueless on remote table indexes and statistics, so it might use an incorrect joining mechanism and might be grossly inefficient.

For example, if you had to join all January 2013 orders between OLTP and OLAP tables and compare revenue per product while showing the five top contributors, we might build the following query (see Fig #4) to achieve that goal:

Figure 4

Reviewing Statistics IO (see Fig #5) and execution plan details (see Fig #6), we see:

Figure 5

 

Figure 6

As you might notice (far right), 93% of the query execution cost goes to a “mysterious” remote query.

Solution (a way to make it perfect)

One of the easiest ways to fix performance problems with a linked server is to run it via OPENQUERY.

What is OPENQUERY? According to Microsoft, OPENQUERY executes the specified pass-through query on the specified linked server. This server is an OLE DB data source. We can reference OPENQUERY in the FROM clause of a query as if it were a table name. We can also reference OPENQUERY as the target table of an INSERT, UPDATE, or DELETE statement. This is subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one. 

One of the main advantages of OPENQUERY is remote execution. This  means the local server sends the query to the remote server with knowledge of those remote tables that are now local to the query. By the way, remote execution also enables the use of native syntax of the remote server, so you can take advantage of other RDBMS system performance tricks.

Here is how our original query will look with an OPENQUERY (see Fig #7). It’s still using the same linked server, but it happens indirectly now with an  OPENQUERY.

Figure 7

When reviewing Statistics IO (see Fig #8) and execution plan details (see Fig #9), we now see: 

Figure 8

 

Figure 9

Let’s compare Statistics IO and execution plans to see the differences between direct query linked server usage vs. an OPENQUERY linked server.

The most noticeable differences are:

  1. WorkFile reads in Statistics IO (see Fig #10)
  2. Remote Query 93% cost vs. most distributed cost in Execution Plan (see Fig #11) and partially replaced with Remote Scans.

Figure 10

 

Why Does It Work?

The main reason OPENQUERY will usually perform better is knowledge of the table in terms of indexes and stats, knowledge that a direct linked server doesn’t have.

As you can see, we have managed to cut the run-time from 22 seconds (using direct link server) down to 2 seconds (using OPENQUERY). Additionally, we can add indexes specific to the query to make OPENQUERY even faster.

Disclaimer

Since nothing is certain in this life other than taxes and death, your mileage may vary (“YMMV”). Please test it (preferably using DBCC FREEPROCCACHE) prior to deployment. In addition the query above that reduced run-time by 11 times, I also scored a drastic performance gain by using OPENQUERY in one of the clients. In that example, replacing all three direct linked server references reduced run-time by 10 times, to just a few seconds.

 

산업 모니터링에 관한 다른 Contents도 확인 하세요. 

'ForBeginner' 카테고리의 다른 글

8-9.Database mail  (0) 2021.05.20
8-7. View  (0) 2021.05.20
2-5. Sensor와 PLC의 연결  (0) 2021.05.19
2-0. 왜 Sensor의 이해가 필요한가?  (0) 2021.05.19
2-4. 센서와 변환기  (0) 2021.05.19

+ Recent posts