ProxySQL讀寫分離測試

来源:https://www.cnblogs.com/aaron8219/archive/2018/08/10/9458301.html
-Advertisement-
Play Games

占座 ...


  Preface       I've implemented ProxySQL on PXC yesterday but got some errors when configured query rules.I'm gonna do it again in my master-slave environment again.Let's see the procedure.   Procedure   Start ProxySQL.
1 [root@zlm1 17:22:46 /var/lib]
2 #service proxysql start
3 Starting ProxySQL: ProxySQL is already running.
4 
5 [root@zlm1 17:23:16 /var/lib]
6 #ps aux|grep proxysql
7 root       666  0.0  0.5  58180  5180 ?        S    15:06   0:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql
8 root       667  0.0  2.0 104152 21068 ?        Sl   15:06   0:02 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql
9 root      5523  0.0  0.0 112640   960 pts/1    R+   15:55   0:00 grep --color=auto proxysql

 

Login ProxySQL configure the hostgroups.
 1 [root@zlm1 17:27:11 ~]
 2 #mysql -uadmin -padmin -h127.0.0.1 -P6032
 3 mysql: [Warning] Using a password on the command line interface can be insecure.
 4 Welcome to the MySQL monitor.  Commands end with ; or \g.
 5 Your MySQL connection id is 1
 6 Server version: 5.5.30 (ProxySQL Admin Module)
 7 
 8 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 9 
10 Oracle is a registered trademark of Oracle Corporation and/or its
11 affiliates. Other names may be trademarks of their respective
12 owners.
13 
14 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
15 
16 admin@127.0.0.1:6032 [(none)]>select * from mysql_replication_hostgroups;
17 Empty set (0.00 sec)
18 
19 admin@127.0.0.1:6032 [(none)]>insert into mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup) values(10,20);
20 Query OK, 1 row affected (0.00 sec)
21 
22 admin@127.0.0.1:6032 [(none)]>select * from mysql_replication_hostgroups;
23 +------------------+------------------+---------+
24 | writer_hostgroup | reader_hostgroup | comment |
25 +------------------+------------------+---------+
26 | 10               | 20               |         |
27 +------------------+------------------+---------+
28 1 row in set (0.00 sec)
29 
30 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_replication_hostgroups;
31 Empty set (0.00 sec)
32 
33 admin@127.0.0.1:6032 [(none)]>select * from disk.mysql_replication_hostgroups;
34 Empty set (0.00 sec)
35 
36 admin@127.0.0.1:6032 [(none)]>load mysql servers to runtime;save mysql servers to disk;
37 Query OK, 0 rows affected (0.00 sec)
38 
39 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_replication_hostgroups;
40 +------------------+------------------+---------+
41 | writer_hostgroup | reader_hostgroup | comment |
42 +------------------+------------------+---------+
43 | 10               | 20               |         |
44 +------------------+------------------+---------+
45 1 row in set (0.00 sec)
46 
47 admin@127.0.0.1:6032 [(none)]>select * from disk.mysql_replication_hostgroups;
48 +------------------+------------------+---------+
49 | writer_hostgroup | reader_hostgroup | comment |
50 +------------------+------------------+---------+
51 | 10               | 20               |         |
52 +------------------+------------------+---------+
53 1 row in set (0.00 sec)

 

