2016-10-23 6 views
0

나는 mosquitto를 설치하고Mosquitto 증가 최대 연결

/etc/security/limits.conf 
/etc/sysctl.cnof 
/etc/pam.d/common-session 
/etc/pam.d/common-session-noninteractive 

세부 사항 설정을 많이 변경 한 변경 :

$ sudo vim /etc/sysctl.conf 

fs.file-max=2097152 
fs.nr_open=2097152 
net.core.somaxconn=32768 
net.ipv4.tcp_max_syn_backlog=16384 
net.core.netdev_max_backlog=16384 
net.ipv4.ip_local_port_range='1025 65535' 
net.core.rmem_default=262144 
net.core.wmem_default=262144 
net.core.rmem_max=16777216 
net.core.wmem_max=16777216 
net.core.optmem_max=16777216 
net.ipv4.tcp_rmem='1024 4096 16777216' 
net.ipv4.tcp_wmem='1024 4096 16777216' 
net.ipv4.tcp_max_tw_buckets=1048576 
net.ipv4.tcp_fin_timeout=15 

$ sudo vim /etc/security/limits.conf 

*  hard nofile 1048576 
*  soft nofile 1048576 
*  hard nproc 1048576 
*  soft nproc 1048676 

$ sudo vim /etc/pam.d/common-session 
$ sudo vim /etc/pam.d/common-session-noninteractive 

session required pam_limits.so 

그러나 일이 후

는 mosquitto 1024 연결을 계속 지원할 수 있습니다.

그래서 나는 mosquitto의 한계를 확인 cat /etc/{pid}/limits를 사용

다음

내가 그 mosquitto의 제한은 여전히 ​​나는 mosquitto 사용자를 NOLOGIN입니다 파악 기본

Max processes    7968     7968  processes 
Max open files   1024     4096  files 

이며, PAM 제한 설정을 실행할 수 없습니다 발견 . 그리고 만약 내가 prlimit 명령을 사용하여 소프트 오픈 파일 한계를 증가 시키면, 모스키토는 실제로 최대 연결을 늘릴 수 있지만 하드 제한 (4096)에 의해 제한됩니다.

때문에 가능한 솔루션 내가 /etc/init/mosquitto.conf 변경 않는 /etc/init/mosquitto.conf

사용하는 것입니다하지만 사람이 어떤 생각을 가지고 있나요

$ sudo vim /etc/init/mosquitto.conf  
limit nofile 1048576 1048576 
limit nproc 1048576 1048576 
ulimit -n 1048576 # I do both command, but neither do they works 
ulimit -u 1048576 

를 작동하지 않는 것 같다,이 (Reference)를 할 수 없어 여전히 데비안을 보인다 모스 굿이 많은 양의 연결을 지원하도록 만드시겠습니까?

감사합니다.

PS입니다. 테스트 도구 : 공부를 많이 한 후, 나는 마침내 해결책을 가지고

답변

0

emqtt benchmark가 : mosquitto의 init 스크립트를 변경하고 설정을 변경 한 후

$ sudo vim /etc/mosquitto/mosquitto.conf 

# change user to root 
user root 



$ sudo vim /etc/init.d/mosquitto 

#! /bin/bash 
# Change /bin/sh to /bin/bash for fixing "ulimit -u illegal option" error 

set_ulimit() { 
    ulimit -f unlimited 
    ulimit -t unlimited 
    ulimit -v unlimited 
    ulimit -n 1048576 
    ulimit -m unlimited 
    ulimit -u 1048576 
} 

start) 
    ... 
    # Update ulimit config in start command 
    set_ulimit 
    ... 
    ;; 
    stop) 

을 뿌리 mosquitto 사용자를 변경, systemctl 설정을 다시로드 mosquitto를 다시 시작

sudo systemctl daemon-reload 
sudo service mosquitto stop 
sudo service mosquitto start 

한계가 변경되었습니다.

+1

모스키토를 루트로 실행할 이유가 없으므로 사용하지 않는 것이 좋습니다. – ralight

+0

안녕하세요, 귀하의 조언을 주셔서 감사합니다. 이 작업을 수행 할 다른 방법이 있습니까? – Asoul

+0

루트로 실행하면 한계에 차이가 없으므로 프로세스에 적용되는 내용입니다. root로 mosquitto를 시작할 수 있지만, 모든 설정 변경은 모스키토를 시작한 후에 root로 계속 실행되도록합니다. – ralight