set mqtt configuration file

[wangshumin@CentOSNode1 mosquitto]$ ll
总用量 84
-rw-r--r--. 1 root root   230 4月  24 16:10 aclfile.example
-rw-r--r--. 1 root root 36806 4月  24 16:13 mosquitto.conf
-rw-r--r--. 1 root root 36806 4月  24 16:10 mosquitto.conf.example
-rw-r--r--. 1 root root    23 4月  24 16:10 pskfile.example
-rw-r--r--. 1 root root   355 4月  24 16:10 pwfile.example
[wangshumin@CentOSNode1 mosquitto]$ sudo vim /etc/mosquitto/mosquitto.conf
▽  "/etc/mosquitto/mosquitto.conf" 821L, 36806C# Config file for mosquitto
#
# See mosquitto.conf(5) for more information.
#
# Default values are shown, uncomment to change.
#
# Use the # character to indicate a comment, but only if it is the 
# very first character on the line.


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


# Time in seconds to wait before resending an outgoing QoS=1 or 
# QoS=2 message.
#retry_interval 20


# Time in seconds between updates of the $SYS tree.
# Set to 0 to disable the publishing of the $SYS tree.
#sys_interval 10


# Time in seconds between cleaning the internal message store of 
# unreferenced messages. Lower values will result in lower memory 
# usage but more processor time, higher values will have the 
# opposite effect.
# Setting a value of 0 means the unreferenced messages will be 
# disposed of as quickly as possible.
#store_clean_interval 10