Configure the mysql servers.
  1 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
  2 Empty set (0.00 sec)
  3 
  4 admin@127.0.0.1:6032 [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(10,'192.168.56.100',100,300);
  5 Query OK, 1 row affected (0.00 sec)
  6 
  7 admin@127.0.0.1:6032 [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(20,'192.168.56.101',100,300);
  8 Query OK, 1 row affected (0.00 sec)
  9 
 10 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
 11 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 12 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
 13 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 14 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 15 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 16 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 17 2 rows in set (0.00 sec)
 18 
 19 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_servers;
 20 Empty set (0.00 sec)
 21 
 22 admin@127.0.0.1:6032 [(none)]>select * from disk.mysql_servers;
 23 Empty set (0.00 sec)
 24 
 25 admin@127.0.0.1:6032 [(none)]>load mysql servers to runtime;save mysql servers to disk;
 26 Query OK, 0 rows affected (0.00 sec)
 27 
 28 Query OK, 0 rows affected (0.05 sec)
 29 
 30 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_servers;
 31 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 32 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
 33 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 34 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 35 | 20           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 36 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 37 2 rows in set (0.00 sec)
 38 
 39 //Why does the hostgroup_id in table "runtime_mysql_servers" still "20"?
 40 
 41 admin@127.0.0.1:6032 [(none)]>select * from disk.mysql_servers;
 42 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 43 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
 44 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 45 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 46 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 47 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 48 2 rows in set (0.00 sec)
 49 
 50 //The hostgroup_id in table "disk.mysql_servers" has taken effect.
 51 
 52 //Check the variables of "read_only" and "super_read_only".
 53 zlm@192.168.56.100:3306 [(none)]>show variables like '%read_only%';
 54 +-----------------------+-------+
 55 | Variable_name         | Value |
 56 +-----------------------+-------+
 57 | innodb_read_only      | OFF   |
 58 | read_only             | OFF   |
 59 | super_read_only       | OFF   |
 60 | transaction_read_only | OFF   |
 61 | tx_read_only          | OFF   |
 62 +-----------------------+-------+
 63 5 rows in set (0.00 sec)
 64 
 65 admin@127.0.0.1:6032 [(none)]>load mysql servers to runtime;
 66 Query OK, 0 rows affected (0.00 sec)
 67 
 68 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_servers;
 69 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 70 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
 71 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 72 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 73 | 20           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 74 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 75 2 rows in set (0.00 sec)
 76 
 77 //It's still "20".
 78 
 79 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
 80 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 81 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
 82 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 83 | 20           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 84 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
 85 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
 86 2 rows in set (0.00 sec)
 87 
 88 //The "hostgroup_id" in mysql_serves also turned to be "20".Why does it happen?It's the reason why my query rule did not take effect yesterday.
 89 
 90 admin@127.0.0.1:6032 [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 10;
 91 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
 92 | hostname       | port | time_start_us    | connect_success_time_us | connect_error                                                 |
 93 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
 94 | 192.168.56.100 | 3306 | 1533999241153417 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
 95 | 192.168.56.101 | 3306 | 1533999240299607 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
 96 | 192.168.56.101 | 3306 | 1533999181251828 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
 97 | 192.168.56.100 | 3306 | 1533999180299465 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
 98 | 192.168.56.101 | 3306 | 1533999120959376 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
 99 | 192.168.56.100 | 3306 | 1533999120299350 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
100 | 192.168.56.100 | 3306 | 1533999061361175 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
101 | 192.168.56.101 | 3306 | 1533999060299292 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
102 | 192.168.56.100 | 3306 | 1533999001472876 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
103 | 192.168.56.101 | 3306 | 1533999000299091 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
104 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
105 10 rows in set (0.00 sec)
106 
107 //It seems the privileges was configurated abnormally.
108 
109 zlm@192.168.56.100:3306 [(none)]>select user,host from mysql.user;
110 +---------------+--------------+
111 | user          | host         |
112 +---------------+--------------+
113 | repl          | 192.168.56.% |
114 | zlm           | 192.168.56.% |
115 | bkuser        | localhost    |
116 | monitor       | localhost    |
117 | mysql.session | localhost    |
118 | mysql.sys     | localhost    |
119 | root          | localhost    |
120 +---------------+--------------+
121 7 rows in set (0.00 sec)
122 
123 zlm@192.168.56.100:3306 [(none)]>drop user monitor@localhost;
124 Query OK, 0 rows affected (0.00 sec)
125 
126 zlm@192.168.56.100:3306 [(none)]>grant all privileges on *.* to monitor@'%' identified by 'monitor';
127 ERROR 1045 (28000): Access denied for user 'zlm'@'192.168.56.%' (using password: YES)
128 zlm@192.168.56.100:3306 [(none)]>exit
129 Bye
130 
131 [root@zlm1 17:59:50 /data/backup]
132 #mysql -uroot -pPassw0rd -hlocalhost -S /tmp/mysql3306.sock
133 mysql: [Warning] Using a password on the command line interface can be insecure.
134 Welcome to the MySQL monitor.  Commands end with ; or \g.
135 Your MySQL connection id is 2758
136 Server version: 5.7.21-log MySQL Community Server (GPL)
137 
138 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
139 
140 Oracle is a registered trademark of Oracle Corporation and/or its
141 affiliates. Other names may be trademarks of their respective
142 owners.
143 
144 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
145 
146 root@localhost:mysql3306.sock [(none)]>grant all privileges on *.* to monitor@'%' identified by 'monitor';
147 Query OK, 0 rows affected, 1 warning (0.00 sec)
148 
149 root@localhost:mysql3306.sock [(none)]>select user,host from mysql.user;
150 +---------------+--------------+
151 | user          | host         |
152 +---------------+--------------+
153 | monitor       | %            |
154 | repl          | 192.168.56.% |
155 | zlm           | 192.168.56.% |
156 | bkuser        | localhost    |
157 | mysql.session | localhost    |
158 | mysql.sys     | localhost    |
159 | root          | localhost    |
160 +---------------+--------------+
161 7 rows in set (0.00 sec)
162 
163 admin@127.0.0.1:6032 [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 10;
164 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
165 | hostname       | port | time_start_us    | connect_success_time_us | connect_error                                                 |
166 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
167 | 192.168.56.101 | 3306 | 1533999721321021 | 1040                    | NULL                                                          |
168 | 192.168.56.100 | 3306 | 1533999720303754 | 441                     | NULL                                                          |
169 | 192.168.56.100 | 3306 | 1533999661174268 | 370                     | NULL                                                          |
170 | 192.168.56.101 | 3306 | 1533999660302486 | 1468                    | NULL                                                          |
171 | 192.168.56.100 | 3306 | 1533999601377823 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
172 | 192.168.56.101 | 3306 | 1533999600302394 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
173 | 192.168.56.101 | 3306 | 1533999541205310 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
174 | 192.168.56.100 | 3306 | 1533999540302168 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
175 | 192.168.56.101 | 3306 | 1533999480925661 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
176 | 192.168.56.100 | 3306 | 1533999480302043 | 0                       | Access denied for user 'monitor'@'zlm1' (using password: YES) |
177 +----------------+------+------------------+-------------------------+---------------------------------------------------------------+
178 10 rows in set (0.00 sec)
179 
180 //The monitor became normal.
181 
182 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
183 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
184 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
185 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
186 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
187 | 20           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
188 | 10           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
189 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
190 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
191 4 rows in set (0.00 sec)
192 
193 admin@127.0.0.1:6032 [(none)]>delete from mysql_servers;
194 Query OK, 4 rows affected (0.00 sec)
195 
196 admin@127.0.0.1:6032 [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(10,'192.168.56.100',100,300),(20,'192.168.56.101',100,300);
197 Query OK, 2 rows affected (0.00 sec)
198 
199 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
200 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
201 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
202 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
203 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
204 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
205 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
206 2 rows in set (0.00 sec)
207 
208 admin@127.0.0.1:6032 [(none)]>load mysql servers to runtime;save mysql servers to disk;
209 Query OK, 0 rows affected (0.00 sec)
210 
211 Query OK, 0 rows affected (0.02 sec)
212 
213 admin@127.0.0.1:6032 [(none)]>select * from mysql_servers;
214 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
215 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
216 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
217 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
218 | 10           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
219 | 20           | 192.168.56.101 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
220 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
221 3 rows in set (0.00 sec)
222 
223 //Why there're three records in table "mysql_servers"?
224 
225 admin@127.0.0.1:6032 [(none)]>select * from runtime_mysql_servers;
226 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
227 | hostgroup_id | hostname       | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
228 +--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
229 | 10           | 192.168.56.100 | 3306 | ONLINE | 1      | 0           | 100             | 300                 | 0       | 0              |         |
230 | 20           |

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 環境 lunix(ubuntu) 1:添加文件 在 /etc/apt/sources.list.d/gitlab-ce.list 中添加一行 2:開始安裝 3:修改配置 /etc/gitlab/gitlab.rb 中修改 external_url (如 : external_url 'http:// ...
  • 將兩伺服器通訊問題擴展到多伺服器通訊問題,需要解決定址以及復用/分用問題,這就是數據鏈路層的主要作用。 ...
  • 前言 Internet最早來源於美國國防部ARPANet,1969年投入運行,到現在已有很長一段路了,各位想要瞭解發展史可以百度下,這裡就不多說了。 現如今當我們想要獲取一些資料,首先是打開某個瀏覽器,在地址欄輸入地址,想要的信息出現在你的面前。 大家有沒有想過輸入地址就能返回給你想要的信息是怎麼實 ...
  • 檢查了好久才知道原來是 sudo nano /etc/sysconfig/network-scripts/ifcfg-ens33 下的DNS配錯了,改好之後,sudo service network restart 就ok了 ...
  • 由於經常使用 vim 編輯配置文件,有時候也會進行使用vim 編寫一些腳本和c/c++ 程式,所以配置一個常用的 vim 是很是必要的。這篇博文主要是記錄vim使用和配置相關的一些知識點。 關於vim : vim 是比較好用的編輯器,很多linux server 都自帶vi, vim 是vi 的升級 ...
  • 1. linux中 xl2tpd VPN連接需要兩個程式 xl2tpd 和pppd並且pppd包含l2tpd.so庫。 並且需要兩個配置文件 一個xl2tpd配置文件一個pppd配置文件當xl2tpd啟動時會調用pppd. root@router:~/xl2tpd# cat options.xl2t ...
  • 您的Web瀏覽器會保留您訪問的每個網頁的歷史記錄,以便您可以輕鬆返回之前看到的內容。那麼為什麼不讓您的操作系統跟蹤您所處理的每個文件?從2017年12月發佈的 Insider Build 17063開始,Windows 10有一項名為Timeline的新功能,可以跟蹤您打開的每個文件以及您訪問過的每 ...
  • [20180810]exadata--豆腐渣系統的保護神.txt--//最近一段時間,一直在看exdata方面的書籍,我個人的感覺exadata並非善長oltp系統,能通過OLTP獲得好處的就算exadata的快閃記憶體(也叫--//智能快閃記憶體).當然大部分系統負載類型都是混合型的,但是如果你系統OLTP占 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...