-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.xml
More file actions
2532 lines (2435 loc) · 260 KB
/
search.xml
File metadata and controls
2532 lines (2435 loc) · 260 KB
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
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>Mac os thrift旧版本安装爬坑指南、Mac thrift安装指南、thrift安装学习、thrift安装爬坑</title>
<url>/2019/06/01/MacOS%20thrift%E6%97%A7%E7%89%88%E6%9C%AC%E5%AE%89%E8%A3%85%E7%88%AC%E5%9D%91%E6%8C%87%E5%8D%97/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h5 id="Mac-os-thrift旧版本安装爬坑指南"><a href="#Mac-os-thrift旧版本安装爬坑指南" class="headerlink" title="Mac os thrift旧版本安装爬坑指南"></a>Mac os thrift旧版本安装爬坑指南</h5><p>喜欢使用brew来进行一键安装:</p>
<blockquote>
<p><a href="https://brew.sh/index_zh-cn" target="_blank" rel="noopener">homebrew官网</a><br><a href="https://github.com/Homebrew/homebrew-core" target="_blank" rel="noopener">homebrew-core github网址</a></p>
</blockquote>
<ul>
<li><p>对于安装最新新版本thrift,我们可以直接是用brew install thrift </p>
</li>
<li><p>使用brew search thrift;查看不同版本的thrift。然后brew install <a href="mailto:thrift@0.9.0" target="_blank" rel="noopener">thrift@0.9.0</a></p>
</li>
<li><p>使用复杂brew方案进行安装。思路同时通过找到旧版本的thrift.rb。</p>
<ol>
<li>将homebrew-core的git文件下载到本地。</li>
<li>通过查看Formula/thrift.rb的history。 </li>
</ol>
<a id="more"></a>
<p><code>git log 234b34ab1418bd42b14e73dbeea179f40ef1bec2 -- Formula/thrift.rb</code></p>
<ol start="3">
<li><p>找到旧版本的commit。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"> commit 9d524e4850651cfedd64bc0740f1379b533f607d</span><br><span class="line">Author: BrewTestBot <brew-test-bot@googlegroups.com></span><br><span class="line">Date: Thu Dec 29 18:54:26 2016 +0000</span><br><span class="line"></span><br><span class="line"> thrift: update 0.9.3 bottle.</span><br></pre></td></tr></table></figure>
</li>
<li><p>然后将链接</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">https://github.com/Homebrew/homebrew-core/blob/{commit_id}/Formula/thrift.rb</span><br><span class="line">即:</span><br><span class="line">https://github.com/Homebrew/homebrew-core/blob/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb</span><br></pre></td></tr></table></figure>
</li>
<li><p>点击页面上按钮“Raw”,获取文件内容</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">https://raw.githubusercontent.com/Homebrew/homebrew-core/{commit_id}/Formula/thrift.rb</span><br><span class="line">即:</span><br><span class="line">https://raw.githubusercontent.com/Homebrew/homebrew-core/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb</span><br></pre></td></tr></table></figure>
</li>
<li><p>在命令行上 brew install <a href="https://raw.githubusercontent.com/Homebrew/homebrew-core/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb" target="_blank" rel="noopener">https://raw.githubusercontent.com/Homebrew/homebrew-core/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb</a><br>即可。<br>安装成功。</p>
</li>
</ol>
<p>参考网址:<br><a href="https://apple.stackexchange.com/questions/352477/install-older-removed-brew-formula-version" target="_blank" rel="noopener">Install older removed brew formula version</a></p>
</li>
</ul>
<h5 id="源码安装"><a href="#源码安装" class="headerlink" title="源码安装"></a>源码安装</h5><blockquote>
<p><a href="https://thrift.apache.org/" target="_blank" rel="noopener">thrift快速指南</a></p>
</blockquote>
<ul>
<li><a href="https://github.com/apache/thrift/releases" target="_blank" rel="noopener">下载旧版本</a></li>
<li><a href="https://thrift.apache.org/docs/install/" target="_blank" rel="noopener">安装下载thrift要求的其他工具|插件</a></li>
<li><a href="https://thrift.apache.org/docs/BuildingFromSource" target="_blank" rel="noopener">配置、编译、安装</a></li>
</ul>
<hr>
<h5 id="开始爬坑"><a href="#开始爬坑" class="headerlink" title="开始爬坑"></a>开始爬坑</h5><ul>
<li><p>安装前要求工具 可以使用brew install 进行安装</p>
<blockquote>
<p><a href="https://thrift.apache.org/docs/install/os_x" target="_blank" rel="noopener">https://thrift.apache.org/docs/install/os_x</a><br>boost<br>libevent<br>openssl<br>bison 2.5 </p>
</blockquote>
</li>
<li><p>下载thrift文件安装包</p>
<blockquote>
<p><a href="https://github.com/apache/thrift/releases/tag/0.9.3" target="_blank" rel="noopener">https://github.com/apache/thrift/releases/tag/0.9.3</a><br>tar -zxvf 解压</p>
</blockquote>
</li>
<li><p>编译流程</p>
<blockquote>
<p>./configure –prefix=/usr/local/ –disable-static –without-python –without-csharp –without-ruby –without-perl –without-php –without-haskell –without-erlang<br><a href="https://thrift.apache.org/docs/BuildingFromSource" target="_blank" rel="noopener">https://thrift.apache.org/docs/BuildingFromSource</a><br>出现bison版本低: <a href="https://stackoverflow.com/questions/31805431/how-to-install-bison-on-mac-osx" target="_blank" rel="noopener">https://stackoverflow.com/questions/31805431/how-to-install-bison-on-mac-osx</a><br>注意需要source .base_profile</p>
</blockquote>
</li>
<li><p>出现问题:</p>
<blockquote>
<p>src/thrift/transport/TSSLSocket.cpp:33:10: fatal error: ‘openssl/err.h’ file not found #include <openssl/err.h><br><a href="https://www.jianshu.com/p/f7380139afdd" target="_blank" rel="noopener">https://www.jianshu.com/p/f7380139afdd</a></p>
</blockquote>
</li>
</ul>
<p>推荐阅读:<br><a href="http://www.ruanyifeng.com/blog/2014/11/compiler.html" target="_blank" rel="noopener">编译器的工作过程</a></p>
]]></content>
<tags>
<tag>后端</tag>
</tags>
</entry>
<entry>
<title>CORS学习、实战内网测试和外网更新</title>
<url>/2018/10/08/CORS%E5%86%85%E7%BD%91%E6%B5%8B%E8%AF%95%E5%92%8C%E5%A4%96%E7%BD%91%E6%9B%B4%E6%96%B0/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h5 id="解释CORS的定义"><a href="#解释CORS的定义" class="headerlink" title="解释CORS的定义"></a>解释CORS的定义</h5><p>CORS (Cross-origin resource sharing)跨域资源共享问题,是W3C的标准。 </p>
<blockquote>
<p>当某一资源在自己的资源服务器上的不同域或者端口请求另一个资源时,那么该资源会发起一次跨域请求. (Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin. A web application makes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, and port) than its own origin.) </p>
</blockquote>
<h5 id="CORS请求介绍"><a href="#CORS请求介绍" class="headerlink" title="CORS请求介绍"></a>CORS请求介绍</h5><p>CORS请求是指当前请求出现和源站不一样的请求协议、域名(含二级域名)、端口。<br><a href="https://segmentfault.com/a/1190000007326671" target="_blank" rel="noopener">详细介绍哪些情况会出现跨域的情况列链接</a>并前端的角度该如何解决问题。</p>
<a id="more"></a>
<h4 id="CORS请求拦截"><a href="#CORS请求拦截" class="headerlink" title="CORS请求拦截"></a>CORS请求拦截</h4><p>我遇到的HTTPS在CHROME浏览器出现跨域字体无法显示,在safari和HTTP的情况没有出现。<br>浏览器限制了发起跨站请求,存在可能是跨站请求可以正常发起,但是返回结果不包含Access-Control-Allow-Origin等符合信息就被浏览器拦截了。<br>目前一般很少出现浏览器主动限制CORS请求呢。</p>
<h5 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h5><p>对于简单请求,浏览器直接发出 CORS 请求。具体来说,就是由浏览器自动在头信息中增加一个 Origin 字段。然后只需要在返回的相应上加上Access-Control-Allow-Origin:[Origin]|* 。<br><a href="https://zoctan.github.io/2018/07/21/%E5%AD%A6%E4%B9%A0/%E8%B7%A8%E5%9F%9F%E8%B5%84%E6%BA%90%E5%85%B1%E4%BA%AB%20CORS%20%E8%AF%A6%E8%A7%A3%EF%BC%88%E8%BD%AC%EF%BC%89/" target="_blank" rel="noopener">前端详细介绍了解</a></p>
<h5 id="接下来详细讲实际解决的情况"><a href="#接下来详细讲实际解决的情况" class="headerlink" title="接下来详细讲实际解决的情况"></a>接下来详细讲实际解决的情况</h5><ul>
<li>需要让内网出现线上的情况</li>
<li>按照网上解决方案去解决</li>
<li>线上CDN资源需要让其失效</li>
</ul>
<h6 id="内网配置出线上环境"><a href="#内网配置出线上环境" class="headerlink" title="内网配置出线上环境"></a>内网配置出线上环境</h6><p>我们内网是http协议,不支持https的协议,没有出现线上的情况。</p>
<ul>
<li>先需要将线上的证书下载到本地,在上传到内网指定位置。</li>
<li>先将内网的nginx的配置文本上加上https的443的端口访问处理。(/opt/nginx/conf/conf.d)</li>
<li>证书和域名是一一对应,所有配置文件的server-name 为证书上的域名。<blockquote>
<pre><code>server {
listen 443;
server_name #证书上的域名即线上的网址
access_log #日志地址
ssl on;
ssl_certificate #证书地址
ssl_certificate_key #证书地址
location ~ / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header FORWARDED-FOR $remote_addr;
proxy_pass #代理到Tomcat的服务器的域名+端口
include conf.d/proxy_params;}}</code></pre></blockquote>
</li>
</ul>
<p>1.遇到问题只能通过线上域名访问,但是无法访问到内网的资源。<br>2.<a href="https://www.jianshu.com/p/4394aaf97492" target="_blank" rel="noopener">DNS 服务详细了解</a></p>
<blockquote>
<p>先了解客户端进行域名解析的流程:<br>先查hosts文件<br>若没有,查本地DNS缓存<br>若没有,再查DNS服务器:<br>先查DNS服务器的本地DNS缓存<br>若没有,再查DNS服务器的解析库<br>都没有,那DNS向根域发起请求,开始迭代查询<br>如果缓存的有效期为1天的话,能极大减轻DNS服务器的压力,所以对于DNS的架构,“缓存”是很重要的。</p>
</blockquote>
<p>3.在/etc/hosts文件加上ip和域名的强制映射(内网ip(nginx) 线上域名)。我们的nginx和tomcat服务器是在同一个服务器上。 接下来线上域名的访问都会转接到内网资源的访问。(另一个办法:通过Charles进行代理实现)<br>4.详细分析后,字体是加载进来的js代码发起的静态资源访问(CORS的访问,二级域名不一样)。折腾好久才想起来的,但是静态资源的访问是通过不同内外网环境进行变化的,内网静态资源都在内网服务器上,外网的静态资源在CDN缓存上和静态资源服务器上。<br>5.将加载js的代码写死,变成直接访问外网的静态资源。(与线上保持一致)<br>6.静态资源访问需要变成内网资源的访问。同样,先在hosts文件加上ip和静态资源的域名的强制映射(内网ip 线上域名)。<br>内网静态资源nginx配置 </p>
<blockquote>
<pre><code>server {
listen 443;
server_name #静态资源服务器
gzip on;
ssl on;
ssl_certificate /data/config/ssl/star.enjoymeet.com.chained;
ssl_certificate_key #证书地址
access_log #证书地址
location ~* \.(eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin * ;
add_header Access-Control-Allow-Methods GET;
proxy_pass #代理到Tomcat的服务器的域名+端口
}
}</code></pre></blockquote>
<p>基本上实现在内网测试。<br>参考资料:在nginx上解决问题<br><a href="http://www.yunweipai.com/archives/9381.html" target="_blank" rel="noopener">Nginx通过CORS实现跨域1</a><br><a href="https://hk.saowen.com/a/bcc2bf629fad4037006703f159ec7927ef4cca06a0d7a2cf6d8932584754fa28" target="_blank" rel="noopener">Nginx通過CORS實現跨域2</a><br><a href="https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS" target="_blank" rel="noopener">HTTP访问控制(CORS)
</a><br><a href="https://serverfault.com/questions/162429/how-do-i-add-access-control-allow-origin-in-nginx" target="_blank" rel="noopener">How do I add Access-Control-Allow-Origin in NGINX?</a></p>
<h6 id="线上处理"><a href="#线上处理" class="headerlink" title="线上处理"></a>线上处理</h6><ul>
<li>CDN 回源,我们回源的访问80端口欧,HTTP协议。</li>
<li>CDN的资源让线上的资源失效。</li>
</ul>
]]></content>
<tags>
<tag>后端</tag>
</tags>
</entry>
<entry>
<title>HTTP大文件上传思路和总结、HTTP大文件上传学习、服务器集群实现大文件上传</title>
<url>/2019/06/01/HTTP%E5%A4%A7%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E6%80%9D%E8%B7%AF%E5%92%8C%E6%80%BB%E7%BB%93/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h5 id="HTTP大文件上传思路和总结"><a href="#HTTP大文件上传思路和总结" class="headerlink" title="HTTP大文件上传思路和总结"></a>HTTP大文件上传思路和总结</h5><h5 id="无法http大文件一次性上传的原因"><a href="#无法http大文件一次性上传的原因" class="headerlink" title="无法http大文件一次性上传的原因"></a>无法http大文件一次性上传的原因</h5><blockquote>
<p>存在文件上传大小的限制</p>
</blockquote>
<ol>
<li>默认一般nginx和tomcat都会对上传文件大小进行限制<br>nginx的配置文件nginx.conf设置 client_max_body_size 20m; </li>
<li>tomcat默认设置能接收HTTP POST请求的大小最大为2M。如果POST请求传递的数据大于2M,就会报错误。解决方案:修改tomcat的配置server.xml中<connector>标签,在该标签中添 加”maxPostSize”属性,将该属性值设置成你想要的最大值,单位是字节,或者把这个值设置为 0(maxPostSize=”0”)。 </connector></li>
<li><a href="https://www.jianshu.com/p/285ad45f60d1" target="_blank" rel="noopener">Tomcat项目的web配置</a>。工程项目web.xml的配置</li>
</ol>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><servlet></span><br><span class="line"><multipart-config></span><br><span class="line"><location></location></span><br><span class="line"><max-file-size></max-file-size></span><br><span class="line"><max-request-size></max-request-size></span><br><span class="line"><file-size-threshold></file-size-threshold></span><br><span class="line"></multipart-config></span><br><span class="line"></servlet></span><br></pre></td></tr></table></figure>
<blockquote>
<ol start="4">
<li>Spring配置文件限制上传文件的大小 </li>
</ol>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><bean id="multipartResolver"</span><br><span class="line"> class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></span><br><span class="line"> <property name="maxUploadSize" value="41943040" /> <!-- 40mb --></span><br><span class="line"> </bean></span><br></pre></td></tr></table></figure>
<a id="more"></a>
<h6 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h6><p>错误方案1:<br>1、分片上传大文件<br>2、服务端将每片文件存成临时文件,然后在进行合并文件。<br><strong>存在无核实合并文件是否正确的问题</strong></p>
<p>错误方案2:<br><img src="/images/Http%E5%88%86%E7%89%87%E4%B8%8A%E4%BC%A0%E6%B5%81%E7%A8%8B.jpg" alt="http分片上传方案"><br>md5文件摘要,确保合并文件没有问题。<br><strong>存在重复造轮子问题。在分布式服务器中进行分片上传无法控制同一个服务器上</strong></p>
<p>前端选择<a href="http://fex-team.github.io/webuploader/" target="_blank" rel="noopener">WebUploader</a>进行上传。<br>后端没有选择控制nginx路由到指定服务器,而是选择单点文件上传服务thrift。</p>
<blockquote>
<p>单点文件上传服务thrift提供功能</p>
</blockquote>
<ol>
<li>存储分片文件和合并分片文件进行存储</li>
<li>获取文件上传的状态</li>
</ol>
<p>前后端交互流程:</p>
<ul>
<li>前端向服务器获取上传文件的唯一标识。(可以写入数据库获取id标识)</li>
<li>前端将指定文件md5,分片上传 {file,chunk,chunks,md5value,唯一id标识, 额外自定义字段}</li>
<li>服务端检查是否存在唯一id标识,校验参数正确性 <ol>
<li>调用单点文件上传服务,存储指定文件路径夹下(使用 <code>md5Value+userId+唯一id标识</code> 作为唯一文件夹名称)</li>
<li>单点文件上传服务通过对分片文件进行排序统计返回是否可以进行合并文件操作。 | 单点文件上传服务通过对分片文件进行排序统计返回是否正在进行合并操作。</li>
</ol>
</li>
<li>前端收到合并信息停止上传文片文件并调用服务端进行文件合并。</li>
<li>服务端清理相关的文件夹。</li>
<li>当前端接收上传失败的信息,需要调用服务端清理相关文件的操作。</li>
</ul>
<hr>
<h6 id="安卓APK文件上传(不是特别规范,有待以后自己多加研究)"><a href="#安卓APK文件上传(不是特别规范,有待以后自己多加研究)" class="headerlink" title="安卓APK文件上传(不是特别规范,有待以后自己多加研究)"></a>安卓APK文件上传(不是特别规范,有待以后自己多加研究)</h6><blockquote>
<p>前端分片文件 -> 服务端 -> 单点文件服务</p>
</blockquote>
<ul>
<li>单点文件服务是否在合并文件 -> 服务端 -> 前端</li>
</ul>
<p><strong>这一步就是为了让服务端分片不去占用磁盘。降低出错下,产生大量临时文件</strong></p>
<blockquote>
<p>前端删除分片文件 -> 服务端 -> 单点文件服务 </p>
</blockquote>
<ul>
<li>单点文件服务删除分片文件 -> 服务端 -> 前端</li>
</ul>
<p><strong>增加这一步的原因:APK远程上传到CDN上耗时较长,容易超过request时间。改用轮询来处理,让界面不卡死,容易有反馈。</strong></p>
<blockquote>
<p>前端获取APK文件上传状态 -> 服务端 -> 单点文件服务</p>
</blockquote>
<ul>
<li>单点文件服务APK上传状态 -> 服务端 -> 前端</li>
</ul>
<p><img src="/images/APK%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0.jpg" alt="APK上传流程"></p>
<p>推荐了解网址:<br><a href="https://my.oschina.net/appnet/blog/1591830" target="_blank" rel="noopener">大文件分步式分片上传和续传</a><br><a href="https://blog.kazaff.me/2014/11/14/%E8%81%8A%E8%81%8A%E5%A4%A7%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0/" target="_blank" rel="noopener">聊聊大文件上传</a><br><a href="https://blog.breezelin.cn/scheme-nginx-php-js-upload-process.html" target="_blank" rel="noopener">HTTP文件上传的一个后端完善方案(NginX)</a><br><a href="https://segmafrontend.github.io/2018/09/19/%E5%A4%A7%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/" target="_blank" rel="noopener">大文件上传解决方案</a></p>
]]></content>
<tags>
<tag>后端</tag>
<tag>HTTP</tag>
</tags>
</entry>
<entry>
<title>TCP、HTTP的深入思考</title>
<url>/2020/10/12/TCP%E3%80%81HTTP%E7%9A%84%E6%B7%B1%E5%85%A5%E6%80%9D%E8%80%83/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h4 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h4><ol>
<li>TCP上传大文件是如何缓存数据的?当TCP缓存区满时是如何处理的?(滑动窗口)</li>
<li>TCP连接和Socket之间的关系是什么啊?</li>
<li>TCP连接保持keepalive时,http1.1请求如何区分进行区分?</li>
</ol>
<h4 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h4><p><a href="https://www.cnblogs.com/ShaYeBlog/p/9289711.html" target="_blank" rel="noopener">网络通信socket连接数上限</a> </p>
]]></content>
<tags>
<tag>HTTP</tag>
<tag>TCP</tag>
</tags>
</entry>
<entry>
<title>PERL学习</title>
<url>/2018/12/05/PERL%E5%AD%A6%E4%B9%A0/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a><br>perl 是脚本语言,在工作部署、编译等一些关于linux服务器上的事情都会跟perl打交道。写下自己学习路程,给自己日后总结。</p>
<h3 id="文档查询"><a href="#文档查询" class="headerlink" title="文档查询"></a>文档查询</h3><p>perldoc -f xxxx</p>
<h3 id="perl数据类型"><a href="#perl数据类型" class="headerlink" title="perl数据类型"></a>perl数据类型</h3><h4 id="字符串"><a href="#字符串" class="headerlink" title="字符串"></a>字符串</h4><p>定义字符串变量: my $name (my: 定义变量 $: 表示字符串 name: 变量名)<br><strong><em>注意点</em></strong> </p>
<ul>
<li>内插型字符串<blockquote>
<p>其他变量的数据可以在插入字符串中展示</p>
</blockquote>
</li>
</ul>
<a id="more"></a>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my $name = "Inigo MOntoya";</span><br><span class="line">print "My name is $name";</span><br></pre></td></tr></table></figure>
<ul>
<li>非内插型字符串<blockquote>
<p>无论什么字符都直接展示</p>
</blockquote>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">print 'You may have won $1,000,000';</span><br></pre></td></tr></table></figure>
<ul>
<li>转义字符<blockquote>
<p>有些特殊字符需要转义才能正输出</p>
</blockquote>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my $email = "andy@foo.com";</span><br><span class="line">print $email;</span><br><span class="line"># Prints "andy.com"</span><br><span class="line">解决方案:</span><br><span class="line">my $email = "andy\@foo.com";</span><br></pre></td></tr></table></figure>
<h4 id="字符串操作函数"><a href="#字符串操作函数" class="headerlink" title="字符串操作函数"></a>字符串操作函数</h4><ul>
<li>length() 获取字符串长度</li>
<li>subStr() 能够截取字符串</li>
</ul>
<h4 id="数组"><a href="#数组" class="headerlink" title="数组"></a>数组</h4><ul>
<li><p>创建</p>
</li>
<li><p>访问 $stooges[1]</p>
</li>
<li><p>数组长度 @stooges scalar @stooges</p>
</li>
<li><p>数组特性</p>
<ul>
<li>数组没有边界</li>
<li>数组合并会平展元素</li>
</ul>
</li>
<li><p>数组操作方法</p>
<ul>
<li>shift 从数组开头移除元素</li>
<li>unshift 将元素添加到数组开头</li>
<li>push 将元素添加到数组的结尾</li>
<li>pop 从数组的结尾移除元素</li>
</ul>
</li>
<li><p>数组高级用法</p>
<ul>
<li><p>提取数组的部分元素</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my @a = 'a'..'z';</span><br><span class="line">my @vowels = @a[0, 4, 8, 14, 20];</span><br></pre></td></tr></table></figure>
</li>
<li><p>分配数组块 使用splice</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">使用场景 数组拼接</span><br><span class="line">my @a = qw(Steve Stu Stan);</span><br><span class="line">$a[1] = ['Stewart', 'Zane'];</span><br><span class="line"># @a = ('Steve', ARRAY(0x841214c), 'Stan')</span><br><span class="line"></span><br><span class="line">my @a = qw(Steve Stu Stan);</span><br><span class="line">splice @a 1, 1, 'Stewart', 'Zane';</span><br><span class="line">#@a = ('Steve', 'Stewart', 'Zane', 'Stan')</span><br></pre></td></tr></table></figure>
<ul>
<li>利用map处理数组 (<strong>map 本质上是返回列表的foreach 循环</strong>)map</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my @ARRAY = (1, 2, 3, 4, 5);</span><br><span class="line">my %hash = map {$_ => $_ * 9} @ARRAY;</span><br><span class="line"># %hash = (1 => 9, 2 => 18, 3 => 27, 4 => 36, 5 => 45)</span><br></pre></td></tr></table></figure>
<ul>
<li>grep从数组中选择项目 (<strong>grep 本质上返回列表foreach循环</strong>)<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my @ARRAY = (1, 2, 3, 4, 5);</span><br><span class="line">my @NEWARRAY = grep {$_ * 9} @ARRAY</span><br><span class="line">{} 包含表达式的意思</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ul>
<h4 id="哈希"><a href="#哈希" class="headerlink" title="哈希"></a>哈希</h4><p>哈希就是键值对</p>
<ul>
<li>创建</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">1.方法一</span><br><span class="line">my %stooges = (</span><br><span class="line"> 'Moe', 'Howard',</span><br><span class="line"> 'Larry', 'Fine',</span><br><span class="line"> );</span><br><span class="line">2. 方法二</span><br><span class="line">my %stooges = (</span><br><span class="line"> Moe => 'Howard',</span><br><span class="line"> Larry => 'Fine',</span><br><span class="line"> )</span><br></pre></td></tr></table></figure>
<ul>
<li>哈希转数组</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my @hash_array = %stooges;</span><br><span class="line"># Contains ('Moe', 'Howard', 'Larry', 'Fine');</span><br></pre></td></tr></table></figure>
<ul>
<li><p>使用{}操作哈希<br>输出哈希值 更改哈希值 删除哈希条目</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">print $stooges{'Moe'};</span><br><span class="line">#Prints "Howard";</span><br><span class="line">$stooges{'Moe'} = 'NiHao';</span><br><span class="line">delete $stooges{'Moe'};</span><br><span class="line">unlink $stooges{'Moe'};</span><br><span class="line">delete 不会删除文件 unlink 为删除文件</span><br></pre></td></tr></table></figure>
</li>
<li><p>哈希的键/值数组</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">my @key = keys %stooges;</span><br><span class="line">my @value = values %stooges;</span><br></pre></td></tr></table></figure>
<ul>
<li><p>哈希特点</p>
<ul>
<li>哈希是无序的</li>
<li>无法排序</li>
</ul>
</li>
<li><p>哈希define exist的差异</p>
</li>
</ul>
]]></content>
<tags>
<tag>perl</tag>
</tags>
</entry>
<entry>
<title>ganglia安装使用</title>
<url>/2020/07/26/ganglia%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h3 id="ganglia"><a href="#ganglia" class="headerlink" title="ganglia"></a>ganglia</h3><h4 id="Ganglia简介"><a href="#Ganglia简介" class="headerlink" title="Ganglia简介"></a>Ganglia简介</h4><p><a href="http://ganglia.info/" target="_blank" rel="noopener">ganglia官网</a> <a href="https://zhuanlan.zhihu.com/p/48597372" target="_blank" rel="noopener">监控软件对比</a><br>   Ganglia是一个可扩展的分布式监视系统,用于高性能计算系统,例如集群和网格。它利用了广泛使用的技术,例如XML用于数据表示,XDR用于紧凑,便携式数据传输以及RRDtool用于数据存储和可视化。它使用精心设计的数据结构和算法来实现非常低的每节点开销和高并发性。它已用于链接大学校园和全球范围内的集群,并且可以扩展以处理具有2000个节点的集群。</p>
<p>伯克利大学的开源服务器监控软件。</p>
<h4 id="ganglia模块结构"><a href="#ganglia模块结构" class="headerlink" title="ganglia模块结构"></a>ganglia模块结构</h4><p>ganglia 分为gmond、gmetad、gweb</p>
<h4 id="Centos-安装与使用"><a href="#Centos-安装与使用" class="headerlink" title="Centos 安装与使用"></a>Centos 安装与使用</h4><h5 id="PHP-nginx-gweb的安装与使用"><a href="#PHP-nginx-gweb的安装与使用" class="headerlink" title="PHP+nginx+gweb的安装与使用"></a>PHP+nginx+gweb的安装与使用</h5><h6 id="Server"><a href="#Server" class="headerlink" title="Server"></a>Server</h6><p>安装并启动gmetad:</p>
<blockquote>
<p>gmetad展示收集到cpu等服务器性能数据。gmetad通过TCP拉取gmond信息</p>
</blockquote>
<ul>
<li><p><code>yum install ganglia-gmetad</code> gmetad拉取其他集群或者服务器的rrd数据</p>
</li>
<li><p>自定义设置/etc/ganglia/gmetad.conf</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">data_source "dev" localhost #自定义集群数据源为dev,localhost是指集群数据来自于本机</span><br><span class="line">gridname "Dev" #自定义表格为Dev</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p><img src="/images/gmetad%E9%85%8D%E7%BD%AE%E5%BD%B1%E5%93%8D%E5%85%83%E7%B4%A0.png" alt="gmetad配置影响元素"></p>
<ul>
<li><code>chkconfig gmetad on</code> centos6开启开机自动启动</li>
<li><code>service gmetad start</code> 启动gmetad程序</li>
</ul>
<a id="more"></a>
<p><strong><em>安装并启动gweb:</em></strong> </p>
<p><strong>两种方式安装:</strong> </p>
<ol>
<li>第一种方式自定义编译安装(当时因为担心yum提供的不太完整,所以采用源码ganglia-web包编译安装):</li>
</ol>
<ul>
<li>下载安装ganglia-web包</li>
<li><ul>
<li>下载最新ganglia-web最新安装包 <a href="https://sourceforge.net/projects/ganglia/files/ganglia-web/" target="_blank" rel="noopener">下载地址</a></li>
</ul>
</li>
<li><ul>
<li>解压ganglia-web的压缩包</li>
</ul>
</li>
<li><ul>
<li>创建www-data的用户 <code>useradd www-data</code></li>
</ul>
</li>
<li><ul>
<li>切换至ganglia-web的解压缩包路径下执行: <code>make install</code> 编译安装ganglia-web</li>
</ul>
</li>
</ul>
<ol start="2">
<li>第二种方式安装: </li>
</ol>
<ul>
<li><p>yum install ganglia-web</p>
</li>
<li><p><code>/var/lib/ganglia-web/dwoo/compiled</code>、<code>/var/lib/ganglia-web/dwoo/cache</code>文件夹写入权限用户组,需要看php-fpm启动用户(默认为:apache)</p>
</li>
<li><ul>
<li><code>chown -R apache:apache ./</code></li>
</ul>
</li>
</ul>
<p><strong>安装nginx代理访问ganglia-web的应用</strong> </p>
<ul>
<li>下载安装启动nginx <a href="https://www.nginx.com/resources/wiki/start/topics/tutorials/install/" target="_blank" rel="noopener">nginx官网安装教程</a></li>
<li>nginx配置gweb</li>
</ul>
<ol>
<li>创建了一个nginx的 ganglia.conf,并将这个文件 <code>include conf.d/aloha_ganglia.conf;</code>到nginx.conf中。<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">ganglia.conf</span><br><span class="line">server {</span><br><span class="line"> listen 80 default_server;</span><br><span class="line"></span><br><span class="line"> access_log /data/log/nginx/access_ganglia_http.log main;</span><br><span class="line"> gzip on;</span><br><span class="line"></span><br><span class="line"> # root指向/usr/share/ganglia-webfrontend</span><br><span class="line"> root /usr/share/ganglia-webfrontend;</span><br><span class="line"> index index.php;</span><br><span class="line"></span><br><span class="line"> location ~ \.php$ {</span><br><span class="line"> fastcgi_pass localhost:9000;</span><br><span class="line"> include fastcgi.conf;</span><br><span class="line"> }</span><br><span class="line"> }</span><br></pre></td></tr></table></figure>
</li>
</ol>
<ul>
<li><p><code>yum install php-fpm</code> php-fpm(FastCGI Process Manager)安装php的fastcgi进程管理包</p>
</li>
<li><p><code>chkconfig php-fpm on</code> centos6开启开机自动启动</p>
</li>
<li><p><code>service php-fpm start</code> 启动php-fpm</p>
</li>
</ul>
<h6 id="Client-Node"><a href="#Client-Node" class="headerlink" title="Client/Node"></a>Client/Node</h6><blockquote>
<p>定义单广播地址、端口和群播的端口,定义gmetad拉取数据端口。<br>需要配置集群主节点、子节点。子节点负责发送数据到主节点、主节点收集子节点数据,同时开放端口共gmetab提取数据。</p>
</blockquote>
<ul>
<li><p><code>yum install ganglia-gmond</code> 使用yum安装 ganglia-gmond</p>
</li>
<li><p><code>chkconfig gmond on</code> centos6开启开机自动启动</p>
</li>
<li><p><code>service gmond start</code> 启动gmond</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cluster {</span><br><span class="line"> name = "dev" #指定data_source的名称,集群名称</span><br><span class="line"> owner = "unspecified"</span><br><span class="line"> latlong = "unspecified"</span><br><span class="line"> url = "unspecified"</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">udp_send_channel { #udp包的发送通道</span><br><span class="line"> #bind_hostname = yes # Highly recommended, soon to be default.</span><br><span class="line"> # This option tells gmond to use a source address</span><br><span class="line"> # that resolves to the machine's hostname. Without</span><br><span class="line"> # this, the metrics may appear to come from any</span><br><span class="line"> # interface and the DNS names associated with</span><br><span class="line"> # those IPs will be used to create the RRDs.</span><br><span class="line"> #mcast_join = 239.2.11.71 </span><br><span class="line"> host = 192.168.0.2 # 单播地址</span><br><span class="line"> port = 8649 # 单播端口</span><br><span class="line"> ttl = 1</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">udp_recv_channel { #接收udp包配置</span><br><span class="line"> #mcast_join = 239.2.11.71</span><br><span class="line"> port = 8649 #gmond收到广播端口</span><br><span class="line"> #bind = 239.2.11.71</span><br><span class="line"> retry_bind = true</span><br><span class="line"> # Size of the UDP buffer. If you are handling lots of metrics you really</span><br><span class="line"> # should bump it up to e.g. 10MB or even higher.</span><br><span class="line"> # buffer = 10485760</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">tcp_accept_channel {</span><br><span class="line"> port = 8649 #开放gmetad的端口,常用于集群主节点</span><br><span class="line"> # If you want to gzip XML output</span><br><span class="line"> gzip_output = no</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">send_metadata_interval 30 #改成30秒,一定要改,否则子节点数据不会提交</span><br></pre></td></tr></table></figure>
<h6 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h6><table>
<thead>
<tr>
<th align="center">应用</th>
<th align="center">配置文件</th>
<th align="center">数据文件</th>
<th align="center">命令</th>
</tr>
</thead>
<tbody><tr>
<td align="center">ganglia-gmetad</td>
<td align="center">/etc/ganglia/gmetad.conf</td>
<td align="center"></td>
<td align="center">service gmetab start、chkconfig gmetab on</td>
</tr>
<tr>
<td align="center">ganglia-gmond</td>
<td align="center">/etc/ganglia/gmond.conf</td>
<td align="center"></td>
<td align="center">service gmond start、chkconfig gmond on</td>
</tr>
<tr>
<td align="center">ganglia-web</td>
<td align="center"></td>
<td align="center">/var/lib/ganglia-web/dwoo/compiled、/var/lib/ganglia-web/dwoo/cache、/usr/share/ganglia-webfrontend</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">rrdtool</td>
<td align="center"></td>
<td align="center">/var/lib/ganglia/rrds</td>
<td align="center"></td>
</tr>
</tbody></table>
<h4 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h4><p><a href="http://legendtkl.com/2017/08/12/understanding-ganglia-1/" target="_blank" rel="noopener">深入理解 Ganglia 之 Overview</a><br><a href="https://wiki.archlinux.org/index.php/Ganglia" target="_blank" rel="noopener">nginx 配置ganglia参考</a><br><a href="https://www.dazhuanlan.com/2019/08/21/5d5d10f64d4ed/" target="_blank" rel="noopener">Ganglia部署实战</a><br><a href="https://github.com/ganglia/monitor-core/wiki/Ganglia-Quick-Start" target="_blank" rel="noopener">Ganglia Quick Start</a></p>
]]></content>
<tags>
<tag>后端</tag>
<tag>运维</tag>
</tags>
</entry>
<entry>
<title>MacOX安装JMagick、Jmagick安装学习、Jmagick爬坑指南</title>
<url>/2019/01/29/MacOX%E5%AE%89%E8%A3%85JMagick/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h5 id="MacOX安装JMgick原因和使用JMagick执行流程"><a href="#MacOX安装JMgick原因和使用JMagick执行流程" class="headerlink" title="MacOX安装JMgick原因和使用JMagick执行流程"></a>MacOX安装JMgick原因和使用JMagick执行流程</h5><blockquote>
<p>目前对于图片处理,很少采用java去处理图片,性能不是很好。目前我们公司采用ImageMagick图片处理,有些采用Process执行cmd命令,有些采用jmagick的java接口进行处理。</p>
</blockquote>
<p><a href="https://www.imagemagick.org/index.php" target="_blank" rel="noopener">ImageMagick官网</a><br>通过jmagick调用native方法来调用JMagick的方法, 再由JMagick调用ImageMagick的方法。jmagick使用Java代码写的。JMagick使用C语言写的,含有java JNI生成的头文件。ImageMagick使用C语言写的,没有含有java JNI生成的头文件。 <a href="https://elf8848.iteye.com/blog/455675" target="_blank" rel="noopener">ImageMagick介绍和执行流程原因解释</a> </p>
<ul>
<li>执行流程: </li>
<li>jmagick(java) –> JMagick(C) –> ImageMagick(C)</li>
</ul>
<a id="more"></a>
<h5 id="本地MacOX执行遇到问题"><a href="#本地MacOX执行遇到问题" class="headerlink" title="本地MacOX执行遇到问题"></a>本地MacOX执行遇到问题</h5><p>new MagickInfo(“”); 调用时出现无法加载MagickLoader,实际无法加载资源JMagick;</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">ClassLoader.getSystemClassLoader().loadClass("magick.MagickLoader").newInstance();</span><br><span class="line">public class MagickLoader {</span><br><span class="line"> static { </span><br><span class="line"> System.loadLibrary("JMagick"); </span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>因为jmagick的接口都是本地调用,需要加载JNI的JMagick动态库。因此,接下来我们的主要任务是生成JMagick的动态库。<br>通过Brew install ImageMagick直接安装使用。但是JMagick只用源码包,需要进行编译安装。尽量将ImageMagick和JMagick安装在同一路径下。</p>
<h6 id="Brew-install-ImageMagick-开始编译JMagick,生成JMagick动态库。"><a href="#Brew-install-ImageMagick-开始编译JMagick,生成JMagick动态库。" class="headerlink" title="Brew install ImageMagick,开始编译JMagick,生成JMagick动态库。"></a>Brew install ImageMagick,开始编译JMagick,生成JMagick动态库。</h6><ul>
<li>遇到JMagick出现找不到api.h文件(实际上在ImageMagick-7是没有这个api.h文件,在ImageMagick-6是有api.h文件):<br>checking magick/api.h usability… no<br>checking magick/api.h presence… no<br>checking for magick/api.h… no<br>configure: error: ‘Unable to find ImageMagick header files’。</li>
</ul>
<p>出现这种情况通过pkg-config、修改configure的参数、查看configure源码,根据报错来修改文件路径,让其能够找到header files等等方法。这些方法都没有解决问题。 </p>
<ul>
<li><a href="http://promiselove.github.io/2017/11/30/Mac%E5%AE%89%E8%A3%85Imagemagick%E5%92%8CJMagick/" target="_blank" rel="noopener">该文章找到原因</a></li>
</ul>
<p>主要是因为JMagick版本老(最新版本是2013更新的),无法跟上ImageMagick的节奏。ImageMagick的文件位置都发生了很大的变化。(注.看configure源码,可以看到一些文件路径不在了)。</p>
<ul>
<li><p>我们需要做的是:ImageMagick不要安装最新版本,安装旧版ImageMaick6相关版本,并且下载JMagick6.4.0版本。</p>
</li>
<li><p>根据configure的部分源码</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># Check whether --with-magick-home was given.</span><br><span class="line">if test "${with_magick_home+set}" = set; then</span><br><span class="line"> withval=$with_magick_home; MAGICK_HOME=${withval}</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">for MPATH in /usr /usr/local /usr/local/ImageMagick /usr/local/ImageMagick-${VER_MAJOR}.${VER_MINOR}.${VER_MICRO} ${MAGICK_HOME} ; do</span><br><span class="line"> # Location before IM 6.3.8.something</span><br><span class="line"> if test -f ${MPATH}/include/magick/api.h ; then</span><br><span class="line"> MAGICK_LIB_PATH=${MPATH}/lib</span><br><span class="line"> MAGICK_LIBS="-L${MPATH}/lib -lMagick"</span><br><span class="line"> MAGICK_INCLUDES=-I${MPATH}/include</span><br><span class="line"> MAGICK_REALHOME=${MPATH}</span><br><span class="line"> fi</span><br><span class="line"> # Location after IM 6.3.8.something</span><br><span class="line"> if test -f ${MPATH}/include/ImageMagick/magick/api.h ; then</span><br><span class="line"> MAGICK_LIB_PATH=${MPATH}/lib</span><br><span class="line"> MAGICK_LIBS="-L${MPATH}/lib -lMagick"</span><br><span class="line"> MAGICK_INCLUDES=-I${MPATH}/include/ImageMagick</span><br><span class="line"> MAGICK_REALHOME=${MPATH}</span><br><span class="line"> fi</span><br><span class="line">done</span><br></pre></td></tr></table></figure>
<p>因为编译的该文件的<code>${MPATH}/include/magick/api.h</code>。由于目前include路径下存放的文件多了一层Imagemagick-6,我们要将Imagemagick-6里的所有文件ln -s到include目录下。<br>eg:我的configure命令:</p>
<ul>
<li><p><code>JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/" CFLAGS="-I/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/include/ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/include/darwin" ./configure --with-magick-inc-dir=-I/usr/local/Cellar/imagemagick/6.9.10-14/include/ --with-magick-lib-dir=-L/usr/local/Cellar/imagemagick/6.9.10-14/lib/</code></p>
</li>
<li><p><code>./configure --with-java-home=</code>/usr/libexec/java_home<code>--with-java-includes=/System/Library/Frameworks/JavaVM.framework/Headers --with-magick-inc-dir=/usr/local/Cellar/imagemagick@6/6.9.10-14/include/ --with-magick-lib-dir=/usr/local/Cellar/imagemagick@6/6.9.10-14/lib/</code></p>
</li>
</ul>
<p>接下来有些问题下面链接可以解决一部分由<br><a href="https://www.zybuluo.com/yibo/note/125940" target="_blank" rel="noopener">Mac OS X 安装JMagick</a>来解决我们configure的问题。<br>因为还有编译文件中的<code>withval=$with_magick_home; MAGICK_HOME=${withval}</code>,因此我们可以通过增加 – with_magick_home参数,解决某些问题。</p>
<p>make过程中ERROR :</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">make[1]: Entering directory `/usr/local/Cellar/jmagick-6.4.0/6.4.0/src'</span><br><span class="line">make[2]: Entering directory `/usr/local/Cellar/jmagick-6.4.0/6.4.0/src/magick'</span><br><span class="line">make[2]: *** No rule to make target `/usr/local/Cellar/imagemagick/6.9.10-14/include/magick/api.h', needed by `/usr/local/Cellar/jmagick-6.4.0/6.4.0/obj/magick/magick_PixelPacket.lo'. Stop.</span><br><span class="line">make[2]: Leaving directory `/usr/local/Cellar/jmagick-6.4.0/6.4.0/src/magick'</span><br><span class="line">make[1]: *** [dir_target] Error 2</span><br><span class="line">make[1]: Leaving directory `/usr/local/Cellar/jmagick-6.4.0/6.4.0/src'</span><br><span class="line">make: *** [dir_target] Error 2</span><br></pre></td></tr></table></figure>
<p>因为api.h的路径不对,可以通过ln -s 下。eg: cd /usr/local/Cellar/ && ln -s ./imagemagick@6/ imagemagick</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">make[1]: Entering directory `/Users/yibo/Downloads/6.4.0/src'</span><br><span class="line">make[2]: Entering directory `/Users/yibo/Downloads/6.4.0/src/magick'</span><br><span class="line">../../Make.rules:175: *** missing separator. Stop.</span><br><span class="line">make[2]: Leaving directory `/Users/yibo/Downloads/6.4.0/src/magick'</span><br><span class="line">make[1]: *** [dir_target] Error 2</span><br><span class="line">make[1]: Leaving directory `/Users/yibo/Downloads/6.4.0/src'</span><br><span class="line">make: *** [dir_target] Error 2</span><br></pre></td></tr></table></figure>
<p>修改Make.rules, 175,176 四个空格换成tab,参见: <a href="http://stackoverflow.com/a/15880079/3368344" target="_blank" rel="noopener">http://stackoverflow.com/a/15880079/3368344</a></p>
<h6 id="make-make-install-成功之后"><a href="#make-make-install-成功之后" class="headerlink" title="make make install 成功之后"></a>make make install 成功之后</h6><p>在/usr/local/lib会生成三个文件</p>
<ul>
<li>jmagick-6.4.0.jar</li>
<li>libJMagick-6.4.0.so</li>
<li>libJMagick.so -> ./libJMagick-6.4.0.so<br>在动态链接库在不同平台的形式:</li>
<li>windows .dll</li>
<li>linux .so</li>
<li>macos .dylib (最新的动态链接库) .jnilib (以前的动态链接库)<br>需要在mac上使用动态链接库,需要使用dylib的后缀的名称。<br>cp libJMagick.so libJMagick.dylib</li>
</ul>
<h5 id="测试使用"><a href="#测试使用" class="headerlink" title="测试使用"></a>测试使用</h5><p>IDEA的单元测试没有问题</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">try {</span><br><span class="line"> String property = System.getProperty("java.library.path");</span><br><span class="line"> System.out.println(property); // 输出/usr/local/lib</span><br><span class="line"> // System.setProperty("java.library.path", "/usr/local/lib");</span><br><span class="line"> // System.loadLibrary("JMagick");</span><br><span class="line"> System.out.println("success");</span><br><span class="line"> MagickInfo magickInfo = new MagickInfo("myImage");</span><br><span class="line"> } catch (MagickException e) {</span><br><span class="line"> System.out.println(e);</span><br><span class="line"> }</span><br></pre></td></tr></table></figure>
<p>IDEA的Tomcat需要额外处理:<br>tomcat的VM options增加:<br>-Djmagick.systemclassloader=no -Djava.library.path=/usr/local/lib</p>
<p>参考资料:<br><a href="https://www.zybuluo.com/yibo/note/125940" target="_blank" rel="noopener">Mac OS X 安装JMagick</a><br><a href="http://promiselove.github.io/2017/11/30/Mac%E5%AE%89%E8%A3%85Imagemagick%E5%92%8CJMagick/" target="_blank" rel="noopener">Mac安装Imagemagick和JMagick</a><br><a href="http://noahsnail.com/2016/12/12/2016-12-12-Linux%E7%9A%84pkg-config%E5%91%BD%E4%BB%A4/" target="_blank" rel="noopener">Linux的pkg-config命令</a><br><a href="https://elf8848.iteye.com/blog/455675" target="_blank" rel="noopener">ImageMagick +Jmagick安装</a> </p>
]]></content>
<tags>
<tag>后端</tag>
</tags>
</entry>
<entry>
<title>通过nginx控制http转https、http转https请求实现、http变成https请求</title>
<url>/2019/06/01/nginx%E6%8E%A7%E5%88%B6http%E8%BD%AChttps/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h5 id="通过nginx控制http转https"><a href="#通过nginx控制http转https" class="headerlink" title="通过nginx控制http转https"></a>通过nginx控制http转https</h5><blockquote>
<p>现在越来越多的公司选择https的协议。<br>我司的做法: nginx上进行https的认证,在请求在交给tomcat进行处理。而tomcat处理的是http的请求。因为当进行tomcat应用程进行重定向时直接使用http的请求在处理。</p>
</blockquote>
<p>为了保证整个请求都是https请求。我们需要将返回的请求进行重定向为https的。</p>
<p>通过proxy-redirect修改Location中的url。</p>
<ol>
<li>将 conf/conf.d/proxy_params文件中 <code>proxy_redirect off;</code> 注释掉</li>
<li>将<br>proxy_redirect <a href="http://www.xxxxx.com/" target="_blank" rel="noopener">http://www.xxxxx.com/</a> <a href="https://www.xxxxx.com/" target="_blank" rel="noopener">https://www.xxxxx.com/</a>;<br>proxy_redirect <a href="http://xxxxx.com/" target="_blank" rel="noopener">http://xxxxx.com/</a> <a href="https://xxxx.com/" target="_blank" rel="noopener">https://xxxx.com/</a>;<br>放入到server {}块中。</li>
</ol>
<p>如果一直使用http的协议,容易出现网页中有代码注入广告的现象。运营商就经常将小广告注入到网页中,一般是网页的右下角有个摆动的小图标。使用https的协议,能够降低这一现象。不过一山更比一山高,https的也会有网页代码注入的现象,不过特别隐蔽。我遇到表现是打开应用的中网页时会启动其他应用程序如京东、淘宝。<a href="https://www.zhihu.com/question/35720092/answer/523563873" target="_blank" rel="noopener">对这一现象的说明和解决方案</a></p>
<p>参考资料:<br><a href="http://info.siven.net/posts/d925bb5d.html" target="_blank" rel="noopener">Nginx SSL 结合Tomcat 重定向URL变成HTTP的问题</a></p>
]]></content>
<tags>
<tag>后端</tag>
</tags>
</entry>
<entry>
<title>influxdb+grafana+telegraf服务器统计</title>
<url>/2020/08/06/influxdb-grafana-telegraf%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%BB%9F%E8%AE%A1/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h2 id="influxdb-grafana-telegraf服务器统计"><a href="#influxdb-grafana-telegraf服务器统计" class="headerlink" title="influxdb+grafana+telegraf服务器统计"></a>influxdb+grafana+telegraf服务器统计</h2><h3 id="influxdb"><a href="#influxdb" class="headerlink" title="influxdb"></a>influxdb</h3><blockquote>
<p>类似mysql数据库,时序图的数据库<br> <a href="https://docs.influxdata.com/influxdb/v1.8/introduction/install/" target="_blank" rel="noopener">开源Influxdb安装指引</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">应用</th>
<th align="center">配置文件</th>
<th align="center">数据文件</th>
<th align="center">命令</th>
</tr>
</thead>
<tbody><tr>
<td align="center">influx</td>
<td align="center">/etc/influxdb/influxdb.conf<br>设置meta、data、wal数据存放地址</td>
<td align="center">/var/lib/influxdb/…</td>
<td align="center">influxd config: 输出influxdb的配置文件</td>
</tr>
</tbody></table>
<p>备注:</p>
<ul>
<li>当前启动influxdb失败,可能存在meta、data、wal数据存放地址用户组没有访问权限导致的。<code>chown -R influxdb:influxdb [meta、data、wal数据存放地址]</code></li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 第一步 设置influxdb的仓库源</span><br><span class="line">cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo</span><br><span class="line">[influxdb]</span><br><span class="line">name = InfluxDB Repository - RHEL \$releasever</span><br><span class="line">baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable</span><br><span class="line">enabled = 1</span><br><span class="line">gpgcheck = 1</span><br><span class="line">gpgkey = https://repos.influxdata.com/influxdb.key</span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line"># 第二步 启动influxdb和设置开机自启动服务</span><br><span class="line">sudo yum install influxdb</span><br><span class="line">sudo service influxdb start</span><br><span class="line">sudo chkconfig influxdb on</span><br><span class="line"></span><br><span class="line">//////////</span><br><span class="line">sudo yum install influxdb</span><br><span class="line">sudo systemctl start influxdb</span><br><span class="line">sudo systemctl enable influxdb</span><br></pre></td></tr></table></figure>
<a id="more"></a>
<p><strong>influxdb连接与操作</strong></p>
<table>
<thead>
<tr>
<th align="center">命令</th>
<th align="center">操作</th>
</tr>
</thead>
<tbody><tr>
<td align="center">influx</td>
<td align="center">连接influxdb的server</td>
</tr>
<tr>
<td align="center">influx -precision rfc3339</td>
<td align="center">以rfc3339协议格式连接influxdb的server</td>
</tr>
<tr>
<td align="center">show databases</td>
<td align="center">显示所有数据库</td>
</tr>
<tr>
<td align="center">use [xxx]</td>
<td align="center">进入[xxx]数据库</td>
</tr>
<tr>
<td align="center">show measurements</td>
<td align="center">显示[xxx]数据库中的表</td>
</tr>
<tr>
<td align="center">其他命令跟mysql命令差不多</td>
<td align="center"></td>
</tr>
</tbody></table>
<p><strong>http访问influxdb</strong><br>默认端口 8086<br>eg: 192.168.100.100:8086</p>
<h3 id="grafana"><a href="#grafana" class="headerlink" title="grafana"></a>grafana</h3><blockquote>
<p>展示influxdb时序数据的Web应用<br><a href="https://grafana.com/docs/grafana/latest/installation/rpm/" target="_blank" rel="noopener">grafana centos 安装</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 第一步 设置grafana的仓库源</span><br><span class="line">vi /ect/yum.repos.d/grafana.repo</span><br><span class="line"></span><br><span class="line">[grafana]</span><br><span class="line">name=grafana</span><br><span class="line">baseurl=https://packages.grafana.com/oss/rpm</span><br><span class="line">repo_gpgcheck=1</span><br><span class="line">enabled=1</span><br><span class="line">gpgcheck=1</span><br><span class="line">gpgkey=https://packages.grafana.com/gpg.key</span><br><span class="line">sslverify=1</span><br><span class="line">sslcacert=/etc/pki/tls/certs/ca-bundle.crt</span><br><span class="line"></span><br><span class="line"># 第二步 启动grafana和设置开机自启动服务</span><br><span class="line">sudo yum install grafana</span><br><span class="line">sudo service grafana-server start</span><br><span class="line">sudo chkconfig --add grafana-server</span><br></pre></td></tr></table></figure>
<h4 id="配置grafana访问和数据源"><a href="#配置grafana访问和数据源" class="headerlink" title="配置grafana访问和数据源"></a>配置grafana访问和数据源</h4><blockquote>
<p><a href="https://grafana.com/docs/grafana/latest/administration/configuration/" target="_blank" rel="noopener">grafana config配置</a><br><a href="https://grafana.com/docs/grafana/latest/features/datasources/add-a-data-source/" target="_blank" rel="noopener">grafana Web配置数据源</a></p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">应用</th>
<th align="center">配置文件</th>
<th align="center">数据文件</th>
<th align="center">命令</th>
</tr>
</thead>
<tbody><tr>
<td align="center">grafana</td>
<td align="center">/etc/grafana/grafana.ini</td>
<td align="center"></td>
<td align="center"></td>
</tr>
</tbody></table>
<p><strong>修改访问grafana网页端口</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># The HTTP port to use</span><br><span class="line">;http_port = 3000</span><br></pre></td></tr></table></figure>
<p>默认管理员: admin admin<br>eg:<br>访问地址: 192.168.100.100:3000</p>
<p><img src="/images/grafanaWeb%E6%95%B0%E6%8D%AE%E6%BA%90%E9%85%8D%E7%BD%AE.png" alt="grafanaWeb数据源配置"></p>
<h3 id="telegraf"><a href="#telegraf" class="headerlink" title="telegraf"></a>telegraf</h3><blockquote>
<p>服务器性能数据cpu等性能统计<br><a href="https://docs.influxdata.com/telegraf/v1.12/introduction/installation/" target="_blank" rel="noopener">telegraf 安装</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 第一步 设置telegraf的仓库源</span><br><span class="line">cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo</span><br><span class="line"> [influxdb]</span><br><span class="line"> name = InfluxDB Repository - RHEL \$releasever</span><br><span class="line"> baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable</span><br><span class="line"> enabled = 1</span><br><span class="line"> gpgcheck = 1</span><br><span class="line"> gpgkey = https://repos.influxdata.com/influxdb.key</span><br><span class="line"> EOF</span><br><span class="line"></span><br><span class="line"># 第二步 启动telegraf和设置开机自启动服务</span><br><span class="line">sudo yum install telegraf</span><br><span class="line">sudo service telegraf start</span><br><span class="line">sudo chkconfig telegraf on</span><br><span class="line"></span><br><span class="line">//////////</span><br><span class="line">sudo yum install telegraf</span><br><span class="line">sudo systemctl start telegraf</span><br><span class="line">sudo systemctl enable telegraf</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr>
<th align="center">应用</th>
<th align="center">配置文件</th>
<th align="center">数据文件</th>
<th align="center">命令</th>
</tr>
</thead>
<tbody><tr>
<td align="center">telegraf</td>
<td align="center">/etc/telegraf/telegraf.conf</td>
<td align="center"></td>
<td align="center"></td>
</tr>
</tbody></table>
<p><strong>修改config</strong></p>
<blockquote>
<p>设置指定influxdb数据源、数据库名称、当前服务器hostname</p>
</blockquote>
<p>urls = [“<a href="http://192.168.100.100:8086"]" target="_blank" rel="noopener">http://192.168.100.100:8086"]</a><br>database = “telegraf”<br>hostname = “172.18.0.x” # (可以用开机脚本修改)</p>
<p><strong>配置开机时自动修改hostname</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">vi /etc/rc.local</span><br><span class="line"></span><br><span class="line"># centos6:</span><br><span class="line">IP=$(/sbin/ifconfig | /bin/awk '/inet addr/{print substr($2,6)}'|grep 172.16) && /bin/sed -i -E "s/hostname\s*=\s*\".*?\"/hostname=\"$IP\"/" /etc/telegraf/telegraf.conf</span><br><span class="line"></span><br><span class="line"># centos7:</span><br><span class="line">IP=$(/sbin/ifconfig | /bin/awk '/inet /{print substr($2,1)}'|grep 172.16) && /bin/sed -i -E "s/hostname\s*=\s*\".*?\"/hostname=\"$IP\"/" /etc/telegraf/telegraf.conf</span><br></pre></td></tr></table></figure>
]]></content>
<tags>
<tag>后端</tag>
<tag>运维</tag>
</tags>
</entry>
<entry>
<title>phantomjs截图文字不显示、phantmjs文字不显示、phantomJS学习了解</title>
<url>/2018/12/18/phantomjs%E6%88%AA%E5%9B%BE%E6%96%87%E5%AD%97%E4%B8%8D%E6%98%BE%E7%A4%BA/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h4 id="PhantomJS-基于-webkit-内核的无界面浏览器"><a href="#PhantomJS-基于-webkit-内核的无界面浏览器" class="headerlink" title="PhantomJS 基于 webkit 内核的无界面浏览器"></a>PhantomJS 基于 webkit 内核的无界面浏览器</h4><blockquote>
<p>webkit:<br>webkit tutorial : <a href="https://www.paulirish.com/2013/webkit-for-developers/" target="_blank" rel="noopener">https://www.paulirish.com/2013/webkit-for-developers/</a><br>中文了解:<br><a href="https://www.jianshu.com/p/a129b05e2216" target="_blank" rel="noopener">https://www.jianshu.com/p/a129b05e2216</a></p>
</blockquote>
<h4 id="学习缘由"><a href="#学习缘由" class="headerlink" title="学习缘由"></a>学习缘由</h4><p>运营活动需要将用户这一年的数据展示出来,用户是可以截图的。<br>当时方案好几个:</p>
<ol>
<li>用户自己手动截图,但是一个用户截图效果有可能会不太好,也太麻烦,最无奈的方案。</li>
<li>通过前端来完成给用户截图的功能。(后续被前端废弃。)</li>
<li>服务端对网页进行截图,然后用户直接下载。(推荐使用PhantomJS)<a id="more"></a>
<h4 id="使用过程和了解"><a href="#使用过程和了解" class="headerlink" title="使用过程和了解"></a>使用过程和了解</h4><a href="http://phantomjs.org/" target="_blank" rel="noopener">phantomjs官网</a><br>下载包分为源码代码包和二进制代码包。<blockquote>
<p>(因为之前不明白centos RPM 包含源码代码包和二进制代码包,碰到了一些麻烦。)</p>
</blockquote>
</li>
</ol>
<p>phantmjs分平台的软件是二进制包,下载就可以使用。<br>但是值得注意的是mac和linux的平台上,有个细节linux需要依赖fonts。<br>一开始我们没有注意这个问题,才有今天的文章。在mac上截图很正常,但是centos服务器截图就是没有文字。</p>
<blockquote>
<p><strong>分析:</strong><br>当时出现在服务器没有显示文字,不明白。</p>
</blockquote>
<ol>
<li>开始怀疑是字体颜色的问题,修改后发现没有效果。</li>
<li>再次认为是JS的原因,通过对请求生成的html进行输出和截图,发现有可能不是html的问题。</li>
<li>最后查阅相关资料,浏览器查找结果有些展示说是字体的问题(因为与字体有关,操作麻烦,直接放弃。想找简单的方法处理),最后没有办法才尝试,字体相关操作。</li>
</ol>
<p><a href="https://bingozb.github.io/51.html" target="_blank" rel="noopener">phantomjs实现服务端屏幕截图</a><br>这篇博客对linux服务端phantomJS截图的做了很深刻的讲解。但是字体使用是微软雅黑。按照这篇博客讲解操作,我们服务器这边截图的字体样式有点难看,太纤细了。</p>
<p>因此将字体变得好看成为重中之重。 </p>
<ol>
<li>查询当前MAC浏览器的字体是什么类型?? (WhatFont)查询字体 结果:PingFang SC </li>
<li>前端指定字体样式:font-family {} 没有效果 </li>
<li>前端@font-face 下载字体 考虑网速的问题,需要压缩字体。没有执行</li>
<li>服务端寻找字体,放到服务器使用。 {最终解决方案} 首选字体PingFang SC</li>
</ol>
<p><a href="http://jser.me/2016/05/31/phantomjs%E5%9C%A8linux%E4%B8%8B%E6%88%AA%E5%9B%BE%E4%B8%AD%E6%96%87%E5%AD%97%E4%BD%93%E9%97%AE%E9%A2%98.html" target="_blank" rel="noopener">phantomjs在linux下截图中文字体问题</a><br>给我们很好的思路,尝试拷贝字体。</p>
<ol>
<li>直接mac 命令行拷贝 没有权限失败。</li>
<li>通过mac 命令行 (open /) 打开系统文件,进行/System/Library/Fonts的PingFang.ttc 拖拽拷贝成功。</li>
<li>将PingFang.ttc 放置到linux指定位置<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"> mkdir /usr/share/fonts/custom</span><br><span class="line">cp *.ttf /usr/share/fonts/custom</span><br><span class="line">fc-cache -fv</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>经过后续实操经验证明,其实Linux是能够接受ttc格式字体,而且经过压缩后ttf格式字体,存在大量字体丢失情况。<br><del>需要将PingFang.ttc的格式转换为linux可用ttf格式。上面博客推荐的转换地址发现,超过了上传文件最大限度。</del><br><del>1. <a href="https://www.files-conversion.com/font-converter.php" target="_blank" rel="noopener">Convert Font Files</a> 这个网址转换成功。</del></p>
<p>但是新的问题:浏览器上使用的是PingFang SC字体。linux服务器使用的PingFang字体,导致看到和截图字体样式不一致。</p>
<p>linux 建立字体索引 更新缓存</p>
<ul>
<li>mkfontscale</li>
<li>mkfontdir</li>
<li>fc-cache</li>
</ul>
<h4 id="附赠代码"><a href="#附赠代码" class="headerlink" title="附赠代码"></a>附赠代码</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">> renderImage.js phantomJS 的执行js代码</span><br><span class="line"></span><br><span class="line">"use strict";</span><br><span class="line">var page = require('webpage').create();</span><br><span class="line">var system = require('system'), pageWidth, pageHeight, pageUrl, format, quality, imagePath;</span><br><span class="line">if (system.args.length != 7) {</span><br><span class="line"> console.log('Usage: renderImage.js <pageWidth pageHeight pageUrl format quality imagePath>');</span><br><span class="line"> phantom.exit(1);</span><br><span class="line">} else {</span><br><span class="line"> pageWidth = system.args[1]</span><br><span class="line"> pageHeight = system.args[2];</span><br><span class="line"> pageUrl = system.args[3];</span><br><span class="line"> format = system.args[4];</span><br><span class="line"> quality = system.args[5];</span><br><span class="line"> imagePath = system.args[6];</span><br><span class="line">}</span><br><span class="line">page.viewportSize = { width: pageWidth, height: pageHeight };</span><br><span class="line">page.open(pageUrl, function start(status) {</span><br><span class="line"> page.render(imagePath, {format: format, quality: quality});</span><br><span class="line"> phantom.exit();</span><br><span class="line">});</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">> java 执行phantomJS的代码</span><br><span class="line"> /**</span><br><span class="line"> * 将网页渲染成图片</span><br><span class="line"> * format 图片格式 quality 图片质量(0~100)</span><br><span class="line"> * pageWidth 网页宽度 pageHeight 网页高度</span><br><span class="line"> */</span><br><span class="line"> public static void renderImage(String phantomJSPath, String renderImageJSPath, int pageWidth, int pageHeight, String renderUrl, String format, int quality, String outPutImagePath) {</span><br><span class="line"> // 执行命令参数</span><br><span class="line"> List<String> params = Arrays.asList(phantomJSPath, renderImageJSPath, pageWidth + "", pageHeight + "", renderUrl, format, quality + "", outPutImagePath);</span><br><span class="line"></span><br><span class="line"> ProcessBuilder processBuilder = new ProcessBuilder()</span><br><span class="line"> .command(params);</span><br><span class="line"> try {</span><br><span class="line"> processBuilder.redirectError();</span><br><span class="line"> Process process = processBuilder.start();</span><br><span class="line"> InputStream processIS = process.getInputStream();</span><br><span class="line"> String output = IOUtils.toString(processIS);</span><br><span class="line"> logger.info("渲染成图片: {} -> {}", processBuilder.command(), output);</span><br><span class="line"> IOUtils.closeQuietly(processIS);</span><br><span class="line"> int result = process.waitFor();</span><br><span class="line"> if (result != 0) {</span><br><span class="line"> logger.warn("执行失败: {} -> {}", processBuilder.command(), output);</span><br><span class="line"> }</span><br><span class="line"> } catch (InterruptedException | IOException e) {</span><br><span class="line"> logger.warn("执行失败: {} -> {}", processBuilder.command(), e);</span><br><span class="line"> }</span><br><span class="line"> }</span><br></pre></td></tr></table></figure>
<p>参考资料:<br><a href="https://bingozb.github.io/51.html" target="_blank" rel="noopener">phantomjs实现服务端屏幕截图</a><br><a href="http://jser.me/2016/05/31/phantomjs%E5%9C%A8linux%E4%B8%8B%E6%88%AA%E5%9B%BE%E4%B8%AD%E6%96%87%E5%AD%97%E4%BD%93%E9%97%AE%E9%A2%98.html" target="_blank" rel="noopener">phantomjs在linux下截图中文字体问题</a><br><a href="http://phantomjs.org/download.html" target="_blank" rel="noopener">phantmjs下载地址</a><br><a href="https://www.jianshu.com/p/e599ae0c7680" target="_blank" rel="noopener">PingFang sc字体的使用</a><br><a href="http://phantomjs.org/api/webpage/method/open.html" target="_blank" rel="noopener">phantomJS API</a> </p>
]]></content>
<tags>
<tag>phantomjs</tag>
</tags>
</entry>
<entry>
<title>raspberry-system-install</title>
<url>/2020/05/24/raspberry-system-install/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h4 id="树莓派4B系统"><a href="#树莓派4B系统" class="headerlink" title="树莓派4B系统"></a>树莓派4B系统</h4><blockquote>
<p><a href="https://www.raspberrypi.org/products/raspberry-pi-4-model-b/" target="_blank" rel="noopener">官网树莓派4B系统介绍</a><br>在安装其他Linux系统时需要注意下,树莓派CPU架构ARM,64位</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">root@raspberrypi:/etc/systemd/network# hostnamectl status</span><br><span class="line"> Static hostname: raspberrypi</span><br><span class="line"> Icon name: computer</span><br><span class="line"> Machine ID: 9321879165344d29ba552214ae2aca07</span><br><span class="line"> Boot ID: 67c2e9c17ee74d049301e40c99c70b58</span><br><span class="line"> Operating System: Raspbian GNU/Linux 10 (buster)</span><br><span class="line"> Kernel: Linux 4.19.97-v7l+</span><br><span class="line"> Architecture: arm</span><br></pre></td></tr></table></figure>
<p><img src="/images/pi4-labelled@2x.webp" alt="树莓派集成板"></p>
<h5 id="最基础硬件配置"><a href="#最基础硬件配置" class="headerlink" title="最基础硬件配置"></a>最基础硬件配置</h5><p><strong>必选配置</strong></p>
<ol>
<li>读卡器</li>
</ol>
<ul>
<li>和SD存储卡配合使用。应用于其他电脑将树莓派系统烧录到SD存储卡上</li>
</ul>
<ol start="2">
<li>8G以上microSD(T-Flash)存储卡</li>
</ol>
<ul>
<li>存储树莓派系统</li>
<li>存储文件使用</li>
</ul>
<ol start="3">
<li>树莓派4B集成板</li>
<li>5V-3A的Type-C的充电器</li>
</ol>
<hr>
<p><strong>可选配置</strong><br>5. 树莓派集成板散热贴片<br>6. 树莓派塑料外壳或者金属外壳<br>7. 小型散热风扇<br>8. micro-hdmi连接线</p>
<ul>
<li>用于输出页面到显示器上</li>
</ul>
<ol start="9">
<li>等等</li>
</ol>
<a id="more"></a>
<h5 id="下载、烧录树莓派系统"><a href="#下载、烧录树莓派系统" class="headerlink" title="下载、烧录树莓派系统"></a>下载、烧录树莓派系统</h5><blockquote>
<p>Raspbian系统是用Debian专门为ARM卡片式计算机树莓派定制的版本。</p>
</blockquote>
<p><a href="https://www.raspberrypi.org/downloads/raspbian/" target="_blank" rel="noopener">官网系统下载地址</a></p>
<ul>
<li>树莓派桌面版和预装软件系统(Raspbian Buster with desktop and recommended software)</li>
<li>树莓派桌面版(不含预装软件)系统 (Raspbian Buster with desktop)</li>
<li>树莓派(不含桌面、不含预装软件)精简版 (Raspbian Buster Lite)</li>
</ul>
<p><a href="https://www.balena.io/etcher/" target="_blank" rel="noopener">推荐烧录SD软件Etcher</a><br>不合适使用Etcher,也可以使用树莓派自带烧录<a href="https://www.raspberrypi.org/downloads/noobs/" target="_blank" rel="noopener">NOOBS</a></p>
<ol>
<li>下载Raspbian树莓派系统</li>
</ol>
<ul>
<li>一般下载的是压缩包(如:zip),需要进行解压,获取.img的镜像</li>
</ul>
<ol start="2">
<li>将SD卡数据先清空,适当可以直接进行格式化</li>
<li>使用Etcher或者NOOBS或者SDFormater进行烧录</li>
<li>烧录完成,再次查看SD卡会发现boot命名存储卡</li>
</ol>
<ul>
<li>diskutil list</li>
</ul>
<h5 id="启动、访问树莓派系统方案"><a href="#启动、访问树莓派系统方案" class="headerlink" title="启动、访问树莓派系统方案"></a>启动、访问树莓派系统方案</h5><blockquote>
<p><a href="https://www.raspberrypi.org/documentation/remote-access/" target="_blank" rel="noopener">官网连接树莓派4B系统方案</a><br>树莓派raspbian:<br><code>系统用户名为:pi 密码:raspberry</code><br><code>root用户权限密码: raspberry</code></p>
</blockquote>
<ul>
<li>使用HDMI(<strong>High-Definition Multimedia Interface</strong>)显示器、鼠标、键盘进行访问系统</li>
<li>通过SSH(<strong>Secure SHell</strong>))访问树莓派</li>
<li>通过VNC(<strong>Virtual Network Computing</strong>)服务远程登录树莓派<a href="https://www.realvnc.com/en/connect/download/viewer/raspberrypi/" target="_blank" rel="noopener">VNC 客户端下载</a>。树莓派系统命令输入<code>vncserver -geometry 1422x800</code>启动vnc服务。<strong>注意设置好界面展示大小才能正常显示,不然为报·vnc cannot currently show the desktop·错误</strong></li>
</ul>
<p>桌面访问可以在命令行输入:<code>sudo raspi-cofig</code>进入树莓派系统配置界面。选择<code>5 Interfacing Options</code>进行配置默认启动应用程序SSH、VNC等</p>
<h6 id="SSH-访问接入网线rapibian系统"><a href="#SSH-访问接入网线rapibian系统" class="headerlink" title="SSH 访问接入网线rapibian系统"></a>SSH 访问接入网线rapibian系统</h6><ol>
<li>进入SD卡名称为<code>boot</code>文件夹</li>
</ol>
<ul>
<li>mac上: cd /Volumes/boot/</li>
</ul>
<ol start="2">
<li><code>touch ssh</code> 生成一个ssh命名的文件</li>
<li>使用网线连接树莓派,查找树莓派的IP地址</li>
</ol>
<ul>
<li><p>命令输入: <code>ping raspberrypi.local</code></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">useheart@useheart Downloads % ping raspberrypi.local</span><br><span class="line">PING raspberrypi.local (192.168.1.6): 56 data bytes</span><br><span class="line">64 bytes from 192.168.1.6: icmp_seq=0 ttl=64 time=1.618 ms</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用<a href="https://angryip.org/" target="_blank" rel="noopener">IP Scanner</a>软件进行扫描,找到对应树莓派IP地址</p>
</li>
</ul>
<ol start="4">
<li>ssh <a href="mailto:pi@xxx.xxx.xxx.xx" target="_blank" rel="noopener">pi@xxx.xxx.xxx.xx</a></li>
</ol>
<h6 id="SSH-访问接入WIFI的rapibian系统"><a href="#SSH-访问接入WIFI的rapibian系统" class="headerlink" title="SSH 访问接入WIFI的rapibian系统"></a>SSH 访问接入WIFI的rapibian系统</h6><ol>
<li>进入SD卡名称为<code>boot</code>文件夹</li>
</ol>
<ul>
<li>mac上: cd /Volumes/boot/</li>
</ul>
<ol start="2">
<li><p><code>touch ssh</code> 生成一个ssh命名的文件</p>
</li>
<li><p>新建wpa_supplicant.conf 文件,写入无限相关配置<br>如果无限网没有密码或者采用WEP加密方式的话,key_mgmt应设为NONE,密码字段由psk改成wep_key0即可。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">country=CN</span><br><span class="line">ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev</span><br><span class="line">update_config=1</span><br><span class="line">network={</span><br><span class="line"> ssid="wifi 名称"</span><br><span class="line"> psk="wifi 密码"</span><br><span class="line"> key_mgmt=WPA-PSK</span><br><span class="line">}</span><br><span class="line">Network={</span><br><span class="line"> ssid="wifi 名称"</span><br><span class="line"> psk="wifi 密码"</span><br><span class="line"> key_mgmt=NONE</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</li>
<li><p>树莓派自动连接WIFI,查找树莓派的IP地址</p>
</li>
</ol>
<ul>
<li>命令输入: <code>ping raspberrypi.local</code><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">useheart@useheart Downloads % ping raspberrypi.local</span><br><span class="line">PING raspberrypi.local (192.168.1.6): 56 data bytes</span><br><span class="line">64 bytes from 192.168.1.6: icmp_seq=0 ttl=64 time=1.618 ms</span><br></pre></td></tr></table></figure>
</li>
</ul>
<ol start="5">
<li>ssh <a href="mailto:pi@xxx.xxx.xxx.xx" target="_blank" rel="noopener">pi@xxx.xxx.xxx.xx</a></li>
</ol>
<h5 id="修改pi账号密码和开启root账号"><a href="#修改pi账号密码和开启root账号" class="headerlink" title="修改pi账号密码和开启root账号"></a>修改pi账号密码和开启root账号</h5><p>  修改pi账号的密码可以在之前的rasp-config中修改,也可以在pi用户登录之后在命令行终端输入password pi即可。<br>  当需要root权限时,由默认账户经由sudo执行,Rassberry pi系统中的Raspbian默认用户是pi,密码为raspberry重新开启账号,可由pi用户登录后,在命令行下执行<br><code>sudo passwd root</code><br>  执行此命令系统会提示输入两遍的root密码,输入你想设的密码即可,然后执行<br><code>sudo passwd --unlock root</code><br>这样root用户解锁成功。</p>
<h5 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h5><ul>
<li><p>查看树莓CPU温度</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 方法一</span><br><span class="line">pi@RaspberryPi:~ $ /opt/vc/bin/vcgencmd measure_temp</span><br><span class="line">temp=51.5'C</span><br><span class="line"># 方法二</span><br><span class="line">pi@RaspberryPi:~ $ cat /sys/class/thermal/thermal_zone0/temp</span><br><span class="line">50464 #输出值除以1000,单位是℃。</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看CPU详情</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cat /proc/cpuinfo</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看CPU硬件架构</p>
<blockquote>
<p>在Linux中使用命令arch可以初步查看出当前系统所识别出来的机器CPU类型,如”i386”, “i486”,”i586”, “alpha”, “sparc”, “arm”, “m68k”,”mips”,”ppc”,”ia64”,”x86_64”等;ia64和x86_64就说明这台机器是64位的;</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">[root@db ~]# arch</span><br><span class="line">i686</span><br><span class="line">[root@svr-db-test ~]# uname -m</span><br><span class="line">x86_64</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="推荐阅读"><a href="#推荐阅读" class="headerlink" title="推荐阅读:"></a>推荐阅读:</h4><p><a href="https://zhuanlan.zhihu.com/p/59027897" target="_blank" rel="noopener">如何给树莓派安装操作系统</a></p>
]]></content>
<tags>
<tag>树莓派4B</tag>
</tags>
</entry>
<entry>
<title>自定义程序朗读单词文本</title>
<url>/2018/10/06/speackEnglishWord/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h4 id="自定义程序朗读单词文本意思"><a href="#自定义程序朗读单词文本意思" class="headerlink" title="自定义程序朗读单词文本意思"></a>自定义程序朗读单词文本意思</h4><p>其核心内容是围绕Mac Terminal终端say命令展开的
让学习英语就像听歌一样简单</p>
<h4 id="具体步骤:"><a href="#具体步骤:" class="headerlink" title="具体步骤:"></a>具体步骤:</h4><h5 id="第一步"><a href="#第一步" class="headerlink" title="第一步"></a>第一步</h5><ul>
<li>简单使用say去读一小段的文本 say Hello World;</li>
<li>学习使用say去读文件 say -f …/…/hello_world.txt|.csv</li>
<li>详细使用可以输入命令 man say</li>
</ul>
<h5 id="第二步"><a href="#第二步" class="headerlink" title="第二步"></a>第二步</h5><ul>
<li>寻找合适单词翻译网站 通过复制粘贴的形式到文件中</li>
<li>目前我使用的是<a href="https://www.shanbay.com/" target="_blank" rel="noopener">扇贝网站</a>的单词学习<a id="more"></a>
</li>
</ul>
<h5 id="第三步"><a href="#第三步" class="headerlink" title="第三步"></a>第三步</h5><ul>
<li>编写自己的程序</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">#!/usr/bin/perl</span><br><span class="line">use strict;</span><br><span class="line">use warnings;</span><br><span class="line"></span><br><span class="line">use Time::HiRes qw(usleep nanosleep);</span><br><span class="line"></span><br><span class="line"># 获取文件参数</span><br><span class="line">my $file = $ARGV[0] or die "Need to get CSV file on the command line\n";</span><br><span class="line"># 打开文件</span><br><span class="line">open(my $data, '<', $file) or die "Could not open '$file' $!\n";</span><br><span class="line"># 一行一行的读文件</span><br><span class="line">while (my $line = <$data>) {</span><br><span class="line"> usleep(500);</span><br><span class="line"> # 去除回车键</span><br><span class="line"> chomp $line;</span><br><span class="line"> # 一行文本按照空格符的进行分割成组</span><br><span class="line"> my @strWord = split(/[\s+]/, $line);</span><br><span class="line"> foreach(@strWord){</span><br><span class="line"> if($_ !~ /\./){</span><br><span class="line"> `say "$_"`;</span><br><span class="line"> if($_ =~ /\w+/){</span><br><span class="line"> my $size = length($_);</span><br><span class="line"> my $strIndex = 0;</span><br><span class="line"> my $strEnd = $strIndex + 1;</span><br><span class="line"> while($strIndex < $size){</span><br><span class="line"> my $subWord = substr($_, $strIndex, 1);</span><br><span class="line"> `say "$subWord"`;</span><br><span class="line"> $strIndex = $strIndex + 1;</span><br><span class="line"> }</span><br><span class="line"> usleep(500);</span><br><span class="line"> # say 单词和单词的释义</span><br><span class="line"> `say "$_"`;</span><br><span class="line"> }</span><br><span class="line"> print "$_ ";</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> print "\n";</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<ul>
<li>通过perl命令执行程序 eg: perl readCSV.pl /Users/useheart/学习资料/英语单词学习.csv</li>
</ul>
]]></content>
<tags>
<tag>学习</tag>
</tags>
</entry>
<entry>
<title>树莓派安装Centos7</title>
<url>/2020/05/24/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%AE%89%E8%A3%85Centos7/</url>
<content><![CDATA[<p><a href="https://github.com/drgonroot/drgonroot.github.io/issues/new" target="_blank" rel="noopener">吐槽、建议、解惑入口网址</a></p>
<h4 id="树莓派安装Centos7"><a href="#树莓派安装Centos7" class="headerlink" title="树莓派安装Centos7"></a>树莓派安装Centos7</h4><h5 id="树莓派Centos选择下载"><a href="#树莓派Centos选择下载" class="headerlink" title="树莓派Centos选择下载"></a>树莓派Centos选择下载</h5><blockquote>
<p>简单描述下Centos分为release发版和stream不稳定发版。release迭代较慢,安全。stream迭代较慢,不稳定。</p>
</blockquote>
<p><strong>Centos7 下载</strong> </p>
<ul>
<li><a href="http://isoredirect.centos.org/altarch/7/isos/armhfp/" target="_blank" rel="noopener">Arm架构Centos下载</a> </li>
</ul>
<p>目前笔者购买是关于树莓派4B-4G,选择安装包为University <a href="https://mirrors.bfsu.edu.cn/centos-altarch/7.8.2003/isos/armhfp/CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-2003-sda.raw.xz" target="_blank" rel="noopener">CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-4-2003-sda .raw.xz</a>。<br>然后下载Centos包使用对应工具[Balena Etcher]烧录到SD卡上。</p>
<p><strong>树莓派Centos连接</strong></p>
<ul>
<li>先将树莓派连接网线,并启动</li>
<li>连接的电脑也需要连接WIFI网络上(让电脑和树莓派保持在同一个局域网内)</li>
<li>使用<a href="https://angryip.org/" target="_blank" rel="noopener">IP Scanner</a>软件进行扫描 ,找到新增ip<br><img src="images/%E6%A0%91%E8%8E%93%E6%B4%BEIPScanner.png" alt="树莓派IPScanner"></li>
<li>ssh <a href="mailto:root@xxx.xxx.xxx.xxx" target="_blank" rel="noopener">root@xxx.xxx.xxx.xxx</a> 默认密码centos</li>
</ul>
<p><strong>Centos7 拓展主分区</strong></p>
<blockquote>
<p>由于系统默认的映像把根分区的空间设定得很小,因此我们需要手动扩展根分区。 详情参考<a href="https://zhuanlan.zhihu.com/p/33030757" target="_blank" rel="noopener">为树莓派装上 CentOS 7 系统</a></p>
</blockquote>
<p>首次连接树莓派,会发现主分区没有可用的空间。<br>存储卡硬盘 <code>/dev/mmcblk0</code> 分成3个分区(mmcblk0p1/mmcblk0p2/mmcblk0p3),mmcblk0p3的主分区没有被挂载上。</p>
<a id="more"></a>
<p><em>执行步骤</em></p>
<ul>
<li>执行 <code>rootfs-expand</code></li>
<li>检查硬盘分区拓展情况 <code>df -lh</code></li>
</ul>
<hr>
<p>没有效果则只能将mmcblk0重新进行分区,然后重启</p>
<blockquote>
<p>核心操作就是将第三个主分区删除,重新分区。</p>
</blockquote>
<ul>
<li>执行分区命令 <code>fdisk /dev/mmcblk0</code></li>
<li>删除第三个主分区回车 <code>d</code></li>
<li>新增第三个主分区回车 <code>n</code></li>
<li>选择新增第三个主分区回车 <code>p</code></li>
<li>开始设置分区开始扇区和结束扇区,需要注意设定的开始扇区和结尾扇区,从第二块主分区结尾扇区 + 1开始。不然默认是使用第一块主分区前面的扇区,存储空间很小。</li>
<li>将树莓派重新启动,<code>reboot</code></li>
<li>启动后,直接再次执行 <code>rootfs-expand</code>或者<code>resize2fs /dev/mmcblk0p3</code></li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">设备 Boot Start End Blocks Id System</span><br><span class="line">/dev/mmcblk0p1 * 8192 593919 292864 c W95 FAT32 (LBA)</span><br><span class="line">/dev/mmcblk0p2 593920 1593343 499712 82 Linux swap / Solaris</span><br><span class="line">/dev/mmcblk0p3 1593344 31116287 14761472 83 Linux</span><br><span class="line">### 执行前效果</span><br><span class="line">[root@localhost ~]# df -lh</span><br><span class="line">文件系统 容量 已用 可用 已用% 挂载点</span><br><span class="line">/dev/root 1.7G 1.7G 0 100% /</span><br><span class="line">devtmpfs 1.9G 0 1.9G 0% /dev</span><br><span class="line">tmpfs 1.9G 0 1.9G 0% /dev/shm</span><br><span class="line">tmpfs 1.9G 8.4M 1.9G 1% /run</span><br><span class="line">tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup</span><br><span class="line">/dev/mmcblk0p1 286M 53M 233M 19% /boot</span><br><span class="line">tmpfs 383M 0 383M 0% /run/user/0</span><br><span class="line"></span><br><span class="line">[root@localhost ~]# ll /dev | grep mmcb</span><br><span class="line">brw-rw----. 1 root disk 179, 0 1月 1 00:00 mmcblk0</span><br><span class="line">brw-rw----. 1 root disk 179, 1 1月 1 00:00 mmcblk0p1</span><br><span class="line">brw-rw----. 1 root disk 179, 2 1月 1 00:00 mmcblk0p2</span><br><span class="line">brw-rw----. 1 root disk 179, 3 1月 1 00:04 mmcblk0p3</span><br><span class="line"></span><br><span class="line">### 执行后效果</span><br><span class="line">[root@localhost ~]# df -lh</span><br><span class="line">文件系统 容量 已用 可用 已用% 挂载点</span><br><span class="line">/dev/root 14G 1.7G 13G 13% /</span><br><span class="line">devtmpfs 1.9G 0 1.9G 0% /dev</span><br><span class="line">tmpfs 1.9G 0 1.9G 0% /dev/shm</span><br><span class="line">tmpfs 1.9G 8.4M 1.9G 1% /run</span><br><span class="line">tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup</span><br><span class="line">/dev/mmcblk0p1 286M 53M 233M 19% /boot</span><br><span class="line">tmpfs 383M 0 383M 0% /run/user/0</span><br></pre></td></tr></table></figure>
<h5 id="主机名、网络、时区、语言、键盘配置"><a href="#主机名、网络、时区、语言、键盘配置" class="headerlink" title="主机名、网络、时区、语言、键盘配置"></a>主机名、网络、时区、语言、键盘配置</h5><hr>
<h6 id="主机名配置"><a href="#主机名配置" class="headerlink" title="主机名配置"></a>主机名配置</h6><p><code>hostnamectl status</code><br><code>hostnamectl set-hostname xxxx主机名名称</code></p>
<hr>
<h6 id="网络配置"><a href="#网络配置" class="headerlink" title="网络配置"></a>网络配置</h6><p><code>nmtui</code><br><code>nmcli d</code><br><code>nmcli d wifi</code><br><code>nmcli d wifi connect xxxWiFi名称 password 'xxxWiFi密码'</code><br><code>cat /etc/resolv.conf</code><br>网络连接文件夹: <code>cd /etc/sysconfig/network-scripts</code> <code>cat ifcfg-网络名称</code><br>设置网络连接开机自启动 <code>systemctl enable NetworkManager.service</code></p>
<hr>
<h6 id="语言配置"><a href="#语言配置" class="headerlink" title="语言配置"></a>语言配置</h6><p><code>localectl</code><br><code>localectl set-locale LANG=zh_CN.UTF-8</code><br><code>locale</code><br><code>update-locale LANG=LANG=zh_CN.UTF-8 LANGUAGE</code><br><code>cat /etc/locale.conf</code></p>
<hr>
<h6 id="时区配置"><a href="#时区配置" class="headerlink" title="时区配置"></a>时区配置</h6><p><code>date -R</code> </p>
<ul>
<li>方案一:<br><code>tzselect</code><br>按照步骤使用命令<code>tzselect</code>选择国家时区<br>执行TZ=’Asia/Shanghai’; export TZ 并将这行命令添加到.bash_profile中,然后退出并重新登录。</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">You can make this change permanent for yourself by appending the line</span><br><span class="line"></span><br><span class="line">to the file '.profile' in your home directory; then log out and log in again.</span><br><span class="line"></span><br><span class="line">Here is that TZ value again, this time on standard output so that you</span><br><span class="line">can use the /usr/bin/tzselect command in shell scripts:</span><br><span class="line">Asia/Shanghai</span><br><span class="line">``` </span><br><span class="line"></span><br><span class="line">* 方案二: </span><br><span class="line">`timedatectl` </span><br><span class="line">直接设置中国-上海时区 `timedatectl set-timezone Asia/Shanghai`</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">----------------------------</span><br><span class="line">###### 键盘配置 </span><br><span class="line">`localectl set-keymap us`</span><br><span class="line"></span><br><span class="line">##### 高级配置</span><br><span class="line">###### 切换软件源</span><br><span class="line">> [详情切花软件源网址](https://www.jianshu.com/p/541c737bc947)</span><br><span class="line"></span><br><span class="line">* 将软件源替换为阿里源 </span><br><span class="line">* 先进入源的目录 </span><br><span class="line">`cd /etc/yum.repos.d`</span><br><span class="line">* 备份一下官方源 </span><br><span class="line">`mv CentOS-Base.repo CentOS-Base.repo.bak`</span><br><span class="line">* 将阿里源文件下载下来 </span><br><span class="line">`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo`</span><br><span class="line">* 重建源数据缓存 </span><br><span class="line">`yum clean all`</span><br><span class="line">`yum makecache`</span><br><span class="line"></span><br><span class="line">###### 设置域名解析地址</span><br><span class="line">> [国内常用公共DNS服务器地址有哪些?](https://zhuanlan.zhihu.com/p/39406412)</span><br></pre></td></tr></table></figure>
<p>[root@localhost ~]# cat /etc/resolv.conf</p>
<h1 id="Generated-by-NetworkManager"><a href="#Generated-by-NetworkManager" class="headerlink" title="Generated by NetworkManager"></a>Generated by NetworkManager</h1><p>nameserver 114.114.114.114<br>nameserver 8.8.8.8</p>
<pre><code>
###### 更改语言包
##### 其他
私有内网的linux获取出口公网地址命令
`curl ifconfig.me`
`curl ipinfo.io`
#### 挂载移动硬盘
* 只需要在修改/etc/fstab文件后执行该命令`mount -a` ,即可在不重启的情况下挂载fstab!
* `blkid` 打印块设备属性
* `lsblk` 块设备列表
* `mkfs` 格式化硬盘分区 ext4主流centos7文件系统
* `/etc/fstab` 设置`default,nofail`可以让硬盘不存在启动