1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
| ## Redis configuration file example.
##
## Note that in order to read the configuration file, Redis must be
## started with the file path as first argument:
##
## ./redis-server /path/to/redis.conf
## Note on units: when memory size is needed, it is possible to specify
## it in the usual form of 1k 5GB 4M and so forth:
##
## 1k => 1000 bytes
## 1kb => 1024 bytes
## 1m => 1000000 bytes
## 1mb => 1024*1024 bytes
## 1g => 1000000000 bytes
## 1gb => 1024*1024*1024 bytes
##
## units are case insensitive so 1GB 1Gb 1gB are all the same.
################################### INCLUDES ###################################
## Include one or more other config files here. This is useful if you
## have a standard template that goes to all Redis servers but also need
## to customize a few per-server settings. Include files can include
## other files, so use this wisely.
##
## Note that option "include" won't be rewritten by command "CONFIG REWRITE"
## from admin or Redis Sentinel. Since Redis always uses the last processed
## line as value of a configuration directive, you'd better put includes
## at the beginning of this file to avoid overwriting config change at runtime.
##
## If instead you are interested in using includes to override configuration
## options, it is better to use include as the last line.
##
## include /path/to/local.conf
## include /path/to/other.conf
################################### MODULES #####################################
## Load modules at startup. If the server is not able to load modules
## it will abort. It is possible to use multiple loadmodule directives.
##
## loadmodule /path/to/my_module.so
## loadmodule /path/to/other_module.so
################################### NETWORK #####################################
## By default, if no "bind" configuration directive is specified, Redis listens
## for connections from all available network interfaces on the host machine.
## It is possible to listen to just one or multiple selected interfaces using
## the "bind" configuration directive, followed by one or more IP addresses.
## Each address can be prefixed by "-", which means that redis will not fail to
## start if the address is not available. Being not available only refers to
## addresses that does not correspond to any network interfece. Addresses that
## are already in use will always fail, and unsupported protocols will always BE
## silently skipped.
##
## Examples:
##
## bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses
## bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6
## bind * -::* # like the default, all available interfaces
##
## ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
## internet, binding to all the interfaces is dangerous and will expose the
## instance to everybody on the internet. So by default we uncomment the
## following bind directive, that will force Redis to listen only on the
## IPv4 and IPv6 (if available) loopback interface addresses (this means Redis
## will only be able to accept client connections from the same host that it is
## running on).
##
## IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
## JUST COMMENT OUT THE FOLLOWING LINE.
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## bind 127.0.0.1 -::1
## BEGIN MEIZHAOHUI COMMENTS
## bind 配置的是 redis server 网卡的地址,配置哪个网卡地址,
## 你就可以通过哪个网卡地址访问redis,而不是外部访问redis的ip列表
## END MEIZHAOHUI COMMENTS
bind 192.168.56.121 127.0.0.1
## Protected mode is a layer of security protection, in order to avoid that
## Redis instances left open on the internet are accessed and exploited.
##
## When protected mode is on and if:
##
## 1) The server is not binding explicitly to a set of addresses using the
## "bind" directive.
## 2) No password is configured.
##
## The server only accepts connections from clients connecting from the
## IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
## sockets.
##
## By default protected mode is enabled. You should disable it only if
## you are sure you want clients from other hosts to connect to Redis
## even if no authentication is configured, nor a specific set of interfaces
## are explicitly listed using the "bind" directive.
## protected-mode yes
## BEGIN MEIZHAOHUI COMMENTS
## protected-mode yes 保护模式,这种模式限制了只有本地可以访问redis服务器
## 如果需要外部客户端连接redis服务器,则应设置为 protected-mode no 非保护模式
## END MEIZHAOHUI COMMENTS
protected-mode no
## Accept connections on the specified port, default is 6379 (IANA #815344).
## If port 0 is specified Redis will not listen on a TCP socket.
## port 6379
## BEGIN MEIZHAOHUI COMMENTS
## redis服务监听端口,默认6379
## 使用默认的端口号不是很安全,为了安全一点,需要修改默认的端口号
## 建议修改为10000以上,60000以下的端口,我这里设置为29736
## END MEIZHAOHUI COMMENTS
port 29736
## TCP listen() backlog.
##
## In high requests-per-second environments you need a high backlog in order
## to avoid slow clients connection issues. Note that the Linux kernel
## will silently truncate it to the value of /proc/sys/net/core/somaxconn so
## make sure to raise both the value of somaxconn and tcp_max_syn_backlog
## in order to get the desired effect.
tcp-backlog 511
## BEGIN MEIZHAOHUI COMMENTS
## 在linux系统中控制tcp三次握手已完成连接队列的长度
## 在高并发系统中,你需要设置一个较高的tcp-backlog来避免客户端连接速度慢的问题(三次握手的速度)
## 取 /proc/sys/net/core/somaxconn 和 tcp-backlog 配置两者中的小值
## 对于负载很大的服务程序来说一般会将它修改为2048或者更大。
## 在/etc/sysctl.conf中添加:net.core.somaxconn = 2048,然后在终端中执行sysctl -p
## END MEIZHAOHUI COMMENTS
## Unix socket.
##
## Specify the path for the Unix socket that will be used to listen for
## incoming connections. There is no default, so Redis will not listen
## on a unix socket when not specified.
##
## unixsocket /run/redis.sock
## unixsocketperm 700
## Close the connection after a client is idle for N seconds (0 to disable)
## timeout 0
## BEGIN MEIZHAOHUI COMMENTS
## 客户端空闲超时时间,默认为0,关闭超时时间
## 我设置为300秒,当客户端闲置300秒后关闭连接
## END MEIZHAOHUI COMMENTS
timeout 300
## TCP keepalive.
##
## If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
## of communication. This is useful for two reasons:
##
## 1) Detect dead peers.
## 2) Force network equipment in the middle to consider the connection to be
## alive.
##
## On Linux, the specified value (in seconds) is the period used to send ACKs.
## Note that to close the connection the double of the time is needed.
## On other kernels the period depends on the kernel configuration.
##
## A reasonable value for this option is 300 seconds, which is the new
## Redis default starting with Redis 3.2.1.
tcp-keepalive 300
## BEGIN MEIZHAOHUI COMMENTS
## 它是 TCP 连接保活策略,可以通过 tcp-keepalive 配置项来进行设置,单位为秒
## 假如设置为 60 秒,则 server 端会每 60 秒向连接空闲的客户端发起一次 ACK 请求,
## 以检查客户端是否已经挂掉,对于无响应的客户端则会关闭其连接。
## 如果设置为 0,则不会进行保活检测(默认为 tcp-keepalive 300)
## END MEIZHAOHUI COMMENTS
################################## TLS/SSL #####################################
## By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
## directive can be used to define TLS-listening ports. To enable TLS on the
## default port, use:
##
## port 0
## tls-port 6379
## Configure a X.509 certificate and private key to use for authenticating the
## server to connected clients, masters or cluster peers. These files should be
## PEM formatted.
##
## tls-cert-file redis.crt
## tls-key-file redis.key
##
## If the key file is encrypted using a passphrase, it can be included here
## as well.
##
## tls-key-file-pass secret
## Normally Redis uses the same certificate for both server functions (accepting
## connections) and client functions (replicating from a master, establishing
## cluster bus connections, etc.).
##
## Sometimes certificates are issued with attributes that designate them as
## client-only or server-only certificates. In that case it may be desired to use
## different certificates for incoming (server) and outgoing (client)
## connections. To do that, use the following directives:
##
## tls-client-cert-file client.crt
## tls-client-key-file client.key
##
## If the key file is encrypted using a passphrase, it can be included here
## as well.
##
## tls-client-key-file-pass secret
## Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
## required by older versions of OpenSSL (<3.0). Newer versions do not require
## this configuration and recommend against it.
##
## tls-dh-params-file redis.dh
## Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
## clients and peers. Redis requires an explicit configuration of at least one
## of these, and will not implicitly use the system wide configuration.
##
## tls-ca-cert-file ca.crt
## tls-ca-cert-dir /etc/ssl/certs
## By default, clients (including replica servers) on a TLS port are required
## to authenticate using valid client side certificates.
##
## If "no" is specified, client certificates are not required and not accepted.
## If "optional" is specified, client certificates are accepted and must be
## valid if provided, but are not required.
##
## tls-auth-clients no
## tls-auth-clients optional
## By default, a Redis replica does not attempt to establish a TLS connection
## with its master.
##
## Use the following directive to enable TLS on replication links.
##
## tls-replication yes
## By default, the Redis Cluster bus uses a plain TCP connection. To enable
## TLS for the bus protocol, use the following directive:
##
## tls-cluster yes
## By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
## that older formally deprecated versions are kept disabled to reduce the attack surface.
## You can explicitly specify TLS versions to support.
## Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
## "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
## To enable only TLSv1.2 and TLSv1.3, use:
##
## tls-protocols "TLSv1.2 TLSv1.3"
## Configure allowed ciphers. See the ciphers(1ssl) manpage for more information
## about the syntax of this string.
##
## Note: this configuration applies only to <= TLSv1.2.
##
## tls-ciphers DEFAULT:!MEDIUM
## Configure allowed TLSv1.3 ciphersuites. See the ciphers(1ssl) manpage for more
## information about the syntax of this string, and specifically for TLSv1.3
## ciphersuites.
##
## tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256
## When choosing a cipher, use the server's preference instead of the client
## preference. By default, the server follows the client's preference.
##
## tls-prefer-server-ciphers yes
## By default, TLS session caching is enabled to allow faster and less expensive
## reconnections by clients that support it. Use the following directive to disable
## caching.
##
## tls-session-caching no
## Change the default number of TLS sessions cached. A zero value sets the cache
## to unlimited size. The default size is 20480.
##
## tls-session-cache-size 5000
## Change the default timeout of cached TLS sessions. The default timeout is 300
## seconds.
##
## tls-session-cache-timeout 60
################################## GENERAL #####################################
## By default Redis does not run as a daemon. Use 'yes' if you need it.
## Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
## When Redis is supervised by upstart or systemd, this parameter has no impact.
daemonize no
## BEGIN MEIZHAOHUI COMMENTS
## 是否以守护进程方式运行
## 我后面需要使用supervisor来启动Redis,因此不以守护进程方式运行
## END MEIZHAOHUI COMMENTS
## If you run Redis from upstart or systemd, Redis can interact with your
## supervision tree. Options:
## supervised no - no supervision interaction
## supervised upstart - signal upstart by putting Redis into SIGSTOP mode
## requires "expect stop" in your upstart job config
## supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
## on startup, and updating Redis status on a regular
## basis.
## supervised auto - detect upstart or systemd method based on
## UPSTART_JOB or NOTIFY_SOCKET environment variables
## Note: these supervision methods only signal "process is ready."
## They do not enable continuous pings back to your supervisor.
##
## The default is "no". To run under upstart/systemd, you can simply uncomment
## the line below:
##
## supervised auto
## BEGIN MEIZHAOHUI COMMENTS
## 若从upstart或systemd运行Redis,则Redis可以与监控树交互。
## supervised no - 无相互监督,默认
## supervised upstart - 使Redis进入SIGSTOP模式并监控upstart
## supervised systemd - 通过设置READY=1到$NOTIFY_SOCKET来监控systemd
## supervised auto - 基于UPSTART_JOB或NOTIFY_SOCKET环境变量的监督自动检测upstart或systemd方法
## END MEIZHAOHUI COMMENTS
## If a pid file is specified, Redis writes it where specified at startup
## and removes it at exit.
##
## When the server runs non daemonized, no pid file is created if none is
## specified in the configuration. When the server is daemonized, the pid file
## is used even if not specified, defaulting to "/var/run/redis.pid".
##
## Creating a pid file is best effort: if Redis is not able to create it
## nothing bad happens, the server will start and run normally.
##
## Note that on modern Linux systems "/run/redis.pid" is more conforming
## and should be used instead.
## pidfile /var/run/redis_6379.pid
## BEGIN MEIZHAOHUI COMMENTS
## 设置PID文件,我将redis相关的文件都放在 /srv/redis 目录下
## END MEIZHAOHUI COMMENTS
pidfile /srv/redis/pid/redis_29736.pid
## Specify the server verbosity level.
## This can be one of:
## debug (a lot of information, useful for development/testing)
## verbose (many rarely useful info, but not a mess like the debug level)
## notice (moderately verbose, what you want in production probably)
## warning (only very important / critical messages are logged)
loglevel notice
## BEGIN MEIZHAOHUI COMMENTS
## loglevel 指定日志级别
## 开发阶段可以设置成 debug,生产阶段通常设置为 notice 或者 warning,默认为 loglevel notice
## END MEIZHAOHUI COMMENTS
## Specify the log file name. Also the empty string can be used to force
## Redis to log on the standard output. Note that if you use standard
## output for logging but daemonize, logs will be sent to /dev/null
## logfile ""
## BEGIN MEIZHAOHUI COMMENTS
## logfile 指定日志文件
## redis 在运行过程中,会输出一些日志信息;默认情况下,这些日志信息会输出到控制台;
## 我们可以使用 logfile 配置日志文件,使 redis 把日志信息输出到指定文件中
## END MEIZHAOHUI COMMENTS
logfile "/srv/redis/logs/redis_29736.log"
## To enable logging to the system logger, just set 'syslog-enabled' to yes,
## and optionally update the other syslog parameters to suit your needs.
## syslog-enabled no
## BEGIN MEIZHAOHUI COMMENTS
## syslog-enabled 是否把日志输出到系统日志,默认no,即不输出到系统日志
## END MEIZHAOHUI COMMENTS
## Specify the syslog identity.
## syslog-ident redis
## BEGIN MEIZHAOHUI COMMENTS
## syslog-ident 指定syslog的标示符,如果'syslog-enabled'是no,则这个选项无效
## END MEIZHAOHUI COMMENTS
## Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
## syslog-facility local0
## BEGIN MEIZHAOHUI COMMENTS
## syslog-facility 指定syslog 设备(facility), 必须是USER或者LOCAL0到LOCAL7
## END MEIZHAOHUI COMMENTS
## To disable the built in crash log, which will possibly produce cleaner core
## dumps when they are needed, uncomment the following:
##
## crash-log-enabled no
## BEGIN MEIZHAOHUI COMMENTS
## crash-log-enabled参数用于启用或禁用Redis的崩溃日志功能
## 当Redis发生崩溃时,崩溃日志将被记录在特定的日志文件中,以帮助用户诊断和调试问题。
## 如果你禁用了崩溃日志功能,当Redis发生崩溃时,你将无法获得相关的日志信息,可能会增加故障排查的难度。
## 因此,一般情况下建议将crash-log-enabled参数设置为"yes"
## END MEIZHAOHUI COMMENTS
crash-log-enabled yes
## To disable the fast memory check that's run as part of the crash log, which
## will possibly let redis terminate sooner, uncomment the following:
##
## crash-memcheck-enabled no
## BEGIN MEIZHAOHUI COMMENTS
## crash-memcheck-enabled是一个启用或禁用内存检查的参数。
## 当启用内存检查时,Redis会使用Valgrind实用程序memcheck来检查内存错误和泄漏。
## 这有助于发现和修复潜在的内存问题
## 请注意,启用内存检查会显著影响Redis的性能,因为它会增加运行时开销。
## 因此,仅在调试或测试目的时才应启用此参数。在生产环境中,应禁用它以获得最佳性能。
## 因此,保持默认crash-memcheck-enabled no即可
## END MEIZHAOHUI COMMENTS
## Set the number of databases. The default database is DB 0, you can select
## a different one on a per-connection basis using SELECT <dbid> where
## dbid is a number between 0 and 'databases'-1
databases 16
## BEGIN MEIZHAOHUI COMMENTS
## 设置数据库的数量,默认16个
## END MEIZHAOHUI COMMENTS
## By default Redis shows an ASCII art logo only when started to log to the
## standard output and if the standard output is a TTY and syslog logging is
## disabled. Basically this means that normally a logo is displayed only in
## interactive sessions.
##
## However it is possible to force the pre-4.0 behavior and always show a
## ASCII art logo in startup logs by setting the following option to yes.
always-show-logo no
## BEGIN MEIZHAOHUI COMMENTS
## Redis服务器在启动时是否显示LOGO
## END MEIZHAOHUI COMMENTS
## By default, Redis modifies the process title (as seen in 'top' and 'ps') to
## provide some runtime information. It is possible to disable this and leave
## the process name as executed by setting the following to no.
## set-proc-title yes
## BEGIN MEIZHAOHUI COMMENTS
## 设置Redis进程的标题,我不自定义标题
## 设置 set-proc-title no
## END MEIZHAOHUI COMMENTS
set-proc-title no
## When changing the process title, Redis uses the following template to construct
## the modified title.
##
## Template variables are specified in curly brackets. The following variables are
## supported:
##
## {title} Name of process as executed if parent, or type of child process.
## {listen-addr} Bind address or '*' followed by TCP or TLS port listening on, or
## Unix socket if only that's available.
## {server-mode} Special mode, i.e. "[sentinel]" or "[cluster]".
## {port} TCP port listening on, or 0.
## {tls-port} TLS port listening on, or 0.
## {unixsocket} Unix domain socket listening on, or "".
## {config-file} Name of configuration file used.
##
proc-title-template "{title} {listen-addr} {server-mode}"
## BEGIN MEIZHAOHUI COMMENTS
## 设置Redis进程的标题模板,保持默认值
## END MEIZHAOHUI COMMENTS
################################# SNAPSHOTTING ################################
## Save the DB to disk.
##
## save <seconds> <changes>
##
## Redis will save the DB if both the given number of seconds and the given
## number of write operations against the DB occurred.
##
## Snapshotting can be completely disabled with a single empty string argument
## as in following example:
##
## save ""
##
## Unless specified otherwise, by default Redis will save the DB:
## * After 3600 seconds (an hour) if at least 1 key changed
## * After 300 seconds (5 minutes) if at least 100 keys changed
## * After 60 seconds if at least 10000 keys changed
##
## You can set these explicitly by uncommenting the three following lines.
##
## save 3600 1
## save 300 100
## save 60 10000
## BEGIN MEIZHAOHUI COMMENTS
## 在Redis 6.2.14中,save配置指令已经被弃用,并在新版本中被移除。
## Redis 6.0之前的版本使用save指令来配置在特定的时间间隔内执行数据集的持久化操作。
## 然而,这种方式是同步的,会阻塞服务器进程,因此不推荐在生产环境中使用。
##
## 在Redis 6.0及以上版本,持久化操作采用了新的默认配置,通过RDB和AOF来进行数据的持久化。
## RDB是定时的数据快照,AOF是追加日志形式的持久化方式,它可以提供更好的持久化保证。
## END MEIZHAOHUI COMMENTS
## By default Redis will stop accepting writes if RDB snapshots are enabled
## (at least one save point) and the latest background save failed.
## This will make the user aware (in a hard way) that data is not persisting
## on disk properly, otherwise chances are that no one will notice and some
## disaster will happen.
##
## If the background saving process will start working again Redis will
## automatically allow writes again.
##
## However if you have setup your proper monitoring of the Redis server
## and persistence, you may want to disable this feature so that Redis will
## continue to work as usual even if there are problems with disk,
## permissions, and so forth.
stop-writes-on-bgsave-error yes
## BEGIN MEIZHAOHUI COMMENTS
## stop-writes-on-bgsave-error 配置项是Redis的一个配置选项,用于控制当后台保存(RDB持久化)出现错误时,是否停止接收写操作。
## 如果设置为yes,则当后台保存进程因为某些错误(例如磁盘空间不足)无法执行时,Redis将停止接收写操作以避免数据不一致。
## 如果设置为no,即使后台保存失败,Redis也将继续处理写操作。
## 我们使用默认值,Redis在后台保存出错时停止写操作。
## END MEIZHAOHUI COMMENTS
## Compress string objects using LZF when dump .rdb databases?
## By default compression is enabled as it's almost always a win.
## If you want to save some CPU in the saving child set it to 'no' but
## the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
## BEGIN MEIZHAOHUI COMMENTS
## 是否开启RDB文件压缩。
## RDB文件压缩是Redis的一个优化特性,它可以显著减少RDB文件的大小,从而减少磁盘I/O操作,进而提升Redis的性能。
## END MEIZHAOHUI COMMENTS
## Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
## This makes the format more resistant to corruption but there is a performance
## hit to pay (around 10%) when saving and loading RDB files, so you can disable it
## for maximum performances.
##
## RDB files created with checksum disabled have a checksum of zero that will
## tell the loading code to skip the check.
rdbchecksum yes
## BEGIN MEIZHAOHUI COMMENTS
## 是否开启RDB文件数据校验。
## Redis 6.2.14 引入了 RDB 文件的校验和功能,以确保数据的一致性和完整性。
## 这是通过在 RDB 文件的末尾添加一个 8 字节的校验和来实现的。
## 当 Redis 加载 RDB 文件时,它会计算文件的校验和,并与文件末尾的校验和进行比较,以验证文件的完整性。
## END MEIZHAOHUI COMMENTS
## Enables or disables full sanitation checks for ziplist and listpack etc when
## loading an RDB or RESTORE payload. This reduces the chances of a assertion or
## crash later on while processing commands.
## Options:
## no - Never perform full sanitation
## yes - Always perform full sanitation
## clients - Perform full sanitation only for user connections.
## Excludes: RDB files, RESTORE commands received from the master
## connection, and client connections which have the
## skip-sanitize-payload ACL flag.
## The default should be 'clients' but since it currently affects cluster
## resharding via MIGRATE, it is temporarily set to 'no' by default.
##
## sanitize-dump-payload no
## BEGIN MEIZHAOHUI COMMENTS
## sanitize-dump-payload配置项是用来在使用RDB持久化时,对数据进行清理和/或转换的。
## 当sanitize-dump-payload设置为yes时,Redis会尝试去除RDB文件中的一些不安全的payload,
## 如果它们不能被直接去除,它们将被替换为安全的值。
## 需要注意的是,这个配置项可能会对数据导入性能产生影响,因此在生产环境中使用时需要谨慎考虑。
## END MEIZHAOHUI COMMENTS
## The filename where to dump the DB
dbfilename dump.rdb
## BEGIN MEIZHAOHUI COMMENTS
## 数据库文件名,也就是RDB持久化时Dump文件的名字。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## Remove RDB files used by replication in instances without persistence
## enabled. By default this option is disabled, however there are environments
## where for regulations or other security concerns, RDB files persisted on
## disk by masters in order to feed replicas, or stored on disk by replicas
## in order to load them for the initial synchronization, should be deleted
## ASAP. Note that this option ONLY WORKS in instances that have both AOF
## and RDB persistence disabled, otherwise is completely ignored.
##
## An alternative (and sometimes better) way to obtain the same effect is
## to use diskless replication on both master and replicas instances. However
## in the case of replicas, diskless is not always an option.
rdb-del-sync-files no
## BEGIN MEIZHAOHUI COMMENTS
## 删除未启用持久性的实例中复制所使用的 RDB 文件。
## 请注意,此选项仅适用于同时禁用 AOF 和 RDB 持久性的实例,否则将被完全忽略。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## The working directory.
##
## The DB will be written inside this directory, with the filename specified
## above using the 'dbfilename' configuration directive.
##
## The Append Only File will also be created inside this directory.
##
## Note that you must specify a directory here, not a file name.
## dir ./
## BEGIN MEIZHAOHUI COMMENTS
## dir配置指的是Redis工作目录,用于存储持久化的数据文件和日志文件等。
## 我们将数据文件单独存放到 /srv/redis/data 目录下
## END MEIZHAOHUI COMMENTS
dir /srv/redis/data
################################## REPLICATION #################################
## Master-Replica replication. Use replicaof to make a Redis instance a copy of
## another Redis server. A few things to understand ASAP about Redis replication.
##
## +------------------+ +---------------+
## | Master | ---> | Replica |
## | (receive writes) | | (exact copy) |
## +------------------+ +---------------+
##
## 1) Redis replication is asynchronous, but you can configure a master to
## stop accepting writes if it appears to be not connected with at least
## a given number of replicas.
## 2) Redis replicas are able to perform a partial resynchronization with the
## master if the replication link is lost for a relatively small amount of
## time. You may want to configure the replication backlog size (see the next
## sections of this file) with a sensible value depending on your needs.
## 3) Replication is automatic and does not need user intervention. After a
## network partition replicas automatically try to reconnect to masters
## and resynchronize with them.
##
## replicaof <masterip> <masterport>
## BEGIN MEIZHAOHUI COMMENTS
## 关于 Redis 复制,有几件事需要尽快了解。
## 1) Redis 复制是异步的,但您可以配置主服务器,如果它似乎与至少给定数量的副本没有连接,则停止接受写入。
## 2) 如果复制链接在相对较短的时间内丢失,Redis 副本能够与主服务器执行部分重新同步。您可能需要根据需要使用合理的值配置复制积压大小。
## 3) 复制是自动的,不需要用户干预。在网络断开后,副本会自动尝试重新连接到主服务器,并与它们重新同步。
##
## replicaof指令被用于将当前的Redis服务器实例配置为另一个Redis服务器实例的复制品。
## 这是一个主从复制的配置选项,通常在Redis的配置文件中设置。
## END MEIZHAOHUI COMMENTS
## If the master is password protected (using the "requirepass" configuration
## directive below) it is possible to tell the replica to authenticate before
## starting the replication synchronization process, otherwise the master will
## refuse the replica request.
##
## masterauth <master-password>
##
## BEGIN MEIZHAOHUI COMMENTS
## masterauth配置指令用于设置连接到主节点(如果Redis实例是复制的从节点)时所需的密码。
## 主从配置时,从节点需要配置该参数。
## END MEIZHAOHUI COMMENTS
##
## However this is not enough if you are using Redis ACLs (for Redis version
## 6 or greater), and the default user is not capable of running the PSYNC
## command and/or other commands needed for replication. In this case it's
## better to configure a special user to use with replication, and specify the
## masteruser configuration as such:
##
## masteruser <username>
##
## BEGIN MEIZHAOHUI COMMENTS
## masteruser 用来指定主节点使用的用户。Redis 6或以上版本才支持ACL控制。
## END MEIZHAOHUI COMMENTS
##
## When masteruser is specified, the replica will authenticate against its
## master using the new AUTH form: AUTH <username> <password>.
## When a replica loses its connection with the master, or when the replication
## is still in progress, the replica can act in two different ways:
##
## 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will
## still reply to client requests, possibly with out of date data, or the
## data set may just be empty if this is the first synchronization.
##
## 2) If replica-serve-stale-data is set to 'no' the replica will reply with
## an error "SYNC with master in progress" to all commands except:
## INFO, REPLICAOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
## UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
## HOST and LATENCY.
##
replica-serve-stale-data yes
## BEGIN MEIZHAOHUI COMMENTS
## replica-serve-stale-data配置选项用于控制副本节点在没有可用的主节点时的行为。
## 当设置为yes时,副本会继续响应客户端请求,尽管它可能没有从主节点接收到最新的数据。
## 当设置为no时,除了指定的命令之外,副本会对所有请求返回错误"SYNC with master in progress"。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## You can configure a replica instance to accept writes or not. Writing against
## a replica instance may be useful to store some ephemeral data (because data
## written on a replica will be easily deleted after resync with the master) but
## may also cause problems if clients are writing to it because of a
## misconfiguration.
##
## Since Redis 2.6 by default replicas are read-only.
##
## Note: read only replicas are not designed to be exposed to untrusted clients
## on the internet. It's just a protection layer against misuse of the instance.
## Still a read only replica exports by default all the administrative commands
## such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
## security of read only replicas using 'rename-command' to shadow all the
## administrative / dangerous commands.
replica-read-only yes
## BEGIN MEIZHAOHUI COMMENTS
## 副本只读。
## END MEIZHAOHUI COMMENTS
## Replication SYNC strategy: disk or socket.
##
## New replicas and reconnecting replicas that are not able to continue the
## replication process just receiving differences, need to do what is called a
## "full synchronization". An RDB file is transmitted from the master to the
## replicas.
##
## The transmission can happen in two different ways:
##
## 1) Disk-backed: The Redis master creates a new process that writes the RDB
## file on disk. Later the file is transferred by the parent
## process to the replicas incrementally.
## 2) Diskless: The Redis master creates a new process that directly writes the
## RDB file to replica sockets, without touching the disk at all.
##
## With disk-backed replication, while the RDB file is generated, more replicas
## can be queued and served with the RDB file as soon as the current child
## producing the RDB file finishes its work. With diskless replication instead
## once the transfer starts, new replicas arriving will be queued and a new
## transfer will start when the current one terminates.
##
## When diskless replication is used, the master waits a configurable amount of
## time (in seconds) before starting the transfer in the hope that multiple
## replicas will arrive and the transfer can be parallelized.
##
## With slow disks and fast (large bandwidth) networks, diskless replication
## works better.
repl-diskless-sync no
## BEGIN MEIZHAOHUI COMMENTS
## 是否使用socket方式复制数据(无盘同步),新slave连接连接时候需要做数据的全量同步,
## redis server就要从内存dump出新的RDB文件,然后从master传到slave,有两种方式把RDB文件传输给客户端:
## 1) 基于硬盘(disk-backed):master创建一个新进程dump RDB,RDB完成之后由父进程(即主进程)传给slaves。
## 2) 基于socket(diskless): master创建一个新进程直接dump RDB到slave的socket,不经过主进程,不经过硬盘。
## 基于硬盘的话,RDB文件创建后,一旦创建完毕,可以同时服务更多的slave,
## 但是基于socket的话, 新slave连接到master之后得逐个同步数据。
## 在磁盘较慢并且网络较快的时候,可以用diskless(yes),否则使用磁盘(no)。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## When diskless replication is enabled, it is possible to configure the delay
## the server waits in order to spawn the child that transfers the RDB via socket
## to the replicas.
##
## This is important since once the transfer starts, it is not possible to serve
## new replicas arriving, that will be queued for the next RDB transfer, so the
## server waits a delay in order to let more replicas arrive.
##
## The delay is specified in seconds, and by default is 5 seconds. To disable
## it entirely just set it to 0 seconds and the transfer will start ASAP.
repl-diskless-sync-delay 5
## BEGIN MEIZHAOHUI COMMENTS
## diskless复制的延迟时间,设置0为关闭,在延迟时间内连接的新客户端,会一起通过disk方式同步数据,
## 但是一旦复制开始还没有结束之前,master节点不会再接收新slave的复制请求,直到下一次同步开始。
## 保持默认即可。
## repl-diskless-sync no 使用磁盘复制数据时,这个配置无用。
## END MEIZHAOHUI COMMENTS
## -----------------------------------------------------------------------------
## WARNING: RDB diskless load is experimental. Since in this setup the replica
## does not immediately store an RDB on disk, it may cause data loss during
## failovers. RDB diskless load + Redis modules not handling I/O reads may also
## cause Redis to abort in case of I/O errors during the initial synchronization
## stage with the master. Use only if you know what you are doing.
## -----------------------------------------------------------------------------
##
## Replica can load the RDB it reads from the replication link directly from the
## socket, or store the RDB to a file and read that file after it was completely
## received from the master.
##
## In many cases the disk is slower than the network, and storing and loading
## the RDB file may increase replication time (and even increase the master's
## Copy on Write memory and salve buffers).
## However, parsing the RDB file directly from the socket may mean that we have
## to flush the contents of the current database before the full rdb was
## received. For this reason we have the following options:
##
## "disabled" - Don't use diskless load (store the rdb file to the disk first)
## "on-empty-db" - Use diskless load only when it is completely safe.
## "swapdb" - Keep a copy of the current db contents in RAM while parsing
## the data directly from the socket. note that this requires
## sufficient memory, if you don't have it, you risk an OOM kill.
repl-diskless-load disabled
## BEGIN MEIZHAOHUI COMMENTS
## repl-diskless-load选项是用来控制无盘复制(diskless replication)功能的启用与否。
## 如果启用,则意味着当主服务器进行数据同步时,可以不将数据写入磁盘文件,而是通过网络直接发送给从服务器。
## 这可以提高数据同步的效率,减少磁盘I/O的开销。
## 默认不启用。保持默认即可。
## END MEIZHAOHUI COMMENTS
## Replicas send PINGs to server in a predefined interval. It's possible to
## change this interval with the repl_ping_replica_period option. The default
## value is 10 seconds.
##
## repl-ping-replica-period 10
## BEGIN MEIZHAOHUI COMMENTS
## 副本多长时间向向主节点发送一次PING请求
## 默认10秒。保持默认即可。
## END MEIZHAOHUI COMMENTS
## The following option sets the replication timeout for:
##
## 1) Bulk transfer I/O during SYNC, from the point of view of replica.
## 2) Master timeout from the point of view of replicas (data, pings).
## 3) Replica timeout from the point of view of masters (REPLCONF ACK pings).
##
## It is important to make sure that this value is greater than the value
## specified for repl-ping-replica-period otherwise a timeout will be detected
## every time there is low traffic between the master and the replica. The default
## value is 60 seconds.
##
## repl-timeout 60
## BEGIN MEIZHAOHUI COMMENTS
## 复制连接的超时时间,需要大于repl-ping-slave-period,否则会经常报超时。
## 默认60秒。保持默认即可。
## END MEIZHAOHUI COMMENTS
## Disable TCP_NODELAY on the replica socket after SYNC?
##
## If you select "yes" Redis will use a smaller number of TCP packets and
## less bandwidth to send data to replicas. But this can add a delay for
## the data to appear on the replica side, up to 40 milliseconds with
## Linux kernels using a default configuration.
##
## If you select "no" the delay for data to appear on the replica side will
## be reduced but more bandwidth will be used for replication.
##
## By default we optimize for low latency, but in very high traffic conditions
## or when the master and replicas are many hops away, turning this to "yes" may
## be a good idea.
repl-disable-tcp-nodelay no
## BEGIN MEIZHAOHUI COMMENTS
## 在socket模式下是否在slave套接字发送SYNC之后禁用 TCP_NODELAY。
## 由于不使用socket模式。保持默认即可。
## END MEIZHAOHUI COMMENTS
## Set the replication backlog size. The backlog is a buffer that accumulates
## replica data when replicas are disconnected for some time, so that when a
## replica wants to reconnect again, often a full resync is not needed, but a
## partial resync is enough, just passing the portion of data the replica
## missed while disconnected.
##
## The bigger the replication backlog, the longer the replica can endure the
## disconnect and later be able to perform a partial resynchronization.
##
## The backlog is only allocated if there is at least one replica connected.
##
## repl-backlog-size 1mb
## BEGIN MEIZHAOHUI COMMENTS
## 复制缓冲区内存大小,只有在slave连接之后才分配内存。
## 请注意,设置的repl-backlog-size值不能超过主服务器的可用内存。
## 在实际操作中,应当根据实际需求和服务器的内存容量来设置这个值。
## 如果复制延迟严重,可以考虑增加这个值。
## 如果主服务器数据变化不频繁,可以减少这个值来节省内存。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## After a master has no connected replicas for some time, the backlog will be
## freed. The following option configures the amount of seconds that need to
## elapse, starting from the time the last replica disconnected, for the backlog
## buffer to be freed.
##
## Note that replicas never free the backlog for timeout, since they may be
## promoted to masters later, and should be able to correctly "partially
## resynchronize" with other replicas: hence they should always accumulate backlog.
##
## A value of 0 means to never release the backlog.
##
## repl-backlog-ttl 3600
## BEGIN MEIZHAOHUI COMMENTS
## 多长时间master没有slave连接,就清空复制缓冲区内存。
## 默认3600秒。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
## The replica priority is an integer number published by Redis in the INFO
## output. It is used by Redis Sentinel in order to select a replica to promote
## into a master if the master is no longer working correctly.
##
## A replica with a low priority number is considered better for promotion, so
## for instance if there are three replicas with priority 10, 100, 25 Sentinel
## will pick the one with priority 10, that is the lowest.
##
## However a special priority of 0 marks the replica as not able to perform the
## role of master, so a replica with priority of 0 will never be selected by
## Redis Sentinel for promotion.
##
## By default the priority is 100.
replica-priority 100
## BEGIN MEIZHAOHUI COMMENTS
## 当master不可用,Sentinel会根据slave的优先级选举一个master,
## 最低的优先级的slave,当选master。
## 即值小的节点当前新的master。
## 而配置成0,永远不会被选举。
## 保持默认即可。
## 如果配置成哨兵模式,可以适当修改从节点的优先级值。
## END MEIZHAOHUI COMMENTS
## -----------------------------------------------------------------------------
## By default, Redis Sentinel includes all replicas in its reports. A replica
## can be excluded from Redis Sentinel's announcements. An unannounced replica
## will be ignored by the 'sentinel replicas <master>' command and won't be
## exposed to Redis Sentinel's clients.
##
## This option does not change the behavior of replica-priority. Even with
## replica-announced set to 'no', the replica can be promoted to master. To
## prevent this behavior, set replica-priority to 0.
##
## replica-announced yes
## BEGIN MEIZHAOHUI COMMENTS
## 默认情况下,Redis Sentinel 在其报告中包括所有副本。
## 副本可以从 Redis Sentinel 的公告中排除。
## 未公告的副本将被"sentinel replicas <master>"命令忽略,
## 并且不会暴露给 Redis Sentinel 的客户端。
##
## 保持默认即可。
## 此配置不会改变从节点的选举行为,即使replica-announced no ,这个节点也可以提升为主节点。
## 要禁止该节点提升为主节点,应配置replica-priority 0 不参入选举。
## END MEIZHAOHUI COMMENTS
## It is possible for a master to stop accepting writes if there are less than
## N replicas connected, having a lag less or equal than M seconds.
##
## The N replicas need to be in "online" state.
##
## The lag in seconds, that must be <= the specified value, is calculated from
## the last ping received from the replica, that is usually sent every second.
##
## This option does not GUARANTEE that N replicas will accept the write, but
## will limit the window of exposure for lost writes in case not enough replicas
## are available, to the specified number of seconds.
##
## For example to require at least 3 replicas with a lag <= 10 seconds use:
##
## min-replicas-to-write 3
## min-replicas-max-lag 10
##
## Setting one or the other to 0 disables the feature.
##
## By default min-replicas-to-write is set to 0 (feature disabled) and
## min-replicas-max-lag is set to 10.
## BEGIN MEIZHAOHUI COMMENTS
## 如果连接的副本少于 N 个,且延迟小于或等于 M 秒,则主服务器可能会停止接受写入。
## N 个副本需要处于"在线"状态。
## 延迟(以秒为单位),必须小于等于指定值,
## 是根据从副本收到的最后一个 ping 计算得出的,通常每秒发送一次。
## 至少有3个可连接的slave,master才接受写操作。
## 3个slave的ping延迟不能超过10秒,否则master也将停止写操作。
## 如果集群本来就只有3个节点,可以考虑减少min-replicas-to-write的值,
## 比如设置为1,这样即使只有一个副本,主节点也会进行数据持久化。
## 默认情况下,禁用了该特性。
## END MEIZHAOHUI COMMENTS
## A Redis master is able to list the address and port of the attached
## replicas in different ways. For example the "INFO replication" section
## offers this information, which is used, among other tools, by
## Redis Sentinel in order to discover replica instances.
## Another place where this info is available is in the output of the
## "ROLE" command of a master.
##
## The listed IP address and port normally reported by a replica is
## obtained in the following way:
##
## IP: The address is auto detected by checking the peer address
## of the socket used by the replica to connect with the master.
##
## Port: The port is communicated by the replica during the replication
## handshake, and is normally the port that the replica is using to
## listen for connections.
##
## However when port forwarding or Network Address Translation (NAT) is
## used, the replica may actually be reachable via different IP and port
## pairs. The following two options can be used by a replica in order to
## report to its master a specific set of IP and port, so that both INFO
## and ROLE will report those values.
##
## There is no need to use both the options if you need to override just
## the port or the IP address.
##
## replica-announce-ip 5.5.5.5
## replica-announce-port 1234
## BEGIN MEIZHAOHUI COMMENTS
## 配置通告的IP和端口信息,我们不单独设置。
## END MEIZHAOHUI COMMENTS
################################ KEYS TRACKING #################################
## Redis implements server assisted support for client side caching of values.
## This is implemented using an invalidation table that remembers, using
## a radix key indexed by key name, what clients have which keys. In turn
## this is used in order to send invalidation messages to clients. Please
## check this page to understand more about the feature:
##
## https://redis.io/topics/client-side-caching
##
## When tracking is enabled for a client, all the read only queries are assumed
## to be cached: this will force Redis to store information in the invalidation
## table. When keys are modified, such information is flushed away, and
## invalidation messages are sent to the clients. However if the workload is
## heavily dominated by reads, Redis could use more and more memory in order
## to track the keys fetched by many clients.
##
## For this reason it is possible to configure a maximum fill value for the
## invalidation table. By default it is set to 1M of keys, and once this limit
## is reached, Redis will start to evict keys in the invalidation table
## even if they were not modified, just to reclaim memory: this will in turn
## force the clients to invalidate the cached values. Basically the table
## maximum size is a trade off between the memory you want to spend server
## side to track information about who cached what, and the ability of clients
## to retain cached objects in memory.
##
## If you set the value to 0, it means there are no limits, and Redis will
## retain as many keys as needed in the invalidation table.
## In the "stats" INFO section, you can find information about the number of
## keys in the invalidation table at every given moment.
##
## Note: when key tracking is used in broadcasting mode, no memory is used
## in the server side so this setting is useless.
##
## tracking-table-max-keys 1000000
## BEGIN MEIZHAOHUI COMMENTS
## 配置追踪表(tracking table)的最大键数量的。
## 追踪表是Redis用来记录键空间通知事件的内存结构,这些事件可以是键的添加、删除或者过期等。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
################################### SECURITY ###################################
## Warning: since Redis is pretty fast, an outside user can try up to
## 1 million passwords per second against a modern box. This means that you
## should use very strong passwords, otherwise they will be very easy to break.
## Note that because the password is really a shared secret between the client
## and the server, and should not be memorized by any human, the password
## can be easily a long string from /dev/urandom or whatever, so by using a
## long and unguessable password no brute force attack will be possible.
## Redis ACL users are defined in the following format:
##
## user <username> ... acl rules ...
##
## For example:
##
## user worker +@list +@connection ~jobs:* on >ffa9203c493aa99
##
## The special username "default" is used for new connections. If this user
## has the "nopass" rule, then new connections will be immediately authenticated
## as the "default" user without the need of any password provided via the
## AUTH command. Otherwise if the "default" user is not flagged with "nopass"
## the connections will start in not authenticated state, and will require
## AUTH (or the HELLO command AUTH option) in order to be authenticated and
## start to work.
## BEGIN MEIZHAOHUI COMMENTS
## 警告:由于 Redis 速度非常快,外部用户每秒最多可以尝试 100 万个密码来破解现代机器。
## 这意味着您应该使用非常强的密码,否则它们将很容易被破解。
## 请注意,由于密码实际上是客户端和服务器之间的共享秘密,不应被任何人记住,
## 因此密码很容易是来自 /dev/urandom 或其他任何东西的长字符串,
## 因此通过使用长且不可猜测的密码,不可能进行暴力攻击。
## END MEIZHAOHUI COMMENTS
##
## The ACL rules that describe what a user can do are the following:
##
## on Enable the user: it is possible to authenticate as this user.
## off Disable the user: it's no longer possible to authenticate
## with this user, however the already authenticated connections
## will still work.
## skip-sanitize-payload RESTORE dump-payload sanitation is skipped.
## sanitize-payload RESTORE dump-payload is sanitized (default).
## +<command> Allow the execution of that command
## -<command> Disallow the execution of that command
## +@<category> Allow the execution of all the commands in such category
## with valid categories are like @admin, @set, @sortedset, ...
## and so forth, see the full list in the server.c file where
## the Redis command table is described and defined.
## The special category @all means all the commands, but currently
## present in the server, and that will be loaded in the future
## via modules.
## +<command>|subcommand Allow a specific subcommand of an otherwise
## disabled command. Note that this form is not
## allowed as negative like -DEBUG|SEGFAULT, but
## only additive starting with "+".
## allcommands Alias for +@all. Note that it implies the ability to execute
## all the future commands loaded via the modules system.
## nocommands Alias for -@all.
## ~<pattern> Add a pattern of keys that can be mentioned as part of
## commands. For instance ~* allows all the keys. The pattern
## is a glob-style pattern like the one of KEYS.
## It is possible to specify multiple patterns.
## allkeys Alias for ~*
## resetkeys Flush the list of allowed keys patterns.
## &<pattern> Add a glob-style pattern of Pub/Sub channels that can be
## accessed by the user. It is possible to specify multiple channel
## patterns.
## allchannels Alias for &*
## resetchannels Flush the list of allowed channel patterns.
## ><password> Add this password to the list of valid password for the user.
## For example >mypass will add "mypass" to the list.
## This directive clears the "nopass" flag (see later).
## <<password> Remove this password from the list of valid passwords.
## nopass All the set passwords of the user are removed, and the user
## is flagged as requiring no password: it means that every
## password will work against this user. If this directive is
## used for the default user, every new connection will be
## immediately authenticated with the default user without
## any explicit AUTH command required. Note that the "resetpass"
## directive will clear this condition.
## resetpass Flush the list of allowed passwords. Moreover removes the
## "nopass" status. After "resetpass" the user has no associated
## passwords and there is no way to authenticate without adding
## some password (or setting it as "nopass" later).
## reset Performs the following actions: resetpass, resetkeys, off,
## -@all. The user returns to the same state it has immediately
## after its creation.
##
## ACL rules can be specified in any order: for instance you can start with
## passwords, then flags, or key patterns. However note that the additive
## and subtractive rules will CHANGE MEANING depending on the ordering.
## For instance see the following example:
##
## user alice on +@all -DEBUG ~* >somepassword
##
## This will allow "alice" to use all the commands with the exception of the
## DEBUG command, since +@all added all the commands to the set of the commands
## alice can use, and later DEBUG was removed. However if we invert the order
## of two ACL rules the result will be different:
##
## user alice on -DEBUG +@all ~* >somepassword
##
## Now DEBUG was removed when alice had yet no commands in the set of allowed
## commands, later all the commands are added, so the user will be able to
## execute everything.
##
## Basically ACL rules are processed left-to-right.
##
## For more information about ACL configuration please refer to
## the Redis web site at https://redis.io/topics/acl
## ACL LOG
##
## The ACL Log tracks failed commands and authentication events associated
## with ACLs. The ACL Log is useful to troubleshoot failed commands blocked
## by ACLs. The ACL Log is stored in memory. You can reclaim memory with
## ACL LOG RESET. Define the maximum entry length of the ACL Log below.
acllog-max-len 128
## BEGIN MEIZHAOHUI COMMENTS
## acllog-max-len配置项用于设置ACL日志的最大长度。
## ACL日志记录了所有的访问控制列表(ACL)相关的命令执行历史。
## 当ACL日志记录数据超过了acllog-max-len配置的长度时,旧的记录会被移除。
## END MEIZHAOHUI COMMENTS
## Using an external ACL file
##
## Instead of configuring users here in this file, it is possible to use
## a stand-alone file just listing users. The two methods cannot be mixed:
## if you configure users here and at the same time you activate the external
## ACL file, the server will refuse to start.
##
## The format of the external ACL user file is exactly the same as the
## format that is used inside redis.conf to describe users.
##
## aclfile /etc/redis/users.acl
## BEGIN MEIZHAOHUI COMMENTS
## 使用外部 ACL 文件。aclfile配置用来设置外部ACL文件路径。
## 除了在此文件中配置用户之外,还可以使用# 仅列出用户的独立文件。
## 这两种方法不能混合使用:
## 如果您在此配置用户,同时激活外部ACL 文件,服务器将拒绝启动。
##
## 外部 ACL 用户文件的格式与 redis.conf 中用于描述用户的格式完全相同。
## 保持默认即可。不启动ACL文件。
## END MEIZHAOHUI COMMENTS
## IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
## layer on top of the new ACL system. The option effect will be just setting
## the password for the default user. Clients will still authenticate using
## AUTH <password> as usually, or more explicitly with AUTH default <password>
## if they follow the new protocol: both will work.
##
## The requirepass is not compatable with aclfile option and the ACL LOAD
## command, these will cause requirepass to be ignored.
##
## requirepass foobared
## BEGIN MEIZHAOHUI COMMENTS
## 重要提示:从 Redis 6 开始,"requirepass"只是新 ACL 系统之上的兼容层。
## 该选项的效果只是设置默认用户的密码。
## 客户端仍将像往常一样使用 AUTH <password> 进行身份验证,
## 或者更明确地使用 AUTH default <password> 进行身份验证,
## 如果它们遵循新协议:两者都可以工作。
##
## requirepass 与 aclfile 选项和 ACL LOAD 命令不兼容,
## 这些将导致 requirepass 被忽略。
##
## 请注意,出于安全考虑,应确保密码足够复杂,并在生产环境中使用复杂的安全措施来保护密码。
## END MEIZHAOHUI COMMENTS
requirepass ALONGPASSWORD
## New users are initialized with restrictive permissions by default, via the
## equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it
## is possible to manage access to Pub/Sub channels with ACL rules as well. The
## default Pub/Sub channels permission if new users is controlled by the
## acl-pubsub-default configuration directive, which accepts one of these values:
##
## allchannels: grants access to all Pub/Sub channels
## resetchannels: revokes access to all Pub/Sub channels
##
## To ensure backward compatibility while upgrading Redis 6.0, acl-pubsub-default
## defaults to the 'allchannels' permission.
##
## Future compatibility note: it is very likely that in a future version of Redis
## the directive's default of 'allchannels' will be changed to 'resetchannels' in
## order to provide better out-of-the-box Pub/Sub security. Therefore, it is
## recommended that you explicitly define Pub/Sub permissions for all users
## rather then rely on implicit default values. Once you've set explicit
## Pub/Sub for all existing users, you should uncomment the following line.
##
## acl-pubsub-default resetchannels
## Command renaming (DEPRECATED).
##
## ------------------------------------------------------------------------
## WARNING: avoid using this option if possible. Instead use ACLs to remove
## commands from the default user, and put them only in some admin user you
## create for administrative purposes.
## ------------------------------------------------------------------------
##
## It is possible to change the name of dangerous commands in a shared
## environment. For instance the CONFIG command may be renamed into something
## hard to guess so that it will still be available for internal-use tools
## but not available for general clients.
##
## BEGIN MEIZHAOHUI COMMENTS
## 可以在共享环境中更改危险命令的名称,暂时不设置。
## END MEIZHAOHUI COMMENTS
## Example:
##
## rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
##
## It is also possible to completely kill a command by renaming it into
## an empty string:
##
## rename-command CONFIG ""
##
## Please note that changing the name of commands that are logged into the
## AOF file or transmitted to replicas may cause problems.
#################################### CLIENTS ####################################
## Set the max number of connected clients at the same time. By default
## this limit is set to 10000 clients, however if the Redis server is not
## able to configure the process file limit to allow for the specified limit
## the max number of allowed clients is set to the current file limit
## minus 32 (as Redis reserves a few file descriptors for internal uses).
##
## Once the limit is reached Redis will close all the new connections sending
## an error 'max number of clients reached'.
##
## IMPORTANT: When Redis Cluster is used, the max number of connections is also
## shared with the cluster bus: every node in the cluster will use two
## connections, one incoming and another outgoing. It is important to size the
## limit accordingly in case of very large clusters.
##
## maxclients 10000
## BEGIN MEIZHAOHUI COMMENTS
## 设置同时连接的最大客户端数量。
## 默认情况下,此限制设置为 10000 个客户端。
## 但是如果 Redis 服务器无法配置进程文件限制以允许指定的限制,
## 则允许的最大客户端数量将设置为当前文件限制减 32(因为 Redis 保留了一些文件描述符供内部使用)。
##
## 一旦达到限制,Redis 将关闭所有新连接并发送错误"已达到最大客户端数量"。
##
## 重要提示:使用 Redis 集群时,最大连接数也与集群总线共享:
## 集群中的每个节点都将使用两个连接,一个传入,另一个传出。
## 如果集群非常大,则必须相应地调整限制的大小。
## 我们不单独设置。
## END MEIZHAOHUI COMMENTS
############################### MEMORY MANAGEMENT ################################
## Set a memory usage limit to the specified amount of bytes.
## When the memory limit is reached Redis will try to remove keys
## according to the eviction policy selected (see maxmemory-policy).
##
## If Redis can't remove keys according to the policy, or if the policy is
## set to 'noeviction', Redis will start to reply with errors to commands
## that would use more memory, like SET, LPUSH, and so on, and will continue
## to reply to read-only commands like GET.
##
## This option is usually useful when using Redis as an LRU or LFU cache, or to
## set a hard memory limit for an instance (using the 'noeviction' policy).
##
## WARNING: If you have replicas attached to an instance with maxmemory on,
## the size of the output buffers needed to feed the replicas are subtracted
## from the used memory count, so that network problems / resyncs will
## not trigger a loop where keys are evicted, and in turn the output
## buffer of replicas is full with DELs of keys evicted triggering the deletion
## of more keys, and so forth until the database is completely emptied.
##
## In short... if you have replicas attached it is suggested that you set a lower
## limit for maxmemory so that there is some free RAM on the system for replica
## output buffers (but this is not needed if the policy is 'noeviction').
##
## maxmemory <bytes>
## BEGIN MEIZHAOHUI COMMENTS
## 将内存使用限制设置为指定的字节数。
## 当达到内存限制时,Redis 将尝试根据所选的驱逐策略删除键(请参阅 maxmemory-policy)。
##
## 如果 Redis 无法根据策略删除键,或者策略设置为"noeviction",
## Redis 将开始以错误回复将使用更多内存的命令,例如 SET、LPUSH 等,并将继续回复只读命令,例如 GET。
##
## 此选项通常在将 Redis 用作 LRU 或 LFU 缓存时有用,或者在为实例设置硬内存限制时很有用(使用"noeviction"策略)。
##
## 警告:如果您将副本附加到启用了 maxmemory 的实例,
## 将从已用内存计数中减去提供副本所需的输出缓冲区大小,这样网络问题/重新同步就不会触发循环,导致键被逐出,
## 反过来,副本的输出缓冲区已满,被逐出的键的 DEL 触发了更多键的删除,依此类推,直到数据库完全清空。
##
## 简而言之……如果您附加了副本,建议您为 maxmemory 设置一个较低的限制,
## 以便系统上有一些可用于副本输出缓冲区的可用 RAM(但如果策略为"noeviction",则不需要这样做)。
## END MEIZHAOHUI COMMENTS
maxmemory 1gb
## MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
## is reached. You can select one from the following behaviors:
##
## volatile-lru -> Evict using approximated LRU, only keys with an expire set.
## allkeys-lru -> Evict any key using approximated LRU.
## volatile-lfu -> Evict using approximated LFU, only keys with an expire set.
## allkeys-lfu -> Evict any key using approximated LFU.
## volatile-random -> Remove a random key having an expire set.
## allkeys-random -> Remove a random key, any key.
## volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
## noeviction -> Don't evict anything, just return an error on write operations.
##
## LRU means Least Recently Used
## LFU means Least Frequently Used
##
## Both LRU, LFU and volatile-ttl are implemented using approximated
## randomized algorithms.
##
## Note: with any of the above policies, when there are no suitable keys for
## eviction, Redis will return an error on write operations that require
## more memory. These are usually commands that create new keys, add data or
## modify existing keys. A few examples are: SET, INCR, HSET, LPUSH, SUNIONSTORE,
## SORT (due to the STORE argument), and EXEC (if the transaction includes any
## command that requires memory).
##
## The default is:
##
## maxmemory-policy noeviction
## BEGIN MEIZHAOHUI COMMENTS
## MAXMEMORY POLICY:达到 maxmemory 时,Redis 将如何选择要删除的内容。您可以从以下行为中选择一个:
##
## volatile-lru -> 使用近似 LRU 驱逐,仅驱逐设置了过期时间的键。
## allkeys-lru -> 使用近似 LRU 驱逐任何键。
## volatile-lfu -> 使用近似 LFU 驱逐,仅驱逐设置了过期时间的键。
## allkeys-lfu -> 使用近似 LFU 驱逐任何键。
## volatile-random -> 删除设置了过期时间的随机键。
## allkeys-random -> 删除随机键,任何键。
## volatile-ttl -> 删除具有最近过期时间(次要 TTL)的键
## noeviction -> 不驱逐任何内容,仅在写入操作时返回错误。
##
## LRU 表示最近最少使用
## LFU 表示最不频繁使用
##
## LRU、LFU 和 volatile-ttl 都是使用近似随机算法实现的。
##
## 注意:对于上述任何一种策略,当没有适合驱逐的键时,Redis 将在需要更多内存的写入操作上返回错误。
## 这些通常是创建新键、添加数据或修改现有键的命令。
## 一些示例是:SET、INCR、HSET、LPUSH、SUNIONSTORE、SORT(由于 STORE 参数)和 EXEC(如果事务包含任何需要内存的命令)。
## 默认是 maxmemory-policy noeviction, 即不驱逐任何内容,仅在写入操作时返回错误。
## END MEIZHAOHUI COMMENTS
## LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
## algorithms (in order to save memory), so you can tune it for speed or
## accuracy. By default Redis will check five keys and pick the one that was
## used least recently, you can change the sample size using the following
## configuration directive.
##
## The default of 5 produces good enough results. 10 Approximates very closely
## true LRU but costs more CPU. 3 is faster but not very accurate.
##
## maxmemory-samples 5
## BEGIN MEIZHAOHUI COMMENTS
## LRU、LFU 和最小 TTL 算法不是精确算法,而是近似算法(为了节省内存),
## 因此您可以调整速度或准确性。
## 默认情况下,Redis 将检查五个键并选择最近使用最少的键,您可以使用以下配置指令更改样本大小。
##
## 默认值 5 产生足够好的结果。10 非常接近真正的 LRU,但消耗更多 CPU。3 更快但不太准确。
## 因为未启用驱逐算法,此配置无作用。
## 我们保持默认 maxmemory-samples 5 即可。
## END MEIZHAOHUI COMMENTS
## Eviction processing is designed to function well with the default setting.
## If there is an unusually large amount of write traffic, this value may need to
## be increased. Decreasing this value may reduce latency at the risk of
## eviction processing effectiveness
## 0 = minimum latency, 10 = default, 100 = process without regard to latency
##
## maxmemory-eviction-tenacity 10
## BEGIN MEIZHAOHUI COMMENTS
## 设置移除容忍度。
## 数值越小表示容忍度越低,需要移除的数据移除延迟越小;
## 数值越大表示容忍度越高,需要移除的数据移除延迟越大。
## 如果写入流量异常大,则可能需要增加此值。
## 降低此值可能会降低延迟,但可能会降低驱逐处理效率
## 0 = 最小延迟,10 = 默认值,100 = 不考虑延迟的处理。
## END MEIZHAOHUI COMMENTS
## Starting from Redis 5, by default a replica will ignore its maxmemory setting
## (unless it is promoted to master after a failover or manually). It means
## that the eviction of keys will be just handled by the master, sending the
## DEL commands to the replica as keys evict in the master side.
##
## This behavior ensures that masters and replicas stay consistent, and is usually
## what you want, however if your replica is writable, or you want the replica
## to have a different memory setting, and you are sure all the writes performed
## to the replica are idempotent, then you may change this default (but be sure
## to understand what you are doing).
##
## Note that since the replica by default does not evict, it may end using more
## memory than the one set via maxmemory (there are certain buffers that may
## be larger on the replica, or data structures may sometimes take more memory
## and so forth). So make sure you monitor your replicas and make sure they
## have enough memory to never hit a real out-of-memory condition before the
## master hits the configured maxmemory setting.
##
## replica-ignore-maxmemory yes
## BEGIN MEIZHAOHUI COMMENTS
## replica-ignore-maxmemor用于控制 Redis 副本(replica)在达到 maxmemory 限制时的行为。
## 当 replica-ignore-maxmemory 设置为 yes 时,副本会忽略 maxmemory 设置,
## 并允许内存持续增长超过 maxmemory 指定的限制。
## 这可能会导致副本的内存使用超过主服务器,并可能导致不一致的数据状态。
##
## 通常,这个选项应当设置为 no,以确保副本服务器的内存使用保持在安全的范围内。
## END MEIZHAOHUI COMMENTS
## Redis reclaims expired keys in two ways: upon access when those keys are
## found to be expired, and also in background, in what is called the
## "active expire key". The key space is slowly and interactively scanned
## looking for expired keys to reclaim, so that it is possible to free memory
## of keys that are expired and will never be accessed again in a short time.
##
## The default effort of the expire cycle will try to avoid having more than
## ten percent of expired keys still in memory, and will try to avoid consuming
## more than 25% of total memory and to add latency to the system. However
## it is possible to increase the expire "effort" that is normally set to
## "1", to a greater value, up to the value "10". At its maximum value the
## system will use more CPU, longer cycles (and technically may introduce
## more latency), and will tolerate less already expired keys still present
## in the system. It's a tradeoff between memory, CPU and latency.
##
## active-expire-effort 1
## BEGIN MEIZHAOHUI COMMENTS
## active-expire-effort 配置指的是对过期键进行处理的活跃性工作量。
## 这个配置影响了Redis如何平衡CPU时间来处理过期键和其他任务,如持久化和命令处理。
## 值从1-10,值越大,占用CPU资源越多。
## END MEIZHAOHUI COMMENTS
############################## LAZY FREEING ####################################
## Redis has two primitives to delete keys. One is called DEL and is a blocking
## deletion of the object. It means that the server stops processing new commands
## in order to reclaim all the memory associated with an object in a synchronous
## way. If the key deleted is associated with a small object, the time needed
## in order to execute the DEL command is very small and comparable to most other
## O(1) or O(log_N) commands in Redis. However if the key is associated with an
## aggregated value containing millions of elements, the server can block for
## a long time (even seconds) in order to complete the operation.
##
## For the above reasons Redis also offers non blocking deletion primitives
## such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
## FLUSHDB commands, in order to reclaim memory in background. Those commands
## are executed in constant time. Another thread will incrementally free the
## object in the background as fast as possible.
##
## DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
## It's up to the design of the application to understand when it is a good
## idea to use one or the other. However the Redis server sometimes has to
## delete keys or flush the whole database as a side effect of other operations.
## Specifically Redis deletes objects independently of a user call in the
## following scenarios:
##
## 1) On eviction, because of the maxmemory and maxmemory policy configurations,
## in order to make room for new data, without going over the specified
## memory limit.
## 2) Because of expire: when a key with an associated time to live (see the
## EXPIRE command) must be deleted from memory.
## 3) Because of a side effect of a command that stores data on a key that may
## already exist. For example the RENAME command may delete the old key
## content when it is replaced with another one. Similarly SUNIONSTORE
## or SORT with STORE option may delete existing keys. The SET command
## itself removes any old content of the specified key in order to replace
## it with the specified string.
## 4) During replication, when a replica performs a full resynchronization with
## its master, the content of the whole database is removed in order to
## load the RDB file just transferred.
##
## In all the above cases the default is to delete objects in a blocking way,
## like if DEL was called. However you can configure each case specifically
## in order to instead release memory in a non-blocking way like if UNLINK
## was called, using the following configuration directives.
## BEGIN MEIZHAOHUI COMMENTS
## Redis有两个命令用于删除键。一个称为DEL,是对对象的阻塞删除。
## 这意味着服务器停止处理新命令,以便以同步方式回收与对象关联的所有内存。
## 如果删除的键与一个小对象相关联,则执行DEL命令所需的时间非常短,
## 与Redis中的大多数其他O(1)或O(log_N)命令相当。但是,
## 如果key与包含数百万个元素的聚合值关联,则服务器可以阻塞很长时间(甚至几秒钟)以完成操作。
##
## 出于上述原因,Redis还提供了UNLINK(non-blocking DEL)等非阻塞删除命令
## 以及FLUSHALL和FLUSHDB命令的异步选项,以便在后台回收内存。
## 这些命令在固定时间内执行。另一个线程将尽可能在后台释放对象。
##
## FLUSHALL和FLUSHDB的DEL、UNLINK和ASYNC选项由用户控制。
## 这取决于应用程序的设计,所以了解何时使用一个或另一个是一个好主意。
## 然而,Redis服务器有时不得不删除keys或刷新整个数据库,这是其他操作的副作用。
## 具体来说,在以下情况下,Redis独立于用户调用删除对象:
## 1.在逐出时,由于maxmemory和maxmemory策略配置,为了在不超过指定内存限制的情况下为新数据腾出空间
## 2.因为过期:必须从内存中删除具有相关生存时间的key
## 3.因为将数据存储在可能已经存在的keys上的命令的副作用。
## 例如,当旧的keys内容被另一个keys内容替换时,RENAME命令可能会删除它。
## 类似地,SUNIONSTORE或SORT with STORE选项可以删除现有keys。
## SET命令本身删除指定键的任何旧内容,以便用指定字符串替换它。
## 4.在复制过程中,当复制副本与其主服务器执行完全重新同步时,将删除整个数据库的内容,以便加载刚刚传输的RDB文件。
## END MEIZHAOHUI COMMENTS
lazyfree-lazy-eviction no
## BEGIN MEIZHAOHUI COMMENTS
## 当 redis 内存达到阈值 maxmemory 时,是否开启异步惰性淘汰,
## 开启的话,可能使用淘汰键的内存释放不及时,导致redis内存超用,超过maxmemory的限制不建议开启。
## END MEIZHAOHUI COMMENTS
lazyfree-lazy-expire no
## BEGIN MEIZHAOHUI COMMENTS
## 针对设置有TTL的键,达到过期后,被redis清理删除时是否采用lazy free机制。
## 没特殊要求的话,保持默认不开启。
## END MEIZHAOHUI COMMENTS
lazyfree-lazy-server-del no
## BEGIN MEIZHAOHUI COMMENTS
## 执行DEL命令时,是否异步执行删除操作。
## 没特殊要求的话,保持默认不开启。
## END MEIZHAOHUI COMMENTS
replica-lazy-flush no
## BEGIN MEIZHAOHUI COMMENTS
## 主要用于复制过程中,全量同步的场景,从节点是否异步删除整个db。
## 没特殊要求的话,保持默认不开启。
## END MEIZHAOHUI COMMENTS
## It is also possible, for the case when to replace the user code DEL calls
## with UNLINK calls is not easy, to modify the default behavior of the DEL
## command to act exactly like UNLINK, using the following configuration
## directive:
## BEGIN MEIZHAOHUI COMMENTS
## 将代码中的del替换成unlink可能不是那么太容易,所以为了让del
## 命令的实际效果等价于unlink,
## 你可以修改配置文件为lazyfree-lazy-user-del yes
## END MEIZHAOHUI COMMENTS
lazyfree-lazy-user-del no
## FLUSHDB, FLUSHALL, and SCRIPT FLUSH support both asynchronous and synchronous
## deletion, which can be controlled by passing the [SYNC|ASYNC] flags into the
## commands. When neither flag is passed, this directive will be used to determine
## if the data should be deleted asynchronously.
## BEGIN MEIZHAOHUI COMMENTS
## FLUSHDB、FLUSHALL 和 SCRIPT FLUSH 支持异步和同步
## 删除,可通过将 [SYNC|ASYNC] 标志传递到命令中来控制。
## 当未传递任何标志时,此指令将用于确定是否应异步删除数据。
## 保持默认不启用异步删除。
## END MEIZHAOHUI COMMENTS
lazyfree-lazy-user-flush no
################################# THREADED I/O #################################
## Redis is mostly single threaded, however there are certain threaded
## operations such as UNLINK, slow I/O accesses and other things that are
## performed on side threads.
##
## Now it is also possible to handle Redis clients socket reads and writes
## in different I/O threads. Since especially writing is so slow, normally
## Redis users use pipelining in order to speed up the Redis performances per
## core, and spawn multiple instances in order to scale more. Using I/O
## threads it is possible to easily speedup two times Redis without resorting
## to pipelining nor sharding of the instance.
##
## By default threading is disabled, we suggest enabling it only in machines
## that have at least 4 or more cores, leaving at least one spare core.
## Using more than 8 threads is unlikely to help much. We also recommend using
## threaded I/O only if you actually have performance problems, with Redis
## instances being able to use a quite big percentage of CPU time, otherwise
## there is no point in using this feature.
##
## So for instance if you have a four cores boxes, try to use 2 or 3 I/O
## threads, if you have a 8 cores, try to use 6 threads. In order to
## enable I/O threads use the following configuration directive:
##
## io-threads 4
## BEGIN MEIZHAOHUI COMMENTS
## 官方表示,当使用redis时有性能瓶颈时,才推荐开启该功能,但是消耗更多的cpu时间。
## 并且,开启i/o多线程,至少要是4核以上的cpu,
## 并且需要预留一个空闲cpu。
## 比如4核就配io-threads=2,
## 8核至多配io-threads=6。
## 对于4核以上的机器,官方更推荐配置io-threads=4,
## 因为再往上叠加,收益相对较低了,也没有太大必要。
## END MEIZHAOHUI COMMENTS
##
## Setting io-threads to 1 will just use the main thread as usual.
## When I/O threads are enabled, we only use threads for writes, that is
## to thread the write(2) syscall and transfer the client buffers to the
## socket. However it is also possible to enable threading of reads and
## protocol parsing using the following configuration directive, by setting
## it to yes:
## io-threads-do-reads no
## BEGIN MEIZHAOHUI COMMENTS
## io-threads-do-reads配置默认no。
## i/o多线程默认是的是写socket多线程,socket连接本身就是epoll多路复用模式,
## 理解下来开启此配置对性能不太有提升空间。
## END MEIZHAOHUI COMMENTS
##
## Usually threading reads doesn't help much.
##
## NOTE 1: This configuration directive cannot be changed at runtime via
## CONFIG SET. Aso this feature currently does not work when SSL is
## enabled.
##
## NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
## sure you also run the benchmark itself in threaded mode, using the
## --threads option to match the number of Redis threads, otherwise you'll not
## be able to notice the improvements.
############################# KERNEL OOM CONTROL ##############################
## On Linux, it is possible to hint the kernel OOM killer on what processes
## should be killed first when out of memory.
##
## Enabling this feature makes Redis actively control the oom_score_adj value
## for all its processes, depending on their role. The default scores will
## attempt to have background child processes killed before all others, and
## replicas killed before masters.
##
## Redis supports three options:
##
## no: Don't make changes to oom-score-adj (default).
## yes: Alias to "relative" see below.
## absolute: Values in oom-score-adj-values are written as is to the kernel.
## relative: Values are used relative to the initial value of oom_score_adj when
## the server starts and are then clamped to a range of -1000 to 1000.
## Because typically the initial value is 0, they will often match the
## absolute values.
oom-score-adj no
## BEGIN MEIZHAOHUI COMMENTS
## 在 Linux 上,可以提示内核 OOM 终止程序在内存不足时应首先终止哪些进程。
## oom-score-adj 参数用于设置 Redis 进程在内存不足时被系统杀死的可能性。
## 保持默认不开启。
## END MEIZHAOHUI COMMENTS
## When oom-score-adj is used, this directive controls the specific values used
## for master, replica and background child processes. Values range -2000 to
## 2000 (higher means more likely to be killed).
##
## Unprivileged processes (not root, and without CAP_SYS_RESOURCE capabilities)
## can freely increase their value, but not decrease it below its initial
## settings. This means that setting oom-score-adj to "relative" and setting the
## oom-score-adj-values to positive values will always succeed.
oom-score-adj-values 0 200 800
## BEGIN MEIZHAOHUI COMMENTS
## oom-score-adj 配置未开启,此配置无效。
## END MEIZHAOHUI COMMENTS
##################### KERNEL transparent hugepage CONTROL ######################
## Usually the kernel Transparent Huge Pages control is set to "madvise" or
## or "never" by default (/sys/kernel/mm/transparent_hugepage/enabled), in which
## case this config has no effect. On systems in which it is set to "always",
## redis will attempt to disable it specifically for the redis process in order
## to avoid latency problems specifically with fork(2) and CoW.
## If for some reason you prefer to keep it enabled, you can set this config to
## "no" and the kernel global to "always".
disable-thp yes
## BEGIN MEIZHAOHUI COMMENTS
## disable-thp 配置项是用来控制是否禁用Transparent Huge Pages (THP)特性的。
## THP透明大页是Linux系统中用于支持大页面的一个特性,它可以提高内存的使用效率,
## 但也可能对一些需要低延迟的应用程序造成影响,因为它会破坏内存的局部性。
## cat /sys/kernel/mm/transparent_hugepage/enabled
## [always] madvise never <------- 这种是透明大页开启状态
## cat /sys/kernel/mm/transparent_hugepage/enabled
## always madvise [never] <------- 这种是透明大页关闭状态
## END MEIZHAOHUI COMMENTS
############################### APPEND ONLY MODE ###############################
## By default Redis asynchronously dumps the dataset on disk. This mode is
## good enough in many applications, but an issue with the Redis process or
## a power outage may result into a few minutes of writes lost (depending on
## the configured save points).
##
## The Append Only File is an alternative persistence mode that provides
## much better durability. For instance using the default data fsync policy
## (see later in the config file) Redis can lose just one second of writes in a
## dramatic event like a server power outage, or a single write if something
## wrong with the Redis process itself happens, but the operating system is
## still running correctly.
##
## AOF and RDB persistence can be enabled at the same time without problems.
## If the AOF is enabled on startup Redis will load the AOF, that is the file
## with the better durability guarantees.
##
## Please check https://redis.io/topics/persistence for more information.
## BEGIN MEIZHAOHUI COMMENTS
## 默认情况下,Redis 会异步将数据集转储到磁盘上。
## 此模式在许多应用程序中都足够好,但 Redis 进程出现问题或断电可能会导致几分钟的写入丢失(取决于配置的保存点)。
##
## 这种只增文件是可选的能够提供更好的体验的数据持久化策略。
## Redis 可能会在服务器断电等重大事件中丢失一秒钟的写入,
## 或者如果 Redis 进程本身出现问题,但操作系统仍在正常运行,则只会丢失一次写入。
## 可以同时启用 AOF 和 RDB 持久性而不会出现问题。
## 如果在启动时启用了 AOF,Redis 将加载 AOF,即具有更好耐用性保证的文件。
## END MEIZHAOHUI COMMENTS
## appendonly no
appendonly yes
## BEGIN MEIZHAOHUI COMMENTS
## 默认 appendonly no 表示未开启AOF只增文件模式。
## 为了让我们Redis在异常时数据丢失更少,开启该参数,
## 设置appendonly yes 打开 AOF持久化。
## END MEIZHAOHUI COMMENTS
## The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"
## BEGIN MEIZHAOHUI COMMENTS
## AOF持久化文件名
## END MEIZHAOHUI COMMENTS
## The fsync() call tells the Operating System to actually write data on disk
## instead of waiting for more data in the output buffer. Some OS will really flush
## data on disk, some other OS will just try to do it ASAP.
##
## Redis supports three different modes:
##
## no: don't fsync, just let the OS flush the data when it wants. Faster.
## always: fsync after every write to the append only log. Slow, Safest.
## everysec: fsync only one time every second. Compromise.
##
## The default is "everysec", as that's usually the right compromise between
## speed and data safety. It's up to you to understand if you can relax this to
## "no" that will let the operating system flush the output buffer when
## it wants, for better performances (but if you can live with the idea of
## some data loss consider the default persistence mode that's snapshotting),
## or on the contrary, use "always" that's very slow but a bit safer than
## everysec.
##
## More details please check the following article:
## http://antirez.com/post/redis-persistence-demystified.html
##
## If unsure, use "everysec".
## BEGIN MEIZHAOHUI COMMENTS
## fsync() 调用会告知操作系统实际将数据写入磁盘,
## 而不是等待输出缓冲区中出现更多数据。有些操作系统会真正刷新磁盘上的数据,
## 而有些操作系统则会尝试尽快执行此操作。
## Redis 支持三种不同的模式:
##
## no:不进行 fsync,只让操作系统在需要时刷新数据。速度更快。
## always:每次写入仅附加日志后进行 fsync。速度慢,最安全。
## everysec:每秒仅进行一次 fsync。折衷。
## 默认值为“everysec”,因为这通常是速度和数据安全性之间的正确折衷。
##
## 我们使用默认值 appendfsync everysec 每秒写入一次。
## END MEIZHAOHUI COMMENTS
## appendfsync always
appendfsync everysec
## appendfsync no
## When the AOF fsync policy is set to always or everysec, and a background
## saving process (a background save or AOF log background rewriting) is
## performing a lot of I/O against the disk, in some Linux configurations
## Redis may block too long on the fsync() call. Note that there is no fix for
## this currently, as even performing fsync in a different thread will block
## our synchronous write(2) call.
##
## In order to mitigate this problem it's possible to use the following option
## that will prevent fsync() from being called in the main process while a
## BGSAVE or BGREWRITEAOF is in progress.
##
## This means that while another child is saving, the durability of Redis is
## the same as "appendfsync none". In practical terms, this means that it is
## possible to lose up to 30 seconds of log in the worst scenario (with the
## default Linux settings).
##
## If you have latency problems turn this to "yes". Otherwise leave it as
## "no" that is the safest pick from the point of view of durability.
## BEGIN MEIZHAOHUI COMMENTS
## bgrewriteaof机制,在一个子进程中进行aof的重写,
## 从而不阻塞主进程对其余命令的处理,同时解决了aof文件过大问题。
## 现在问题出现了,同时在执行bgrewriteaof操作和主进程写aof文件的操作,
## 两者都会操作磁盘,而bgrewriteaof往往会涉及大量磁盘操作,
## 这样就会造成主进程在写aof文件的时候出现阻塞的情形,
## 现在no-appendfsync-on-rewrite参数出场了。
## 如果该参数设置为no,是最安全的方式,不会丢失数据,但是要忍受阻塞的问题。
## 如果设置为yes呢?这就相当于将appendfsync设置为no,这说明并没有执行磁盘操作,
## 只是写入了缓冲区,因此这样并不会造成阻塞(因为没有竞争磁盘),
## 但是如果这个时候redis挂掉,就会丢失数据。丢失多少数据呢?
## 在linux的操作系统的默认设置下,最多会丢失30s的数据。
## 因此,如果应用系统无法忍受延迟,而可以容忍少量的数据丢失,则设置为yes。
## 如果应用系统无法忍受数据丢失,则设置为no。
## END MEIZHAOHUI COMMENTS
no-appendfsync-on-rewrite no
## Automatic rewrite of the append only file.
## Redis is able to automatically rewrite the log file implicitly calling
## BGREWRITEAOF when the AOF log size grows by the specified percentage.
##
## This is how it works: Redis remembers the size of the AOF file after the
## latest rewrite (if no rewrite has happened since the restart, the size of
## the AOF at startup is used).
##
## This base size is compared to the current size. If the current size is
## bigger than the specified percentage, the rewrite is triggered. Also
## you need to specify a minimal size for the AOF file to be rewritten, this
## is useful to avoid rewriting the AOF file even if the percentage increase
## is reached but it is still pretty small.
##
## Specify a percentage of zero in order to disable the automatic AOF
## rewrite feature.
## BEGIN MEIZHAOHUI COMMENTS
## auto-aof-rewrite-percentage,设置触发 AOF 重写的百分比,一般建议设置为 100% 。
## 当 AOF 文件体积增长超过上次 AOF 重写的体积的指定百分比时,
## Redis 会自动触发一个新的 AOF 重写操作。
## auto-aof-rewrite-min-size 设置最小 AOF 文件大小,一般建议设置为 64mb。
## END MEIZHAOHUI COMMENTS
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
## An AOF file may be found to be truncated at the end during the Redis
## startup process, when the AOF data gets loaded back into memory.
## This may happen when the system where Redis is running
## crashes, especially when an ext4 filesystem is mounted without the
## data=ordered option (however this can't happen when Redis itself
## crashes or aborts but the operating system still works correctly).
##
## Redis can either exit with an error when this happens, or load as much
## data as possible (the default now) and start if the AOF file is found
## to be truncated at the end. The following option controls this behavior.
##
## If aof-load-truncated is set to yes, a truncated AOF file is loaded and
## the Redis server starts emitting a log to inform the user of the event.
## Otherwise if the option is set to no, the server aborts with an error
## and refuses to start. When the option is set to no, the user requires
## to fix the AOF file using the "redis-check-aof" utility before to restart
## the server.
##
## Note that if the AOF file will be found to be corrupted in the middle
## the server will still exit with an error. This option only applies when
## Redis will try to read more data from the AOF file but not enough bytes
## will be found.
## BEGIN MEIZHAOHUI COMMENTS
## aof文件可能在尾部是不完整的,当redis启动的时候,aof文件的数据被载入内存。
## 重启可能发生在redis所在的主机操作系统宕机后,尤其在ext4文件系统没有加上data=ordered选项会出现这种现象。
## redis宕机或者异常终止不会造成尾部不完整现象,可以选择让redis退出,
## 或者导入尽可能多的数据。如果选择的是yes,当截断的aof文件被导入的时候,
## 会自动发布一个log给客户端然后load。
## 如果是no,用户必须手动redis-check-aof修复AOF文件才可以。
## END MEIZHAOHUI COMMENTS
aof-load-truncated yes
## When rewriting the AOF file, Redis is able to use an RDB preamble in the
## AOF file for faster rewrites and recoveries. When this option is turned
## on the rewritten AOF file is composed of two different stanzas:
##
## [RDB file][AOF tail]
##
## When loading, Redis recognizes that the AOF file starts with the "REDIS"
## string and loads the prefixed RDB file, then continues loading the AOF
## tail.
## BEGIN MEIZHAOHUI COMMENTS
## 在Redis4.0之后,新增了RDB-AOF混合持久化方式。这种方式结合了RDB和AOF的优点,既能快速加载又能避免丢失过多的数据。
## 具体配置为:aof-use-rdb-preamble: 设置为yes表示开启,设置为no表示禁用。
## 当开启混合持久化时,主进程先fork出子进程将现有内存副本全量以RDB方式写入aof文件中,
## 然后将缓冲区中的增量命令以AOF方式写入aof文件中,
## 写入完成后通知主进程更新相关信息,并将新的含有 RDB和AOF两种格式的aof文件替换旧的aof文件。
## 简单来说:混合持久化方式产生的文件一部分是RDB格式,一部分是AOF格式。
## END MEIZHAOHUI COMMENTS
aof-use-rdb-preamble yes
################################# LUA SCRIPTING ###############################
## Max execution time of a Lua script in milliseconds.
##
## If the maximum execution time is reached Redis will log that a script is
## still in execution after the maximum allowed time and will start to
## reply to queries with an error.
##
## When a long running script exceeds the maximum execution time only the
## SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
## used to stop a script that did not yet call any write commands. The second
## is the only way to shut down the server in the case a write command was
## already issued by the script but the user doesn't want to wait for the natural
## termination of the script.
##
## Set it to 0 or a negative value for unlimited execution without warnings.
## BEGIN MEIZHAOHUI COMMENTS
## Lua脚本的使用和设置超时时间,默认5000毫秒,即5秒。
## 但这里有个坑,当一个脚本达到最大执行时长的时候,Redis并不会强制停止脚本的运行,
## 仅仅在日志里打印个警告,告知有脚本超时。
## 开始允许接受其他客户端请求,但仅限于 SCRIPT KILL 和 SHUTDOWN NOSAVE 两个命令
## 其他请求仍返回busy错误,
## 如果脚本已经改写了数据内容,SCRIPT KILL将报出以下错误,因为它破坏数据集的内容。
## 为什么不能直接停掉呢?
## 因为 Redis 必须保证脚本执行的原子性,中途停止可能导致内存的数据集上只修改了部分数据。
##
## Redis脚本里的写命令是等到执行完成后再一次性写入AOF的。
## 参考:https://www.jb51.net/article/230175.htm Redis中Lua脚本的使用和设置超时
## END MEIZHAOHUI COMMENTS
lua-time-limit 5000
################################# REDIS CLUSTER ###############################
## Normal Redis instances can't be part of a Redis Cluster; only nodes that are
## started as cluster nodes can. In order to start a Redis instance as a
## cluster node enable the cluster support uncommenting the following:
## BEGIN MEIZHAOHUI COMMENTS
## 普通 Redis 实例不能成为 Redis 集群的一部分;只有作为集群节点启动的节点才可以。
## 为了将 Redis 实例作为集群节点启动,请取消注释以下内容以启用集群支持:
## END MEIZHAOHUI COMMENTS
##
## cluster-enabled yes
## Every cluster node has a cluster configuration file. This file is not
## intended to be edited by hand. It is created and updated by Redis nodes.
## Every Redis Cluster node requires a different cluster configuration file.
## Make sure that instances running in the same system do not have
## overlapping cluster configuration file names.
## BEGIN MEIZHAOHUI COMMENTS
## 每个集群节点都有一个集群配置文件。此文件不应手动编辑。它由 Redis 节点创建和更新。
## 每个 Redis 集群节点都需要不同的集群配置文件。
## 确保在同一系统中运行的实例没有重复的集群配置文件名。
## END MEIZHAOHUI COMMENTS
##
## cluster-config-file nodes-6379.conf
## Cluster node timeout is the amount of milliseconds a node must be unreachable
## for it to be considered in failure state.
## Most other internal time limits are a multiple of the node timeout.
## BEGIN MEIZHAOHUI COMMENTS
## 集群节点超时是节点必须处于不可访问状态的毫秒数。
## 才会被视为处于故障状态。
## 大多数其他内部时间限制都是节点超时的倍数。
## END MEIZHAOHUI COMMENTS
##
## cluster-node-timeout 15000
## A replica of a failing master will avoid to start a failover if its data
## looks too old.
##
## There is no simple way for a replica to actually have an exact measure of
## its "data age", so the following two checks are performed:
##
## 1) If there are multiple replicas able to failover, they exchange messages
## in order to try to give an advantage to the replica with the best
## replication offset (more data from the master processed).
## Replicas will try to get their rank by offset, and apply to the start
## of the failover a delay proportional to their rank.
##
## 2) Every single replica computes the time of the last interaction with
## its master. This can be the last ping or command received (if the master
## is still in the "connected" state), or the time that elapsed since the
## disconnection with the master (if the replication link is currently down).
## If the last interaction is too old, the replica will not try to failover
## at all.
##
## The point "2" can be tuned by user. Specifically a replica will not perform
## the failover if, since the last interaction with the master, the time
## elapsed is greater than:
##
## (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
##
## So for example if node-timeout is 30 seconds, and the cluster-replica-validity-factor
## is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
## replica will not try to failover if it was not able to talk with the master
## for longer than 310 seconds.
## BEGIN MEIZHAOHUI COMMENTS
## 如果数据看起来太旧,故障主服务器的副本将避免启动故障转移。
## 对于副本来说,没有简单的方法可以准确测量其“数据年龄”,因此需要执行以下两项检查:
##
## 1) 如果有多个副本能够进行故障转移,它们将交换消息,以尝试为具有最佳复制偏移量的副本(处理来自主服务器的更多数据)提供优势(可以理解为优先级)。
## 副本将尝试通过偏移量获取其排名,并在故障转移开始时应用与其排名成比例的延迟。
## 2) 每个副本计算与其主服务器最后一次交互的时间。这可以是最后一次收到的 ping 或命令(如果主服务器仍处于“连接”状态),
## 也可以是自与主服务器断开连接以来经过的时间(如果复制链接当前已关闭)。
## 如果最后一次交互太旧,副本将根本不会尝试故障转移。
##
## 点“2”可以由用户调整。具体来说,如果自上次与主服务器交互以来,经过的时间大于:
## (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
##
## 例如,如果 node-timeout 为 30 秒,cluster-replica-validity-factor为 10,
## 并假设默认 repl-ping-replica-period 为 10 秒,
## 则如果副本无法与主服务器通信超过 310 秒,则副本将不会尝试故障转移。
## END MEIZHAOHUI COMMENTS
##
## A large cluster-replica-validity-factor may allow replicas with too old data to failover
## a master, while a too small value may prevent the cluster from being able to
## elect a replica at all.
##
## For maximum availability, it is possible to set the cluster-replica-validity-factor
## to a value of 0, which means, that replicas will always try to failover the
## master regardless of the last time they interacted with the master.
## (However they'll always try to apply a delay proportional to their
## offset rank).
##
## Zero is the only value able to guarantee that when all the partitions heal
## the cluster will always be able to continue.
## BEGIN MEIZHAOHUI COMMENTS
## 较大的 cluster-replica-validity-factor 可能允许数据过旧的副本故障转移为主服务器,
## 而太小的值可能会阻止集群能够# 选举副本。
## 如果设置为 0 ,则不管 slave 与 master 之间断开多久,都认为自己有资格成为 master。
## END MEIZHAOHUI COMMENTS
##
## cluster-replica-validity-factor 10
## Cluster replicas are able to migrate to orphaned masters, that are masters
## that are left without working replicas. This improves the cluster ability
## to resist to failures as otherwise an orphaned master can't be failed over
## in case of failure if it has no working replicas.
##
## Replicas migrate to orphaned masters only if there are still at least a
## given number of other working replicas for their old master. This number
## is the "migration barrier". A migration barrier of 1 means that a replica
## will migrate only if there is at least 1 other working replica for its master
## and so forth. It usually reflects the number of replicas you want for every
## master in your cluster.
##
## Default is 1 (replicas migrate only if their masters remain with at least
## one replica). To disable migration just set it to a very large value or
## set cluster-allow-replica-migration to 'no'.
## A value of 0 can be set but is useful only for debugging and dangerous
## in production.
## BEGIN MEIZHAOHUI COMMENTS
## 没有 slave 节点的 master 节点称为孤儿 master节点,这个配置就是用于防止出现裸奔的 master。
## 当某个 master 的 slave 节点宕机后,集群会从其他 master 中选出一个富余的 slave 节点迁移过来,
## 确保每个 master 节点至少有一个 slave 节点,
## 防止当孤立 master 节点宕机时,没有slave节点可以升为 master 导致集群不可用。
## 默认配置为 cluster-migration-barrier 1,是一个迁移临界值。
## 含义是:迁移后 master 节点至少还有 1 个 slave 节点才能做迁移操作。
## 比如 master A 节点有2个以上 slave 节点 ,当集群出现孤儿 master B 节点时,
## A 节点富余的 slave 节点可以迁移到 master B 节点上。
## 生产环境建议维持默认值,最大可能保证高可用。
## END MEIZHAOHUI COMMENTS
##
## cluster-migration-barrier 1
## Turning off this option allows to use less automatic cluster configuration.
## It both disables migration to orphaned masters and migration from masters
## that became empty.
##
## Default is 'yes' (allow automatic migrations).
##
## BEGIN MEIZHAOHUI COMMENTS
## 允许自动迁移。
## END MEIZHAOHUI COMMENTS
## cluster-allow-replica-migration yes
## By default Redis Cluster nodes stop accepting queries if they detect there
## is at least a hash slot uncovered (no available node is serving it).
## This way if the cluster is partially down (for example a range of hash slots
## are no longer covered) all the cluster becomes, eventually, unavailable.
## It automatically returns available as soon as all the slots are covered again.
##
## However sometimes you want the subset of the cluster which is working,
## to continue to accept queries for the part of the key space that is still
## covered. In order to do so, just set the cluster-require-full-coverage
## option to no.
##
## BEGIN MEIZHAOHUI COMMENTS
## 当 redis cluster 发现至少还有一个 哈希槽没有被分配时禁止查询操作。
## 这就会导致集群部分宕机,整个集群就不可用了,
## 当所有哈希槽都有分配,集群会自动变为可用状态。
## 默认值 yes , 即需要集群完整性,方可对外提供服务。
## END MEIZHAOHUI COMMENTS
## cluster-require-full-coverage yes
## This option, when set to yes, prevents replicas from trying to failover its
## master during master failures. However the replica can still perform a
## manual failover, if forced to do so.
##
## This is useful in different scenarios, especially in the case of multiple
## data center operations, where we want one side to never be promoted if not
## in the case of a total DC failure.
##
## BEGIN MEIZHAOHUI COMMENTS
## 默认配置为 no,当配置成 yes,在master 宕机时,slave 不会做故障转移升为 master。
## 这个配置在多数据中心的情况下会很有用,你可能希望某个数据中心永远不要升级为 master 节点,
## 否则 master 节点就漂移到其他数据中心了。
## END MEIZHAOHUI COMMENTS
## cluster-replica-no-failover no
## This option, when set to yes, allows nodes to serve read traffic while the
## the cluster is in a down state, as long as it believes it owns the slots.
##
## This is useful for two cases. The first case is for when an application
## doesn't require consistency of data during node failures or network partitions.
## One example of this is a cache, where as long as the node has the data it
## should be able to serve it.
##
## The second use case is for configurations that don't meet the recommended
## three shards but want to enable cluster mode and scale later. A
## master outage in a 1 or 2 shard configuration causes a read/write outage to the
## entire cluster without this option set, with it set there is only a write outage.
## Without a quorum of masters, slot ownership will not change automatically.
##
## BEGIN MEIZHAOHUI COMMENTS
## cluster-allow-reads-when-down配置选项用于控制在节点
## 标记为FAIL(即节点认为它自己已经下线,不能正确处理命令请求)时,
## 集群是否允许对该节点进行读操作。
##
## 当cluster-allow-reads-when-down配置项设置为yes时,
## 即使一个节点因为网络分区问题被集群标记为FAIL,
## 集群的其他节点仍然可以从这个节点进行读操作。
## 这可以提供一定程度的数据可读性,
## 但是需要注意,由于数据可能不同步,因此可能会返回过时的数据。
##
## 当cluster-allow-reads-when-down配置项设置为no时,
## 一旦一个节点被集群标记为FAIL,它将不再从这个节点进行读操作。
## END MEIZHAOHUI COMMENTS
## cluster-allow-reads-when-down no
## In order to setup your cluster make sure to read the documentation
## available at https://redis.io web site.
########################### CLUSTER DOCKER/NAT support ########################
## In certain deployments, Redis Cluster nodes address discovery fails, because
## addresses are NAT-ted or because ports are forwarded (the typical case is
## Docker and other containers).
## BEGIN MEIZHAOHUI COMMENTS
## 在某些部署中,Redis 集群节点地址发现失败,因为
## 地址经过了 NAT 处理或者端口被转发(典型情况是
## Docker 和其他容器)。
##
## 我们此处不用docker部署redis,忽略下面这四个配置项。
## END MEIZHAOHUI COMMENTS
##
## In order to make Redis Cluster working in such environments, a static
## configuration where each node knows its public address is needed. The
## following four options are used for this scope, and are:
##
## * cluster-announce-ip
## * cluster-announce-port
## * cluster-announce-tls-port
## * cluster-announce-bus-port
##
## Each instructs the node about its address, client ports (for connections
## without and with TLS) and cluster message bus port. The information is then
## published in the header of the bus packets so that other nodes will be able to
## correctly map the address of the node publishing the information.
##
## If cluster-tls is set to yes and cluster-announce-tls-port is omitted or set
## to zero, then cluster-announce-port refers to the TLS port. Note also that
## cluster-announce-tls-port has no effect if cluster-tls is set to no.
##
## If the above options are not used, the normal Redis Cluster auto-detection
## will be used instead.
##
## Note that when remapped, the bus port may not be at the fixed offset of
## clients port + 10000, so you can specify any port and bus-port depending
## on how they get remapped. If the bus-port is not set, a fixed offset of
## 10000 will be used as usual.
##
## Example:
##
## cluster-announce-ip 10.1.1.5
## cluster-announce-tls-port 6379
## cluster-announce-port 0
## cluster-announce-bus-port 6380
################################### SLOW LOG ###################################
## The Redis Slow Log is a system to log queries that exceeded a specified
## execution time. The execution time does not include the I/O operations
## like talking with the client, sending the reply and so forth,
## but just the time needed to actually execute the command (this is the only
## stage of command execution where the thread is blocked and can not serve
## other requests in the meantime).
##
## You can configure the slow log with two parameters: one tells Redis
## what is the execution time, in microseconds, to exceed in order for the
## command to get logged, and the other parameter is the length of the
## slow log. When a new command is logged the oldest one is removed from the
## queue of logged commands.
## The following time is expressed in microseconds, so 1000000 is equivalent
## to one second. Note that a negative number disables the slow log, while
## a value of zero forces the logging of every command.
## BEGIN MEIZHAOHUI COMMENTS
## 执行时间超过该值的命令会被记录在慢查询日志中。
## 该值的单位是微秒,当执行时间超过这个值的命令会被记录,
## 值为0表示记录所有命令,值为负数表示不记录任何命令。
## 微秒(1秒 = 1000毫秒 = 1000000微秒)
## END MEIZHAOHUI COMMENTS
slowlog-log-slower-than 10000
## There is no limit to this length. Just be aware that it will consume memory.
## You can reclaim memory used by the slow log with SLOWLOG RESET.
## BEGIN MEIZHAOHUI COMMENTS
## slowlog-max-len的作用是指定慢查询日志最多存储的条数。
## 实际上,Redis使用了一个列表存放慢查询日志,
## slowlog-max-len就是这个列表的最大长度。
## 当一个新的命令满足满足慢查询条件时,被插入这个列表中。
## 当慢查询日志列表已经达到最大长度时,最早插入的那条命令将被从列表中移出。
## 比如,slowlog-max-len被设置为10,当有第11条命令插入时,
## 在列表中的第1条命令先被移出,然后再把第11条命令放入列表。
## END MEIZHAOHUI COMMENTS
slowlog-max-len 128
################################# LATENCY MONITOR ##############################
## The Redis latency monitoring subsystem samples different operations
## at runtime in order to collect data related to possible sources of
## latency of a Redis instance.
##
## Via the LATENCY command this information is available to the user that can
## print graphs and obtain reports.
##
## The system only logs operations that were performed in a time equal or
## greater than the amount of milliseconds specified via the
## latency-monitor-threshold configuration directive. When its value is set
## to zero, the latency monitor is turned off.
##
## By default latency monitoring is disabled since it is mostly not needed
## if you don't have latency issues, and collecting data has a performance
## impact, that while very small, can be measured under big load. Latency
## monitoring can easily be enabled at runtime using the command
## "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
## BEGIN MEIZHAOHUI COMMENTS
## 延迟监视器
## Redis 延迟监视子系统在运行时对不同的操作进行采样,
## 以便收集与 Redis 实例的可能延迟源相关的数据。
## 这个参数的默认值是0,意味着禁用延迟监控。
## 用于指定处理命令请求的最大延迟时间(单位微秒)。
## 如果某个命令的处理延迟超过这个值,Redis 会在日志中记录一条警告信息。
## 如果你想启用并设置一个特定的阈值,请确保将其值设置为合理的高低值,
## 以避免在正常的操作中记录警告。
## END MEIZHAOHUI COMMENTS
latency-monitor-threshold 0
############################## EVENT NOTIFICATION ##############################
## Redis can notify Pub/Sub clients about events happening in the key space.
## This feature is documented at https://redis.io/topics/notifications
##
## For instance if keyspace events notification is enabled, and a client
## performs a DEL operation on key "foo" stored in the Database 0, two
## messages will be published via Pub/Sub:
##
## PUBLISH __keyspace@0__:foo del
## PUBLISH __keyevent@0__:del foo
##
## It is possible to select the events that Redis will notify among a set
## of classes. Every class is identified by a single character:
##
## K Keyspace events, published with __keyspace@<db>__ prefix.
## E Keyevent events, published with __keyevent@<db>__ prefix.
## g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
## $ String commands
## l List commands
## s Set commands
## h Hash commands
## z Sorted set commands
## x Expired events (events generated every time a key expires)
## e Evicted events (events generated when a key is evicted for maxmemory)
## t Stream commands
## d Module key type events
## m Key-miss events (Note: It is not included in the 'A' class)
## A Alias for g$lshzxetd, so that the "AKE" string means all the events
## (Except key-miss events which are excluded from 'A' due to their
## unique nature).
##
## The "notify-keyspace-events" takes as argument a string that is composed
## of zero or multiple characters. The empty string means that notifications
## are disabled.
##
## Example: to enable list and generic events, from the point of view of the
## event name, use:
##
## notify-keyspace-events Elg
##
## Example 2: to get the stream of the expired keys subscribing to channel
## name __keyevent@0__:expired use:
##
## notify-keyspace-events Ex
##
## By default all notifications are disabled because most users don't need
## this feature and the feature has some overhead. Note that if you don't
## specify at least one of K or E, no events will be delivered.
## BEGIN MEIZHAOHUI COMMENTS
## 事件通知。
## 默认情况下,所有通知均被禁用,
## 因为大多数用户不需要此功能,并且此功能有一些开销。
## END MEIZHAOHUI COMMENTS
notify-keyspace-events ""
################################ GOPHER SERVER #################################
## Redis contains an implementation of the Gopher protocol, as specified in
## the RFC 1436 (https://www.ietf.org/rfc/rfc1436.txt).
##
## The Gopher protocol was very popular in the late '90s. It is an alternative
## to the web, and the implementation both server and client side is so simple
## that the Redis server has just 100 lines of code in order to implement this
## support.
##
## What do you do with Gopher nowadays? Well Gopher never *really* died, and
## lately there is a movement in order for the Gopher more hierarchical content
## composed of just plain text documents to be resurrected. Some want a simpler
## internet, others believe that the mainstream internet became too much
## controlled, and it's cool to create an alternative space for people that
## want a bit of fresh air.
##
## Anyway for the 10nth birthday of the Redis, we gave it the Gopher protocol
## as a gift.
##
## --- HOW IT WORKS? ---
##
## The Redis Gopher support uses the inline protocol of Redis, and specifically
## two kind of inline requests that were anyway illegal: an empty request
## or any request that starts with "/" (there are no Redis commands starting
## with such a slash). Normal RESP2/RESP3 requests are completely out of the
## path of the Gopher protocol implementation and are served as usual as well.
##
## If you open a connection to Redis when Gopher is enabled and send it
## a string like "/foo", if there is a key named "/foo" it is served via the
## Gopher protocol.
##
## In order to create a real Gopher "hole" (the name of a Gopher site in Gopher
## talking), you likely need a script like the following:
##
## https://github.com/antirez/gopher2redis
##
## --- SECURITY WARNING ---
##
## If you plan to put Redis on the internet in a publicly accessible address
## to server Gopher pages MAKE SURE TO SET A PASSWORD to the instance.
## Once a password is set:
##
## 1. The Gopher server (when enabled, not by default) will still serve
## content via Gopher.
## 2. However other commands cannot be called before the client will
## authenticate.
##
## So use the 'requirepass' option to protect your instance.
##
## Note that Gopher is not currently supported when 'io-threads-do-reads'
## is enabled.
##
## To enable Gopher support, uncomment the following line and set the option
## from no (the default) to yes.
##
## BEGIN MEIZHAOHUI COMMENTS
## 是否启用gopher协议的web访问。
## Gopher 协议在 90 年代末非常流行。
## 它是 Web 的替代品,服务器端和客户端的实现都非常简单,
## 以至于 Redis 服务器只需 100 行代码即可实现此支持。
## 保持默认不开启。
## END MEIZHAOHUI COMMENTS
## gopher-enabled no
################################ ADVANCED CONFIG ###############################
## Hashes are encoded using a memory efficient data structure when they have a
## small number of entries, and the biggest entry does not exceed a given
## threshold. These thresholds can be configured using the following directives.
## BEGIN MEIZHAOHUI COMMENTS
## 高级设置。
## 当哈希值包含少量条目且最大条目不超过给定阈值时,
## 哈希值将使用内存高效的数据结构进行编码。
## 可以使用以下指令配置这些阈值。
## hash-max-ziplist-entries,使用压缩列表保存时哈希集合中最大元素个数。
## hash-max-ziplist-value, 使用压缩列表保存时哈希集合中单个元素的最大长度。
## 键值对个数小于512,所有的键值对的键和值的字符串长度都小于64个字节时用ziplist,否则用hashtable。
## 注意:ziplist可以升级为hashtable,但hashtable不能降级为ziplist,
## 在节省内存空间方面哈希表是没有压缩列表高效的!
## END MEIZHAOHUI COMMENTS
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
## Lists are also encoded in a special way to save a lot of space.
## The number of entries allowed per internal list node can be specified
## as a fixed maximum size or a maximum number of elements.
## For a fixed maximum size, use -5 through -1, meaning:
## -5: max size: 64 Kb <-- not recommended for normal workloads
## -4: max size: 32 Kb <-- not recommended
## -3: max size: 16 Kb <-- probably not recommended
## -2: max size: 8 Kb <-- good
## -1: max size: 4 Kb <-- good
## Positive numbers mean store up to _exactly_ that number of elements
## per list node.
## The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
## but if your use case is unique, adjust the settings as necessary.
## BEGIN MEIZHAOHUI COMMENTS
## 列表也以特殊方式编码以节省大量空间。
## 可以将每个内部列表节点允许的条目数指定为
## 固定最大大小或最大元素数。
## 对于固定最大大小,请使用 -5 到 -1,这意味着:
## -5:最大大小:64 Kb <-- 不推荐用于正常工作负载
## -4:最大大小:32 Kb <-- 不推荐
## -3:最大大小:16 Kb <-- 可能不推荐
## -2:最大大小:8 Kb <-- 好
## -1:最大大小:4 Kb <-- 好
## 正数表示每个列表节点最多存储该数量的元素。
## 性能最高的选项通常是 -2(8 Kb 大小)或 -1(4 Kb 大小)。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
list-max-ziplist-size -2
## Lists may also be compressed.
## Compress depth is the number of quicklist ziplist nodes from *each* side of
## the list to *exclude* from compression. The head and tail of the list
## are always uncompressed for fast push/pop operations. Settings are:
## 0: disable all list compression
## 1: depth 1 means "don't start compressing until after 1 node into the list,
## going from either the head or tail"
## So: [head]->node->node->...->node->[tail]
## [head], [tail] will always be uncompressed; inner nodes will compress.
## 2: [head]->[next]->node->node->...->node->[prev]->[tail]
## 2 here means: don't compress head or head->next or tail->prev or tail,
## but compress all nodes between them.
## 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
## etc.
## BEGIN MEIZHAOHUI COMMENTS
## 列表也可以进行压缩。默认为0,禁用列表压缩。
## 保持默认即可。
## END MEIZHAOHUI COMMENTS
list-compress-depth 0
## Sets have a special encoding in just one case: when a set is composed
## of just strings that happen to be integers in radix 10 in the range
## of 64 bit signed integers.
## The following configuration setting sets the limit in the size of the
## set in order to use this special memory saving encoding.
## BEGIN MEIZHAOHUI COMMENTS
## 集合仅在一种情况下具有特殊编码:
## 当集合仅由恰好是基数为 10 的整数且范围为 64 位有符号整数的字符串组成时。
## END MEIZHAOHUI COMMENTS
set-max-intset-entries 512
## Similarly to hashes and lists, sorted sets are also specially encoded in
## order to save a lot of space. This encoding is only used when the length and
## elements of a sorted set are below the following limits:
## BEGIN MEIZHAOHUI COMMENTS
## 与哈希和列表类似,有序集合也经过特殊编码,以节省大量空间。
## 只有当有序集合的长度和元素低于以下限制时才使用此编码:
## END MEIZHAOHUI COMMENTS
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
## HyperLogLog sparse representation bytes limit. The limit includes the
## 16 bytes header. When an HyperLogLog using the sparse representation crosses
## this limit, it is converted into the dense representation.
##
## A value greater than 16000 is totally useless, since at that point the
## dense representation is more memory efficient.
##
## The suggested value is ~ 3000 in order to have the benefits of
## the space efficient encoding without slowing down too much PFADD,
## which is O(N) with the sparse encoding. The value can be raised to
## ~ 10000 when CPU is not a concern, but space is, and the data set is
## composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
## BEGIN MEIZHAOHUI COMMENTS
## hll-sparse-max-bytes用来控制稀疏HyperLogLog结构的最大保存字节数。
## HyperLogLog是一种用于进行基数估计的数据结构,
## 通过牺牲一定的精确度来减小占用的内存空间。
## END MEIZHAOHUI COMMENTS
hll-sparse-max-bytes 3000
## Streams macro node max size / items. The stream data structure is a radix
## tree of big nodes that encode multiple items inside. Using this configuration
## it is possible to configure how big a single node can be in bytes, and the
## maximum number of items it may contain before switching to a new node when
## appending new stream entries. If any of the following settings are set to
## zero, the limit is ignored, so for instance it is possible to set just a
## max entries limit by setting max-bytes to 0 and max-entries to the desired
## value.
## BEGIN MEIZHAOHUI COMMENTS
## stream-node-max-bytes参数用于设置stream节点的最大字节数。
## 每个stream节点都是由多个消息组成的,并且每个消息都有一定的字节数。
## 该参数用于限制stream节点的最大字节数,以避免节点过大而导致内存占用过多的问题。
## stream-node-max-entries参数用于限制一个stream节点(即一个stream所包含的数据的单位)中的最大条目数。
## 默认值为100。当节点中的条目数量达到该限制时,Redis会自动将节点拆分为更小的节点,
## 并创建新的节点来存储后续的条目。
## END MEIZHAOHUI COMMENTS
stream-node-max-bytes 4096
stream-node-max-entries 100
## Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
## order to help rehashing the main Redis hash table (the one mapping top-level
## keys to values). The hash table implementation Redis uses (see dict.c)
## performs a lazy rehashing: the more operation you run into a hash table
## that is rehashing, the more rehashing "steps" are performed, so if the
## server is idle the rehashing is never complete and some more memory is used
## by the hash table.
##
## The default is to use this millisecond 10 times every second in order to
## actively rehash the main dictionaries, freeing memory when possible.
##
## If unsure:
## use "activerehashing no" if you have hard latency requirements and it is
## not a good thing in your environment that Redis can reply from time to time
## to queries with 2 milliseconds delay.
##
## use "activerehashing yes" if you don't have such hard requirements but
## want to free memory asap when possible.
## BEGIN MEIZHAOHUI COMMENTS
## active rehashing(主动重哈希)是通过设置activerehashing参数来启用的。
## active rehashing是一种动态将哈希槽从一个节点转移到另一个节点的机制。
## 在Redis集群中,哈希槽被分配给不同的节点来存储数据。当节点的负载不均衡时,
## active rehashing可以将一部分哈希槽从负载较高的节点移动到负载较低的节点,
## 以实现负载均衡。这个过程是在运行时进行的,并且是自动执行的。
## END MEIZHAOHUI COMMENTS
activerehashing yes
## The client output buffer limits can be used to force disconnection of clients
## that are not reading data from the server fast enough for some reason (a
## common reason is that a Pub/Sub client can't consume messages as fast as the
## publisher can produce them).
##
## The limit can be set differently for the three different classes of clients:
##
## normal -> normal clients including MONITOR clients
## replica -> replica clients
## pubsub -> clients subscribed to at least one pubsub channel or pattern
##
## The syntax of every client-output-buffer-limit directive is the following:
##
## client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
##
## A client is immediately disconnected once the hard limit is reached, or if
## the soft limit is reached and remains reached for the specified number of
## seconds (continuously).
## So for instance if the hard limit is 32 megabytes and the soft limit is
## 16 megabytes / 10 seconds, the client will get disconnected immediately
## if the size of the output buffers reach 32 megabytes, but will also get
## disconnected if the client reaches 16 megabytes and continuously overcomes
## the limit for 10 seconds.
##
## By default normal clients are not limited because they don't receive data
## without asking (in a push way), but just after a request, so only
## asynchronous clients may create a scenario where data is requested faster
## than it can read.
##
## Instead there is a default limit for pubsub and replica clients, since
## subscribers and replicas receive data in a push fashion.
##
## Both the hard or the soft limit can be disabled by setting them to zero.
## BEGIN MEIZHAOHUI COMMENTS
## client-output-buffer-limit参数是用来限制客户端输出缓冲区的大小的。
## 参数的格式为:
## client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
## 其中,
## <class>指定了要限制的客户端类型,包括normal、slave、pubsub和replica。
## <hard-limit>表示客户端输出缓冲区的硬限制大小,单位为字节。当输出缓冲区大小超过这个限制时,客户端将被立即关闭。
## <soft-limit>表示客户端输出缓冲区的软限制大小,单位为字节。当输出缓冲区大小超过这个限制时,Redis将开始主动丢弃一部分缓冲区中的数据,以避免缓冲区溢出。
## <soft seconds>表示在达到软限制后,Redis将开始丢弃缓冲区数据的持续时间。以秒为单位进行设置。
## END MEIZHAOHUI COMMENTS
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
## Client query buffers accumulate new commands. They are limited to a fixed
## amount by default in order to avoid that a protocol desynchronization (for
## instance due to a bug in the client) will lead to unbound memory usage in
## the query buffer. However you can configure it here if you have very special
## needs, such us huge multi/exec requests or alike.
##
## client-query-buffer-limit 1gb
## In the Redis protocol, bulk requests, that are, elements representing single
## strings, are normally limited to 512 mb. However you can change this limit
## here, but must be 1mb or greater
##
## proto-max-bulk-len 512mb
## Redis calls an internal function to perform many background tasks, like
## closing connections of clients in timeout, purging expired keys that are
## never requested, and so forth.
##
## Not all tasks are performed with the same frequency, but Redis checks for
## tasks to perform according to the specified "hz" value.
##
## By default "hz" is set to 10. Raising the value will use more CPU when
## Redis is idle, but at the same time will make Redis more responsive when
## there are many keys expiring at the same time, and timeouts may be
## handled with more precision.
##
## The range is between 1 and 500, however a value over 100 is usually not
## a good idea. Most users should use the default of 10 and raise this up to
## 100 only in environments where very low latency is required.
## BEGIN MEIZHAOHUI COMMENTS
## Redis 调用内部函数来执行许多后台任务,
## 例如关闭超时的客户端连接、清除从未请求的过期键等等。
##
## 并非所有任务都以相同的频率执行,但 Redis 会根据指定的"hz"值检查要执行的任务。
##
## 默认情况下,"hz"设置为 10。当 Redis 空闲时,提高该值将使用更多 CPU,
## 但同时当有许多键同时过期时,Redis 的响应速度会更快,并且可以更精确地处理超时。
##
## 该参数范围在 1 到 500 之间,但超过 100 的值是不推荐的。
## 大多数用户应该使用默认值 10,并仅在需要非常低延迟的环境中将其提高到 100。
## 默认的HZ值为10,表示每秒进行10次的定时任务检查。
## END MEIZHAOHUI COMMENTS
hz 10
## Normally it is useful to have an HZ value which is proportional to the
## number of clients connected. This is useful in order, for instance, to
## avoid too many clients are processed for each background task invocation
## in order to avoid latency spikes.
##
## Since the default HZ value by default is conservatively set to 10, Redis
## offers, and enables by default, the ability to use an adaptive HZ value
## which will temporarily raise when there are many connected clients.
##
## When dynamic HZ is enabled, the actual configured HZ will be used
## as a baseline, but multiples of the configured HZ value will be actually
## used as needed once more clients are connected. In this way an idle
## instance will use very little CPU time while a busy instance will be
## more responsive.
## BEGIN MEIZHAOHUI COMMENTS
## dynamic-hz用于控制Redis是否动态调整服务器的心跳频率。
## 心跳频率是Redis服务器在非阻塞状态下执行任务的速率。
## 在每次循环中,服务器都会操纵定时器(用于计算心跳)。
## dynamic-hz参数允许Redis根据服务器的负载动态地调整心跳频率。
## 如果dynamic-hz被设置为yes,Redis将根据服务器的负载情况自动调整心跳频率。
## 具体来说,如果服务器忙碌并且使用率较高,Redis会增加心跳频率以提高响应速度。
## 相反,如果服务器处于空闲状态,Redis会降低心跳频率以节省资源。
## END MEIZHAOHUI COMMENTS
dynamic-hz yes
## When a child rewrites the AOF file, if the following option is enabled
## the file will be fsync-ed every 32 MB of data generated. This is useful
## in order to commit the file to the disk more incrementally and avoid
## big latency spikes.
## BEGIN MEIZHAOHUI COMMENTS
## aof-rewrite-incremental-fsync参数用于控制重写过程中自动执行fsync的频率。
## fsync是一个用于将数据写入磁盘的系统调用,它确保数据写入磁盘后才返回。
## 然而,频繁的执行fsync操作会导致性能下降。
## aof-rewrite-incremental-fsync参数接受以下值:
## yes:表示在AOF重写期间会自动执行fsync操作。这是默认值,可以确保AOF文件的安全性,但可能会影响性能。
## no:表示在AOF重写期间不执行fsync操作。这样可以提高性能,但可能会增加数据丢失的风险。
## END MEIZHAOHUI COMMENTS
aof-rewrite-incremental-fsync yes
## When redis saves RDB file, if the following option is enabled
## the file will be fsync-ed every 32 MB of data generated. This is useful
## in order to commit the file to the disk more incrementally and avoid
## big latency spikes.
## BEGIN MEIZHAOHUI COMMENTS
## rdb-save-incremental-fsync参数用于控制是否在进行RDB持久化时进行增量fsync操作。
## RDB持久化是将Redis的内存数据以二进制格式写入磁盘文件,以保证数据在重启时的持久性。
## 在默认情况下,Redis会在进行RDB持久化时执行一个完整的fsync操作,将数据强制刷写到磁盘上。
## 但是,完整的fsync操作可能会导致一定的性能损失,特别是在写入大量数据时。
## 为了减轻这种性能损失,Redis 6引入了rdb-save-incremental-fsync参数。
## 默认情况下,rdb-save-incremental-fsync参数的值为yes,表示在进行RDB持久化时进行增量fsync操作。
## 增量fsync操作只会将数据写入磁盘的文件系统缓存中,并不会马上将数据刷写到磁盘上。
## 这种方式可以提高性能,但是可能会增加数据丢失的风险,在发生宕机的情况下可能会有一定的数据丢失。
## END MEIZHAOHUI COMMENTS
rdb-save-incremental-fsync yes
## Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
## idea to start with the default settings and only change them after investigating
## how to improve the performances and how the keys LFU change over time, which
## is possible to inspect via the OBJECT FREQ command.
##
## There are two tunable parameters in the Redis LFU implementation: the
## counter logarithm factor and the counter decay time. It is important to
## understand what the two parameters mean before changing them.
##
## The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
## uses a probabilistic increment with logarithmic behavior. Given the value
## of the old counter, when a key is accessed, the counter is incremented in
## this way:
##
## 1. A random number R between 0 and 1 is extracted.
## 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
## 3. The counter is incremented only if R < P.
##
## The default lfu-log-factor is 10. This is a table of how the frequency
## counter changes with a different number of accesses with different
## logarithmic factors:
##
## +--------+------------+------------+------------+------------+------------+
## | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits |
## +--------+------------+------------+------------+------------+------------+
## | 0 | 104 | 255 | 255 | 255 | 255 |
## +--------+------------+------------+------------+------------+------------+
## | 1 | 18 | 49 | 255 | 255 | 255 |
## +--------+------------+------------+------------+------------+------------+
## | 10 | 10 | 18 | 142 | 255 | 255 |
## +--------+------------+------------+------------+------------+------------+
## | 100 | 8 | 11 | 49 | 143 | 255 |
## +--------+------------+------------+------------+------------+------------+
##
## NOTE: The above table was obtained by running the following commands:
##
## redis-benchmark -n 1000000 incr foo
## redis-cli object freq foo
##
## NOTE 2: The counter initial value is 5 in order to give new objects a chance
## to accumulate hits.
##
## The counter decay time is the time, in minutes, that must elapse in order
## for the key counter to be divided by two (or decremented if it has a value
## less <= 10).
##
## The default value for the lfu-decay-time is 1. A special value of 0 means to
## decay the counter every time it happens to be scanned.
##
## lfu-log-factor 10
## lfu-decay-time 1
############################ ACTIVE DEFRAGMENTATION #######################
##
## What is active defragmentation?
## -------------------------------
##
## Active (online) defragmentation allows a Redis server to compact the
## spaces left between small allocations and deallocations of data in memory,
## thus allowing to reclaim back memory.
##
## Fragmentation is a natural process that happens with every allocator (but
## less so with Jemalloc, fortunately) and certain workloads. Normally a server
## restart is needed in order to lower the fragmentation, or at least to flush
## away all the data and create it again. However thanks to this feature
## implemented by Oran Agra for Redis 4.0 this process can happen at runtime
## in a "hot" way, while the server is running.
##
## Basically when the fragmentation is over a certain level (see the
## configuration options below) Redis will start to create new copies of the
## values in contiguous memory regions by exploiting certain specific Jemalloc
## features (in order to understand if an allocation is causing fragmentation
## and to allocate it in a better place), and at the same time, will release the
## old copies of the data. This process, repeated incrementally for all the keys
## will cause the fragmentation to drop back to normal values.
##
## Important things to understand:
##
## 1. This feature is disabled by default, and only works if you compiled Redis
## to use the copy of Jemalloc we ship with the source code of Redis.
## This is the default with Linux builds.
##
## 2. You never need to enable this feature if you don't have fragmentation
## issues.
##
## 3. Once you experience fragmentation, you can enable this feature when
## needed with the command "CONFIG SET activedefrag yes".
##
## The configuration parameters are able to fine tune the behavior of the
## defragmentation process. If you are not sure about what they mean it is
## a good idea to leave the defaults untouched.
## Enabled active defragmentation
## activedefrag no
## Minimum amount of fragmentation waste to start active defrag
## active-defrag-ignore-bytes 100mb
## Minimum percentage of fragmentation to start active defrag
## active-defrag-threshold-lower 10
## Maximum percentage of fragmentation at which we use maximum effort
## active-defrag-threshold-upper 100
## Minimal effort for defrag in CPU percentage, to be used when the lower
## threshold is reached
## active-defrag-cycle-min 1
## Maximal effort for defrag in CPU percentage, to be used when the upper
## threshold is reached
## active-defrag-cycle-max 25
## Maximum number of set/hash/zset/list fields that will be processed from
## the main dictionary scan
## active-defrag-max-scan-fields 1000
## Jemalloc background thread for purging will be enabled by default
## BEGIN MEIZHAOHUI COMMENTS
## jemalloc-bg-thread 参数是一个用于控制 jemalloc 后台线程行为的选项。
## jemalloc 是一个用于 Redis 内存分配的开源库,它的主要特点是支持多线程内存分配,
## 可以提高 Redis 的并发性能。
## jemalloc-bg-thread 参数的默认值是 yes,它表示启用 jemalloc 后台线程。
## 这个后台线程主要用于处理 jemalloc 的内存处理任务,
## 例如内存碎片整理、内存归还等,它可以在后台异步地执行这些任务,
## 避免阻塞 Redis 的主线程。
## 当发生写入删除操作时,jemalloc 可能会产生一些内存碎片。
## 这些内存碎片会导致 Redis 的内存使用效率下降。
## 启用 jemalloc-bg-thread 可以定期对这些内存碎片进行整理,提高 Redis 的内存使用效率。
## END MEIZHAOHUI COMMENTS
jemalloc-bg-thread yes
## It is possible to pin different threads and processes of Redis to specific
## CPUs in your system, in order to maximize the performances of the server.
## This is useful both in order to pin different Redis threads in different
## CPUs, but also in order to make sure that multiple Redis instances running
## in the same host will be pinned to different CPUs.
##
## Normally you can do this using the "taskset" command, however it is also
## possible to this via Redis configuration directly, both in Linux and FreeBSD.
##
## You can pin the server/IO threads, bio threads, aof rewrite child process, and
## the bgsave child process. The syntax to specify the cpu list is the same as
## the taskset command:
##
## Set redis server/io threads to cpu affinity 0,2,4,6:
## server_cpulist 0-7:2
##
## Set bio threads to cpu affinity 1,3:
## bio_cpulist 1,3
##
## Set aof rewrite child process to cpu affinity 8,9,10,11:
## aof_rewrite_cpulist 8-11
##
## Set bgsave child process to cpu affinity 1,10,11
## bgsave_cpulist 1,10-11
## In some cases redis will emit warnings and even refuse to start if it detects
## that the system is in bad state, it is possible to suppress these warnings
## by setting the following config which takes a space delimited list of warnings
## to suppress
##
## ignore-warnings ARM64-COW-BUG
|