[Ubuntu] Ubuntu 22.04 Ring Buffer 설정 방법
Ubuntu 22.04에서 ethtool로 NIC Ring Buffer를 임시 변경하고, systemd.link 파일로 재부팅 후에도 유지되도록 영구 설정하는 방법입니다.
요약
- Ubuntu 22.04에서는
ethtool -G로 Ring Buffer를 즉시 바꾸고,systemd.link파일로 재부팅 후에도 유지되게 설정할 수 있습니다. networkctl status로 확인한 Network File과 같은 이름의.link파일을/etc/systemd/network에 만들고RxBufferSize,TxBufferSize를 지정합니다.systemd.link설정은 OS 기동 중에는 적용되지 않고 재부팅해야 반영됩니다.
테스트 환경 Ubuntu 22.04
Temporary settings
아래와 같이 ethtool 명령을 통해 online 중에 변경이 가능하다.
주의) 변경되는 Interface 의 Link UP/DOWN 이 발생한다.
$ sudo ethtool -G eth0 rx 4096 tx 4096
$ sudo ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: n/a
RX Jumbo: n/a
TX: 4096
Current hardware settings:
RX: 4096
RX Mini: n/a
RX Jumbo: n/a
TX: 4096
Permanently settings
주로 CentOS 와 같은 RHEL 계열은 network-script 에 ETHTOOL_OPTS 을 사용하거나 NetworkManager 를 통해 설정하는데
(참고 문서 : How to make NIC ethtool settings persistent (apply automatically at boot))
Ubuntu 22.04 의 경우,
networkd-dispatcher를 이용한 설정 방법rc.local혹은udevrule 을 이용한 설정 방법systemd.link를 이용하는 방법
위와 같이 다양한 방법들이 있으나, Ubuntu 에서 권고되는 방식인 systemd.link 를 이용하는 방법에 대해 작성해본다.
systemd.link 설정
먼저 systemd.link 를 사용하기 위해서는 networkctl 명령을 통해 Network file 이 생성된 것을 확인 해야된다.
$ sudo networkctl status eth0
● 2: eth0
Link File: /usr/lib/systemd/network/99-default.link <<
Network File: /run/systemd/network/10-netplan-eth0.network <<
Type: ether
State: enslaved (configured)
Online state: online
...생략
해당 시스템은 netplan 에 의해 Network 가 설정되고 해당 Network File 이 build 되어 설정된 것을 확인 할 수 있다.
위 network file 과 동일한 이름으로 link file 을 생성합니다.
$ sudo cat /etc/systemd/network/10-netplan-eth0.link
[Match]
MACAddress=xx:xx:xx:xx:xx:xx
[Link]
RxBufferSize=4096
TxBufferSize=4096
위와 같이 적용할 Interface 의 MAC Address 와 RxBufferSize , TxBufferSize 값을 입력한 link file 이다.
(주의) 해당 systemd.link 로 적용한 내용은 OS 기동중에는 적용이 불가능하며 재부팅을 하면 반영된다.
There is no consistent way to manage NIC ring buffer sizes "on boot" at this time.
(참고) https://github.com/systemd/systemd/issues/13601
Check
시스템 재부팅 이후, 아래와 같이 정상적으로 반영되고 Ring Buffer 가 설정 된 것을 확인 할 수 있다.
$ sudo networkctl status eth0
● 2: eth0
Link File: /etc/systemd/network/10-netplan-eth0.link <<
Network File: /run/systemd/network/10-netplan-eth0.network
Type: ether
State: enslaved (configured)
Online state: online
...생략
$ sudo ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: n/a
RX Jumbo: n/a
TX: 4096
Current hardware settings:
RX: 4096
RX Mini: n/a
RX Jumbo: n/a
TX: 4096
여러 Interface 에 적용하기 위해서는 /etc/systemd/network 경로에 각각 link file 을 생성하고 시스템을 재부팅하면 적용된다.
참고 문서
- https://github.com/systemd/systemd/issues/13601
- https://manpages.ubuntu.com/manpages/jammy/man5/systemd.link.5.html
자주 묻는 질문
ethtool로 Ring Buffer를 변경하면 서비스에 영향이 있나요?
ethtool -G eth0 rx 4096 tx 4096처럼 온라인 중에 변경할 수 있지만, 변경되는 인터페이스의 Link UP/DOWN이 발생합니다.
Ubuntu 22.04에서 Ring Buffer 설정을 영구 적용하려면 어떻게 하나요?
Ubuntu에서 권고되는 systemd.link 방식을 사용합니다. /etc/systemd/network/10-netplan-eth0.link처럼 Network File과 같은 이름으로 파일을 만들고 [Match]에 MAC Address, [Link]에 RxBufferSize와 TxBufferSize를 입력한 뒤 재부팅합니다.
systemd.link 파일이 적용되었는지 어떻게 확인하나요?
재부팅 후 networkctl status eth0의 Link File이 새로 만든 .link 파일로 바뀌었는지 확인하고, ethtool -g eth0으로 현재 RX/TX 값을 확인합니다.