# Write process id to a file. Default is a blank string which means 
# a pid file shouldn't be written.
# This should be set to /var/run/mosquitto.pid if mosquitto is
# being run automatically on boot with an init script and 
# start-stop-daemon or similar.1,1顶端
"/etc/mosquitto/mosquitto.conf" 821L, 36806C       /Default Listeners
已查找到文件结尾,再从开头继续查找
E486: Pattern not found: Default Listeners1,1 top/nDefaultListenerListenerListenerListenerListenerListenerListener found to end of file, continue from beginning
E486: Pattern not found: Listeners 1,1 top 23456789,0-110,1 /10,1 top 9 ,0-110,1 123,0-14,1 567,0-18,1 9201,0-12,1 3456789,0-130,1 1234
#pid_file35,10%
36,0-10%
# When run as root, drop privileges to this user and its primary 37,10%
# group.38,10%
# Leave blank to stay as root, but this is not recommended.39,10%
# If run as a non-root user, this setting has no effect.40,10%
# Note that on Windows this has no effect and so mosquitto should 41,10%
# be started by the user you wish it to run as.42,11%
#user mosquitto43,11%
44 ,0-11%
# The maximum number of QoS 1 and 2 messages currently inflight per 45,11%
# client.46,11%
# This includes messages that are partway through handshakes and 47,11%
# those that are being retried. Defaults to 20. Set to 0 for no 48,11%
# maximum. Setting to 1 will guarantee in-order delivery of QoS 1 49,11%
# and 2 messages.50,12%
#max_inflight_messages 2051,12%
52,0-12%
# The maximum number of QoS 1 and 2 messages to hold in a queue 53,12%
# above those that are currently in-flight.  Defaults to 100. Set 54,12%
# to 0 for no maximum (not recommended).55,12%
# See also queue_qos0_messages.56,12%
#max_queued_messages 10057,12%
58,0-13%
# Set to true to queue messages with QoS 0 when a persistent client is59,13%
# disconnected. These messages are included in the limit imposed by60,13%
# max_queued_messages.61,13%
# Defaults to false.62,13%
# This is a non-standard option for the MQTT v3.1 spec but is allowed in63,13%
# v3.1.1.64,13%
#queue_qos0_messages false65,13%
66,0-14%
# This option sets the maximum publish payload size that the broker will allow.67,14%
# Received messages that exceed this size will not be accepted by the broker.68,14%
# The default value is 0, which means that all valid MQTT messages are69,14%
# accepted. MQTT imposes a maximum payload size of 268435455 bytes. 70,14%
#message_size_limit 071,14%
72,0-14%
# This option controls whether a client is allowed to connect with a zero73,14%
# length client id or not. This option only affects clients using MQTT v3.1.174,15%
# and later. If set to false, clients connecting with a zero length client id75,15%
# are disconnected. If set to true, clients will be allocated a client id by76,15%
# the broker. This means it is only useful for clients with clean session set77,15%
# to true.78,15%
#allow_zero_length_clientid true79,15%
80,0-15%
# If allow_zero_length_clientid is true, this option allows you to set a prefix81,15%
# to automatically generated client ids to aid visibility in logs.82,16%
#auto_id_prefix83,16%
84,0-16%
# This option allows persistent clients (those with clean session set to false)85,16%
# to be removed if they do not reconnect within a certain time frame.86,16%
#87,16%
# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1.88,16%
#89,16%
# Badly designed clients may set clean session to false whilst using a randomly90,17%
# generated client id. This leads to persistent clients that will never91,17%
# reconnect. This option allows these clients to be removed.92,17%
#93,17%
# The expiration period should be an integer followed by one of h d w m y for94,17%
# hour, day, week, month and year respectively. For example95,17%
#96,17%
# persistent_client_expiration 2m97,18%
# persistent_client_expiration 14d98,18%
# persistent_client_expiration 1y99,18%
#100,18%
# The default if not set is to never expire persistent clients.101,18%
#persistent_client_expiration102,18%
103,0-18%
# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/#104,18%
# and foo/+/baz , then MQTT expects that when the broker receives a message on105,19%
# a topic that matches both subscriptions, such as foo/bar/baz, then the client106,19%
# should only receive the message once.107,19%
# Mosquitto keeps track of which clients a message has been sent to in order to108,19%
# meet this requirement. The allow_duplicate_messages option allows this109,19%
# behaviour to be disabled, which may be useful if you have a large number of110,19%
# clients subscribed to the same set of topics and are very concerned about111,19%
# minimising memory usage.112,19%
# It can be safely set to true if you know in advance that your clients will113,110%
# never have overlapping subscriptions, otherwise your clients must be able to114,110%
# correctly deal with duplicate messages even when then have QoS=2.115,110%
#allow_duplicate_messages false116,110%
117,0-110%
# The MQTT specification requires that the QoS of a message delivered to a118,110%
# subscriber is never upgraded to match the QoS of the subscription. Enabling119,110%
# this option changes this behaviour. If upgrade_outgoing_qos is set true,120,110%
# messages sent to a subscriber will always match the QoS of its subscription.121,111%
# This is a non-standard option explicitly disallowed by the spec.122,111%
#upgrade_outgoing_qos false123,111%
124,0-111%
# =================================================================125,111%
# Default listener126,111%
# =================================================================127,111%
128,0-111%
# IP address/hostname to bind the default listener to. If not129,112%
# given, the default listener will not be bound to a specific 130,112%
# address and so will be accessible to all network interfaces.131,112%
# bind_address ip-address/host name132,112%
#bind_address133,112%
134,0-112%
# Port to use for the default listener.135,112%
#port 1883136,112%
137,0-113%
# The maximum number of client connections to allow. This is 138,113%
# a per listener setting.139,113%
# Default is -1, which means unlimited connections.140,113%
# Note that other process limits mean that unlimited connections 141,113%
# are not really possible. Typically the default maximum number of 142,113%
# connections possible is around 1024.143,113%
#max_connections -1144,113%
145,0-114%
# Choose the protocol to use when listening.146,114%
# This can be either mqtt or websockets.147,114%
# Websockets support is currently disabled by default at compile time.148,114%
# Certificate based TLS may be used with websockets, except that149,114%
# only the cafile, certfile, keyfile and ciphers options are supported.150,114%
#protocol mqtt151,114%
152,0-114%
# When a listener is using the websockets protocol, it is possible to serve153,115%
# http data as well. Set http_dir to a directory which contains the files you154,115%
# wish to serve. If this option is not specified, then no normal http155,115%
# connections will be possible.156,115%5432,0-11,1  0498765,0-14,1  32103987,0-16,1  -- 插入 --136,115%port 18831789401234max_connections -115678950123456
#http_dir157,115%
158,115%
# Set use_username_as_clientid to true to replace the clientid that a client159,115%
# connected with with its username. This allows authentication to be tied to160,116%
# the clientid, which means that it is possible to prevent one client161,116%
# disconnecting another by using the same clientid.162,116%
# If a client connects with no username it will be disconnected as not163,116%
# authorised when this option is set to true.164,116%
# Do not use in conjunction with clientid_prefixes.165,116%
# See also use_identity_as_username.166,116%
#use_username_as_clientid167,116%
168,117%
# -----------------------------------------------------------------169,117%
# Certificate based SSL/TLS support170,117%
# -----------------------------------------------------------------171,117%
# The following options can be used to enable SSL/TLS support for 172,117%
# this listener. Note that the recommended port for MQTT over TLS173,117%
# is 8883, but this must be set manually.174,117%3210698728,1u2s3e4r56w7a8n9g10s1h2u3m4i5n69701234
#175,217%
# See also the mosquitto-tls man page.176,1618%
177,118%
# At least one of cafile or capath must be defined. They both 178,1618%
# define methods of accessing the PEM encoded Certificate 179,1618%
# Authority certificates that have signed your server certificate 180,1618%
# and that you wish to trust.181,1618%
# cafile defines the path to a file containing the CA certificates.182,1618%182,1518%:wq!
"mosquitto.conf" 821L, 36819C 已写入




