MQTT--Mosquitto的配置文件

Mosquitto的配置文件存放在/etc/mosquitto/mosquitto.confpython

配置文件具體的配置內容爲:web

# =================================================================
# General configuration
# =================================================================

# 客戶端心跳的間隔時間,當QoS爲1或2的消息已經被髮送後,mosquitto在一段時間內仍未接收到客戶端的反饋消息,將從新發送消息。 默認爲20秒
#retry_interval 20

# 系統狀態的刷新時間,每隔一段時間將更新$SYS層級話題的狀態,其中包含着broker的狀態信息。 默認爲10秒,
#設置爲0以禁用$ SYS樹的發佈。
#sys_interval 10 # 系統資源的回收時間,0表示儘快處理,表示間隔多長時間將再也不被使用的消息銷燬掉。該值越小,使用的內存就會越小但會須要更多的處理時間。 若是設置爲0,表示不被
#使用的消息將會及時銷燬。 默認爲10秒 #store_clean_interval 10 # 服務進程的PID, 默認爲/var/run/mosquitto.pid #pid_file /var/run/mosquitto.pid # 服務進程的系統用戶,設置mosquitto啓動用戶 #user mosquitto
#queue_qos0_messages 是否將QoS爲0的消息計算到max_queued_messages參數中

# 客戶端心跳消息的最大併發數,表示容許多大數量的QoS爲1或2消息被同時進行傳輸處理。這些消息包括正在進行握手的消息和進行從新發送的消息。默認爲20個,
#若是設置爲0,表示不設限制;若是爲1,則會確保消息被順序處理。 #max_inflight_messages 10 # 客戶端心跳消息緩存隊列,表示容許多大數量的QoS爲1或2消息在隊列中進行排隊。 默認爲100個 #max_queued_messages 100 # 用於設置客戶端長鏈接的過時時間,默認永不過時,持久訂閱的過時設置。 對於將clean session設置爲false的持久訂閱客戶端,若是在必定的時間段裏面沒有從新鏈接mosquitto將會被移除。
#這並非一個標準的配置項,由於對於MQTT協議來講全部的持久訂閱應該是永遠有效的。
#如: persistent_client_expiration 2m  persistent_client_expiration 14d persistent_client_expiration 1y 
#h:小時  d:天  m:月  y:年 #persistent_client_expiration # ================================================================= # Default listener # ================================================================= # 服務綁定的IP地址 #bind_address # 服務綁定的端口號 #port 1883 # 容許的最大鏈接數,-1表示沒有限制 #max_connections -1
#若是一個客戶端訂閱了多個topic時,設置是否容許接收重複的消息。好比訂閱了foo/# 和 foo/+/baz。
#allow_duplicate_messages



# cafile:CA證書文件 # capath:CA證書目錄 # certfile:PEM證書文件 # keyfile:PEM密鑰文件 #cafile #capath #certfile #keyfile # 必須提供證書以保證數據安全性 #require_certificate false # 若require_certificate值爲true,use_identity_as_username也必須爲true #use_identity_as_username false # 啓用PSK(Pre-shared-key)支持 #psk_hint # SSL/TSL加密算法,可使用「openssl ciphers」命令獲取 # as the output of that command. #ciphers # ================================================================= # Persistence # ================================================================= # 消息自動保存的間隔時間,表示當開啓持久化設置時,間隔多少時間mosquitto會把內存中的消息保存到磁盤中。默認爲30分鐘,當設置爲0時,只有mosquitto
#關閉的時候纔會寫的磁盤中。 #autosave_interval 1800 # 消息自動保存功能的開關,
#If true, mosquitto will count the number of subscription changes, retained messages received and queued messages and if the total exceeds autosave_interval then the in-memory database
# will be saved to disk. If false, mosquitto will save the in-memory database to disk by treating autosave_interval as a time in seconds
#autosave_on_changes false # 持久化功能的開關,設置爲true時,全部的鏈接,訂閱和消息數據都會被保存到磁盤的mosquitto.db文件中。當mosquitto重啓的時候,它會從mosquitto.db文件中
#從新加載數據。 persistence true # 持久化DB文件 #persistence_file mosquitto.db # 持久化DB文件目錄,默認爲/var/lib/mosquitto/ #persistence_location /var/lib/mosquitto/ # ================================================================= # Logging # ================================================================= # 4種日誌模式:stdout、stderr、syslog、topic # none 則表示不記日誌,此配置能夠提高些許性能,設置日誌的輸出目的地  若是輸出到某個文件的話能夠這樣設置log_dest file /var/log/mosquitto.log  要賦予對mosquitto.log文件的讀寫權限 log_dest none # 選擇日誌的級別(可設置多項),日誌類型:debug, error, warning, notice, information, subscribe, unsubscribe, websockets, none, all #log_type error #log_type warning #log_type notice #log_type information # 是否記錄客戶端鏈接信息 #connection_messages true # 是否記錄日誌時間, 是否記錄日誌時間 #log_timestamp true # ================================================================= # Security # ================================================================= # 客戶端ID的前綴限制,可用於保證安全性,置只有clientId以某個前綴開始的客戶端才容許鏈接到mosquitto broker. #clientid_prefixes # 容許匿名用戶 #allow_anonymous true # 用戶/密碼文件,默認格式:username:password #password_file # PSK格式密碼文件,默認格式:identity:key #psk_file # pattern write sensor/%u/data # ACL權限配置,經常使用語法以下: # 用戶限制:user <username> # 話題限制:topic [read|write] <topic> # 正則限制:pattern write sensor/%u/data #acl_file # ================================================================= # Bridges # ================================================================= # 容許服務之間使用「橋接」模式(可用於分佈式部署) #connection <name> #address <host>[:<port>] #topic <topic> [[[out | in | both] qos-level] local-prefix remote-prefix] # 設置橋接的客戶端ID #clientid # 橋接斷開時,是否清除遠程服務器中的消息 #cleansession false # 是否發佈橋接的狀態信息 #notifications true # 設置橋接模式下,消息將會發布到的話題地址 # $SYS/broker/connection/<clientid>/state #notification_topic # 設置橋接的keepalive數值 #keepalive_interval 60 # 橋接模式,目前有三種:automatic、lazy、once #start_type automatic # 橋接模式automatic的超時時間 #restart_timeout 30 # 橋接模式lazy的超時時間 #idle_timeout 60 # 橋接客戶端的用戶名 #username # 橋接客戶端的密碼 #password # bridge_cafile:橋接客戶端的CA證書文件 # bridge_capath:橋接客戶端的CA證書目錄 # bridge_certfile:橋接客戶端的PEM證書文件 # bridge_keyfile:橋接客戶端的PEM密鑰文件 #bridge_cafile #bridge_capath #bridge_certfile #bridge_keyfile # 本身的配置能夠放到如下目錄中 include_dir /etc/mosquitto/conf.d
相關文章
相關標籤/搜索