[wangshumin@CentOSNode1 mosquitto]$ pwd
/etc/mosquitto
[wangshumin@CentOSNode1 mosquitto]$ mosquitto -c /etc/mosquitto/mosquitto.conf
1524557999: mosquitto version 1.4.9 (build date 2018-04-24 15:56:07+0800) starting
1524557999: Config loaded from /etc/mosquitto/mosquitto.conf.
1524557999: Opening ipv4 listen socket on port 1883.
1524557999: Opening ipv6 listen socket on port 1883.
 wangshumin hhhaaa
^C1524558206: mosquitto version 1.4.9 terminating
[wangshumin@CentOSNode1 mosquitto]$ mosquitto_sub -t HelloWord mosquitto_sub
: error while loading shared libraries: libmosquitto.so.1: cannot open shared object file: No such file or directory
[wangshumin@ CentOSNode1 mosquitto]$ sudo ln -s /usr/local/lib/libmosquitto.so.1 /usr/lib/libmosquitto 
.so.1
[sudo] wangshumin's password:
[wangshumin@CentOSNode1 mosquitto]$ ldconfig
ldconfig: Unable to create temporary Cache file /etc/ld.so.cache~: Insufficient permissions
[wangshumin@CentOSNode1 mosquitto]$ sudo 
[wangshumin@CentOSNode1 mosquitto]$ mosquitto_sub -t HelloWord
Error: Connection refused
[wangshumin@CentOSNode1 mosquitto]$ sudo 
sudo: mosquitto_sub: find less than command
[wangshumin@CentOSNode1 mosquitto]$ ll
总用量 84
-rw-r--r--. 1 root root   230 4月  24 16:10 aclfile.example
-rw-r--r--. 1 root root 36819 4月  24 16:19 mosquitto.conf
-rw-r--r--. 1 root root 36806 4月  24 16:10 mosquitto.conf.example
-rw-r--r--. 1 root root    23 4月  24 16:10 pskfile.example
-rw-r--r--. 1 root root   355 4月  24 16:10 pwfile.example
[wangshumin@CentOSNode1 mosquitto]$ mosquitto -c /etc/mosquitto/mosquitto.conf
1524558395: mosquitto version 1.4.9 (build date 2018-04-24 15:56:07+0800) starting
1524558395: Config loaded from /etc/mosquitto/mosquitto.conf.
1524558395: Opening ipv4 listen socket on port 1883.
1524558395: Opening ipv6 listen socket on port 1883.
1524558406: New connection from ::1 on port 1883.
1524558406: New client connected from ::1 as mosqsub/24268-CentOSNod (c1, k60).
1524558440: New connection from ::1 on port 1883.
1524558440: New client connected from ::1 as mosqpub/24322-CentOSNod (c1, k60).
1524558440: Client mosqpub/24322-CentOSNod disconnected.
1524558449: New connection from ::1 on port 1883.
1524558449: New client connected from ::1 as mosqpub/24329-CentOSNod (c1, k60).
1524558449: Client mosqpub/24329-CentOSNod disconnected.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324867573&siteId=291194637