-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.xml
3926 lines (2689 loc) · 339 KB
/
rss.xml
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"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>ALEXCDEVER's Blog</title>
<link>https://blog.alexc.cn/</link>
<description>喜欢各种瞎折腾</description>
<generator>Hugo 0.105.0-DEV https://gohugo.io/</generator>
<language>zh-CN</language>
<managingEditor>alexcdever@gmail.com (Alex Chen)</managingEditor>
<webMaster>alexcdever@gmail.com (Alex Chen)</webMaster>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<lastBuildDate>Sun, 16 Oct 2022 00:37:14 +0000</lastBuildDate>
<atom:link rel="self" type="application/rss+xml" href="https://blog.alexc.cn/rss.xml" />
<item>
<title>管理远程k3s集群</title>
<link>https://blog.alexc.cn/posts/%E7%AE%A1%E7%90%86%E8%BF%9C%E7%A8%8Bk3s%E9%9B%86%E7%BE%A4/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/%E7%AE%A1%E7%90%86%E8%BF%9C%E7%A8%8Bk3s%E9%9B%86%E7%BE%A4/</guid>
<pubDate>Thu, 17 Feb 2022 22:57:45 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><ol>
<li>
<p>安装 <strong>kubectl</strong></p>
<ol>
<li>macOS 可通过 homebrew 安装:<code>brew install kubernetes-cli</code></li>
</ol>
</li>
<li>
<p>登录进入 <strong>k3s</strong> 集群的 <strong>master</strong> 节点所在的机器,并找到 <code>/etc/rancher/k3s/k3s.yaml</code>,这份文件就是 <strong>kubeconfig</strong> 了,跟本地的<code>~/.kube/config</code>是同一个东西,接下来可以直接替换掉本地的<strong>config</strong>,也可以把<strong>k3s.yaml</strong>里的<strong>server</strong>、<strong>context</strong>和<strong>user</strong>加进config,并把<strong>current-context</strong>改成<strong>k3s</strong>的<strong>context</strong></p>
</li>
<li>
<p>用<code>kubectl cluster-info</code>去验证能否正常使用</p>
</li>
</ol>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/k3s/">k3s</category>
<category domain="https://blog.alexc.cn/tags/kubectl/">kubectl</category>
<category domain="https://blog.alexc.cn/tags/kubernetes/">kubernetes</category>
</item>
<item>
<title>将gitlab-runner部署到k3s集群中</title>
<link>https://blog.alexc.cn/posts/%E5%B0%86gitlab-runner%E9%83%A8%E7%BD%B2%E5%88%B0k3s%E9%9B%86%E7%BE%A4%E4%B8%AD/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/%E5%B0%86gitlab-runner%E9%83%A8%E7%BD%B2%E5%88%B0k3s%E9%9B%86%E7%BE%A4%E4%B8%AD/</guid>
<pubDate>Thu, 17 Feb 2022 22:57:45 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><p>参考资料:</p>
<p><a href="https://docs.gitlab.com/runner/install/kubernetes.html">GitLab Runner Helm Chart | GitLab</a></p>
<p><a href="https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#docker-in-docker-with-tls-enabled-in-kubernetes">Use Docker to build Docker images | GitLab</a></p>
<ol>
<li>
<p>安装helm</p>
<ol>
<li>
<p>macOS下可通过homebrew安装</p>
<p><code>brew install helm</code></p>
</li>
</ol>
</li>
<li>
<p>添加gitlab的chart库</p>
<p><code>helm repo add gitlab https://charts.gitlab.io</code></p>
</li>
<li>
<p>创建并编辑values.yaml</p>
<ol>
<li>
<p>复制官方提供的示例文件:<a href="https://gitlab.com/gitlab-org/charts/gitlab-runner/blob/main/values.yaml">values.yaml · main · GitLab.org / charts / GitLab Runner · GitLab</a></p>
</li>
<li>
<p>在runners的config里做如下配置:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">config</span><span class="p">:</span><span class="w"> </span><span class="p">|</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd"> [[runners]]
</span></span></span><span class="line"><span class="cl"><span class="sd"> [runners.kubernetes]
</span></span></span><span class="line"><span class="cl"><span class="sd"> namespace = &#34;{{.Release.Namespace}}&#34;
</span></span></span><span class="line"><span class="cl"><span class="sd"> image = &#34;ubuntu:16.04&#34;
</span></span></span><span class="line"><span class="cl"><span class="sd"> privileged = true
</span></span></span><span class="line"><span class="cl"><span class="sd"> # 如果要想在runner里构建docker镜像,就要加入以下配置,因为docker的dind镜像自19.03开始就默认使用tls端口
</span></span></span><span class="line"><span class="cl"><span class="sd"> [[runners.kubernetes.volumes.empty_dir]]
</span></span></span><span class="line"><span class="cl"><span class="sd"> name = &#34;docker-certs&#34;
</span></span></span><span class="line"><span class="cl"><span class="sd"> mount_path = &#34;/certs/client&#34;
</span></span></span><span class="line"><span class="cl"><span class="sd"> medium = &#34;Memory&#34;</span><span class="w">
</span></span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>其他的配置项按需配置即可</p>
</li>
</ol>
</li>
<li>
<p>将gitlab runner部署到k3s</p>
<p><code>helm install --namespace {namespace} gitlab-runner -f {path to values.yaml} gitlab/gitlab-runner</code></p>
</li>
<li>
<p>完毕</p>
</li>
</ol>
<h2 id="额外提醒">额外提醒</h2>
<p>参考资料:<a href="https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#docker-in-docker-with-tls-enabled-in-kubernetes">Use Docker to build Docker images | GitLab</a></p>
<p>假如要使用runner构建docker镜像,请在.gitlab.yaml里加入以下内容:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">services</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span>- <span class="l">docker:stable-dind</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">variables</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">DOCKER_HOST</span><span class="p">:</span><span class="w"> </span><span class="l">tcp://docker:2376</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">DOCKER_TLS_CERTDIR</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;/certs&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">DOCKER_TLS_VERIFY</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">DOCKER_CERT_PATH</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;$DOCKER_TLS_CERTDIR/client&#34;</span><span class="w">
</span></span></span></code></pre></td></tr></table>
</div>
</div></description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/gitlab-runner/">gitlab runner</category>
<category domain="https://blog.alexc.cn/tags/gitlab-ci/">gitlab-ci</category>
<category domain="https://blog.alexc.cn/tags/k3s/">k3s</category>
<category domain="https://blog.alexc.cn/tags/helm/">helm</category>
<category domain="https://blog.alexc.cn/tags/gitlab/">gitlab</category>
<category domain="https://blog.alexc.cn/tags/kubernetes/">kubernetes</category>
</item>
<item>
<title>Ubuntu系统搭建开发环境</title>
<link>https://blog.alexc.cn/posts/ubuntu%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/ubuntu%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83/</guid>
<pubDate>Sat, 16 Oct 2021 03:22:38 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><h2 id="创建-ssh-密钥">创建 ssh 密钥</h2>
<p><code>ssh-keygen</code> 然后一路回车</p>
<h2 id="找到系统对应的国内镜像源">找到系统对应的国内镜像源</h2>
<p>清华、阿里云、腾讯云、网易云等等组织机构提供的镜像源</p>
<h2 id="安装常用的工具">安装常用的工具</h2>
<p><code>sudo apt install curl git vim zip autofs cifs-utils net-tools build-essential file -y</code></p>
<h2 id="更新并升级系统内的组件和工具">更新并升级系统内的组件和工具</h2>
<p><code>sudo apt update &amp;&amp; sudo apt upgrade -y &amp;&amp; sudo apt autoremove -y &amp;&amp; sudo apt autoclean -y</code></p>
<h2 id="oh-my-zsh-和-zsh">oh-my-zsh 和 zsh</h2>
<p><code>sh -c &quot;$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)&quot;</code></p>
<h3 id="安装插件">安装插件</h3>
<ol>
<li><code>git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions</code></li>
<li><code>git clone https://github.com/zsh-users/zsh-syntax-highlighting $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting</code></li>
<li>修改 <code>.zshrc</code> ,将 <code>zsh-autosuggestions</code> 和 <code>zsh-syntax-highlighting</code> 加入到 <code>plugins</code> 方法里</li>
</ol>
<h2 id="docker">docker</h2>
<p>脚本一键安装:<code>curl -sSL https://get.daocloud.io/docker | sh</code> 或 <code>curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun</code></p>
<h2 id="linuxbrew">linuxbrew</h2>
<p><a href="https://github.com/Linuxbrew/brew">参考</a></p>
<ol>
<li><code>sh -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)&quot;</code></li>
<li><code>echo 'eval &quot;$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)&quot;' &gt;&gt; ~/.zshrc</code></li>
<li><code>eval &quot;$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)&quot;</code></li>
</ol>
<h2 id="sdkman">sdkman</h2>
<p><code>curl -s &quot;https://get.sdkman.io&quot; | bash</code></p>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/linux/">linux</category>
<category domain="https://blog.alexc.cn/tags/ubuntu/">Ubuntu</category>
<category domain="https://blog.alexc.cn/tags/apt/">apt</category>
<category domain="https://blog.alexc.cn/tags/ssh/">ssh</category>
<category domain="https://blog.alexc.cn/tags/zsh/">zsh</category>
<category domain="https://blog.alexc.cn/tags/oh-my-zsh/">oh-my-zsh</category>
<category domain="https://blog.alexc.cn/tags/docker/">docker</category>
<category domain="https://blog.alexc.cn/tags/linuxbrew/">linuxbrew</category>
<category domain="https://blog.alexc.cn/tags/sdkman/">sdkman</category>
</item>
<item>
<title>MacOS修改鼠标移速</title>
<link>https://blog.alexc.cn/posts/macos%E4%BF%AE%E6%94%B9%E9%BC%A0%E6%A0%87%E7%A7%BB%E9%80%9F/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/macos%E4%BF%AE%E6%94%B9%E9%BC%A0%E6%A0%87%E7%A7%BB%E9%80%9F/</guid>
<pubDate>Sat, 12 Jun 2021 00:34:26 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><ol>
<li>先查看当前速度:
<ul>
<li>鼠标双击阈值:<code>defaults read -g com.apple.mouse.doubleClickThreshold</code></li>
<li>鼠标加速度(即本次我想要改的鼠标移动速度):<code>defaults read -g com.apple.mouse.scaling</code></li>
<li>鼠标滚轮速度:<code>defaults read -g com.apple.scrollwheel.scaling</code></li>
</ul>
</li>
<li>修改对应的速度
<ul>
<li><code>defaults write -g com.apple.mouse.doubleClickThreshold 0.75</code></li>
<li><code>defaults write -g com.apple.mouse.scaling 11</code></li>
<li><code>defaults write -g com.apple.scrollwheel.scaling 0.75</code></li>
</ul>
</li>
</ol>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/macos/">macOS</category>
<category domain="https://blog.alexc.cn/tags/%E9%BC%A0%E6%A0%87/">鼠标</category>
<category domain="https://blog.alexc.cn/tags/%E7%A7%BB%E5%8A%A8%E9%80%9F%E5%BA%A6/">移动速度</category>
</item>
<item>
<title>Ubuntu挂载trueNAS共享的samba</title>
<link>https://blog.alexc.cn/posts/ubuntu%E6%8C%82%E8%BD%BDtruenas%E5%85%B1%E4%BA%AB%E7%9A%84samba/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/ubuntu%E6%8C%82%E8%BD%BDtruenas%E5%85%B1%E4%BA%AB%E7%9A%84samba/</guid>
<pubDate>Sat, 12 Jun 2021 00:23:14 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><p><em>温馨提示:需要安装cifs-utils</em></p>
<p>参考链接:<a href="https://www.jianshu.com/p/f4ec8a960f01">Ubuntu 18.04 开机自动挂载NAS</a></p>
<h2 id="临时挂载">临时挂载</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo mount -t cifs -o <span class="nv">user</span><span class="o">={</span>username<span class="o">}</span>,password<span class="o">={</span>password<span class="o">}</span> <span class="o">[</span>//freenas.local/<span class="o">{</span>被共享出来的文件夹名称<span class="o">}](</span>notion://freenas.local/alexcdever<span class="o">)</span> /mnt/nas/
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="使用autofs进行自动挂载">使用autofs进行自动挂载</h2>
<ol>
<li>
<p>安装autofs:<code>sudo apt install autofs -y</code></p>
</li>
<li>
<p>编辑<code>/etc/auto.master</code>,添加<code>/mnt /etc/auto.misc</code> 。前者表示远程目录被挂载的父目录,后者表示要被应用的挂载配置文件</p>
</li>
<li>
<p>创建一个记录了账号密码的文件,内里要记录的内容为:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">username</span><span class="o">=</span>xxx
</span></span><span class="line"><span class="cl"><span class="nv">password</span><span class="o">=</span>xxx
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>编辑<code>/etc/auto.misc</code> ,添加<code>nas -fstype=cifs,credentials=/home/alex/credential.txt,uid=1000,gid=1000 ://freenas.lan/alexcdever</code></p>
</li>
<li>
<p>执行<code>systemctl enable autofs</code>, <code>systemctl restart autofs</code></p>
</li>
<li>
<p>使用<code>ll /mnt/nas</code>去验证是否挂载成功</p>
</li>
</ol>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/ubuntu/">Ubuntu</category>
<category domain="https://blog.alexc.cn/tags/gifs-utils/">gifs-utils</category>
<category domain="https://blog.alexc.cn/tags/autofs/">autofs</category>
<category domain="https://blog.alexc.cn/tags/samba/">samba</category>
</item>
<item>
<title>Ubuntu 20.04TLS修改本机IP与网关</title>
<link>https://blog.alexc.cn/posts/ubuntu-20.04tls%E4%BF%AE%E6%94%B9%E6%9C%AC%E6%9C%BAip%E4%B8%8E%E7%BD%91%E5%85%B3/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/ubuntu-20.04tls%E4%BF%AE%E6%94%B9%E6%9C%AC%E6%9C%BAip%E4%B8%8E%E7%BD%91%E5%85%B3/</guid>
<pubDate>Sat, 12 Jun 2021 00:17:09 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><blockquote>
<p>普通用户执行命令时,请在命令前加上<code>sudo</code></p>
</blockquote>
<h2 id="netplan">netplan</h2>
<p>新版本ubuntu不再使用 <code>etc/network/interfaces</code> 配置本机IP和网关了,而是改用<code>netplan</code> 工具,对应的网络配置文件可以由<code>netplan generate</code> 生成,该配置文件位于<code>/etc/netplan</code> 文件夹中,格式为<code>.yaml</code> ,在我这里三个虚拟机里的配置文件名字均为<strong>00-installer-config.yaml</strong>,但网上却是其他名字,如果名字不一致的话请查看文件内容是否相似,配置文件内容如下:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">network</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ethernets</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># 以太网卡名称</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ens18</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># 是否由dhcp服务器提供IP,true为是,false为否。为否时则需要配置静态IP</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">dhcp4</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># 本机静态IP地址</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">addresses</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="m">192.168.3.5</span><span class="l">/24]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># 所在局域网的网关</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">gateway4</span><span class="p">:</span><span class="w"> </span><span class="m">192.168.3.1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># DNS服务器</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">nameservers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">addresses</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="m">192.168.3.1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ens0</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">dhcp4</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span></code></pre></td></tr></table>
</div>
</div><p>如果修改完成后,则可以使用<code>netplan apply</code> 使该配置文件生效。</p>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/netplan/">netplan</category>
<category domain="https://blog.alexc.cn/tags/ubuntu/">Ubuntu</category>
<category domain="https://blog.alexc.cn/tags/ubuntu-20.04tls/">Ubuntu 20.04TLS</category>
<category domain="https://blog.alexc.cn/tags/ip/">IP</category>
<category domain="https://blog.alexc.cn/tags/%E7%BD%91%E5%85%B3/">网关</category>
<category domain="https://blog.alexc.cn/tags/dns/">DNS</category>
</item>
<item>
<title>PVE创建CT容器兼HomeLede尝鲜</title>
<link>https://blog.alexc.cn/posts/pve%E6%90%AD%E5%BB%BA%E9%83%A8%E7%BD%B2ct%E5%AE%B9%E5%99%A8%E5%85%BC%E8%BD%AF%E8%B7%AF%E7%94%B1%E5%B0%9D%E9%B2%9C/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/pve%E6%90%AD%E5%BB%BA%E9%83%A8%E7%BD%B2ct%E5%AE%B9%E5%99%A8%E5%85%BC%E8%BD%AF%E8%B7%AF%E7%94%B1%E5%B0%9D%E9%B2%9C/</guid>
<pubDate>Sat, 12 Jun 2021 00:09:05 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><p><em>参考链接:</em></p>
<ol>
<li>
<p><a href="https://www.right.com.cn/forum/thread-4053183-1-1.html">恩山论坛教程</a></p>
</li>
<li>
<p><a href="https://github.com/xiaoqingfengATGH/HomeLede">HomeLede项目主页</a></p>
</li>
<li>
<p><a href="https://p3terx.com/archives/build-openwrt-with-github-actions.html">homelede项目修改IP的wiki</a></p>
</li>
<li>
<p><a href="https://blog.csdn.net/u012861744/article/details/112463657">homelede用作旁路由</a></p>
</li>
<li>
<p><a href="https://p3terx.com/archives/build-openwrt-with-github-actions.html">云端编译homelede在内的lede系统</a></p>
</li>
</ol>
<h2 id="编译">编译</h2>
<h3 id="方案一自己编译">方案一:自己编译</h3>
<ol>
<li>参照项目<code>README.md</code>给出的教程一路往下走,但在第七步配置软件包的时候,在<code>target images</code>选项中找到<code>rootfs</code>并勾选上<code>tar.gz</code></li>
<li>再往下走就能得到自己需要的PVE的容器模板
<ol>
<li>编译后的固件在当前目录的子目录<code>./bin/targets/x86/64</code> 里,我们所需要的容器模板的文件叫<code>openwrt-x86-64-generic-rootfs.tar.gz</code></li>
</ol>
</li>
</ol>
<h3 id="方案二云编译通过github的actions功能编译">方案二:云编译(通过GitHub的Actions功能编译)</h3>
<p><em>我已在我的<a href="https://github.com/alexcdever/homelede">仓库</a>配置好了,不想再动手操作一遍的话可以直接到<a href="https://github.com/alexcdever/homelede/actions/workflows/build-openwrt.yml">这里</a>下载点进去最新的workflow下载编译好的固件</em></p>
<ol>
<li>参考<strong>参考链接5</strong>(最近因为openethervpn5的编译有问题,导致最近整个HomeLede都出现问题,所以有需要的请等候作者修复。如果你的场景需求与我的相似,需要与我同款的CT模板的话,我已共享,请自取:<a href="https://drive.google.com/file/d/1dDDuBK-qB_xqriK5lMB3Fc8jHIRamRA3/view?usp=sharing">openwrt-x86-64-generic-rootfs-04-05.tar.gz</a>)
<ol>
<li>因为本身默认的配置并不会包含打包LXC所以要的容器模板,所以需要修改配置以打包出容器模板
<ol>
<li>直接copy我仓库中的<a href="https://github.com/alexcdever/homelede/blob/main/.config">.config</a> 文件到你自己的仓库里</li>
<li>参考教程中的<code>SSH 连接到 Actions</code> 小节</li>
</ol>
</li>
</ol>
</li>
</ol>
<h2 id="安装">安装</h2>
<ol>
<li>
<p>上传模板到PVE</p>
</li>
<li>
<p>因为webUI创建会迷之失败,所以接下来需要通过终端创建</p>
<ol>
<li>
<p>创建CT容器
<code>pct create {容器的ID} local:vztmpl/{模板名称} --rootfs local-lvm:{分配的系统盘大小} --ostype unmanaged --hostname {容器内外显示的主机名} --arch {系统架构} --cores {线程数} --memory {内存大小,单位是MB} --swap {交换分区大小,单位是MB} -{网络id} bridge={桥接网络},name={网络名称}</code>
将上方命令中必填项按自身需要修改即可,如: <code>pct create 201 local:vztmpl/openwrt-x86-64-generic-rootfs.tar.gz --rootfs local-lvm:1 --ostype unmanaged --hostname homelede --arch amd64 --cores 2 --memory 4096 --swap 512 -net0 bridge=vmbr0,name=eth0</code></p>
</li>
<li>
<p>编辑容器的相关读写权限
将以下内容追加到<code>/etc/pve/lxc/{容器ID}.conf</code> ,如我的即<code>为/etc/pve/lxc/201.conf</code> (<strong>注意,以下内容里也有地方要填写容器ID</strong> )</p>
<pre tabindex="0"><code>lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
lxc.include: /usr/share/lxc/config/openwrt.common.conf
lxc.cap.drop: sys_admin
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: c 108:0 rwm
lxc.autodev: 1
lxc.cgroup.devices.allow: c 10:200 rwm
lxc.hook.autodev: /var/lib/lxc/{容器id}/device_hook.sh
lxc.mount.entry: tmp tmp tmpfs rw,nodev,relatime,mode=1777 0 0
</code></pre><p>如:</p>
<pre tabindex="0"><code>lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
lxc.include: /usr/share/lxc/config/openwrt.common.conf
lxc.cap.drop: sys_admin
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: c 108:0 rwm
lxc.autodev: 1
lxc.cgroup.devices.allow: c 10:200 rwm
lxc.hook.autodev: /var/lib/lxc/201/device_hook.sh
lxc.mount.entry: tmp tmp tmpfs rw,nodev,relatime,mode=1777 0 0
</code></pre></li>
<li>
<p>在PVE的webUI上启动openwrt,并在容器内执行<code>mv /sbin/modprobe /sbin/mde</code></p>
<ol>
<li>
<p>如果启动失败,请检查 <code>/var/lib/lxc/{容器 ID}/device_hook.sh</code> 是否存在,如果不存在的话,请创建该文件,并写入以下内容:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">mknod /<span class="si">${</span><span class="nv">LXC_ROOTFS_MOUNT</span><span class="si">}</span>/dev/ppp c <span class="m">108</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl">mkdir -p <span class="si">${</span><span class="nv">LXC_ROOTFS_MOUNT</span><span class="si">}</span>/dev/net
</span></span><span class="line"><span class="cl">mknod /<span class="si">${</span><span class="nv">LXC_ROOTFS_MOUNT</span><span class="si">}</span>/dev/net/tun c <span class="m">10</span> <span class="m">200</span>
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ol>
</li>
</ol>
</li>
<li>
<p>参考<a href="https://github.com/xiaoqingfengATGH/HomeLede/wiki/HomeLede-%E5%BC%80%E7%AE%B1-%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C-%E4%BF%AE%E6%94%B9%E8%B7%AF%E7%94%B1IP">这里</a>修改IP和DNS</p>
<h2 id="设置为旁路由">设置为旁路由</h2>
</li>
<li>
<p>进入homelede,默认用户为<code>root</code>,默认密码为<code>password</code></p>
</li>
<li>
<p>去网络-接口,修改lan口</p>
<ol>
<li>设置<code>ipv4网关</code> 的值为主路由IP, 如我的是<code>192.168.3.1</code></li>
<li>DHCP-高级设置里勾选<code>强制</code> ,<code>DHCP选项</code> 的值设置为<code>6,{homelede的IP}</code> 如我的设置:<code>6,192.168.3.100</code></li>
<li>如果没有使用ipv6的需求的话就关掉ipv6,因为有的 OpenWrt 版本有 BUG,IPv6 可能影响到无线 AP 或者 DNS</li>
</ol>
</li>
<li>
<p>去网络-防火墙-常规设置里取消<code>启用 SYN-flood 防御</code>的勾选</p>
</li>
<li>
<p>重启homlede</p>
</li>
<li>
<p>找一台设备将网关设置为homelede的IP测试网络访问是否正常</p>
</li>
<li>
<p>进入主路由关闭主路由的DHCP功能并重启主路由</p>
</li>
<li>
<p>局域网内同一网段的设备重启以更新DHCP服务器为homelede</p>
</li>
</ol>
</description>
<category domain="https://blog.alexc.cn/categories/%E8%AE%B0%E5%BD%95/">记录</category>
<category domain="https://blog.alexc.cn/tags/pve/">PVE</category>
<category domain="https://blog.alexc.cn/tags/ct%E5%AE%B9%E5%99%A8/">CT容器</category>
<category domain="https://blog.alexc.cn/tags/%E8%BD%AF%E8%B7%AF%E7%94%B1/">软路由</category>
<category domain="https://blog.alexc.cn/tags/homelede/">homelede</category>
</item>
<item>
<title>为PVE配置APCUPSD断电后自动关机</title>
<link>https://blog.alexc.cn/posts/%E4%B8%BAnas%E9%85%8D%E7%BD%AEapcupsd%E6%96%AD%E7%94%B5%E5%90%8E%E8%87%AA%E5%8A%A8%E5%85%B3%E6%9C%BA/</link>
<guid isPermaLink="true">https://blog.alexc.cn/posts/%E4%B8%BAnas%E9%85%8D%E7%BD%AEapcupsd%E6%96%AD%E7%94%B5%E5%90%8E%E8%87%AA%E5%8A%A8%E5%85%B3%E6%9C%BA/</guid>
<pubDate>Tue, 23 Mar 2021 00:52:45 +0800</pubDate>
<author>alexcdever@gmail.com (Alex Chen)</author>
<copyright>[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh)</copyright>
<description><ol>
<li>
<p>安装apcupsd</p>
<ol>
<li><code>apt install apcupsd -y</code></li>
</ol>
</li>
<li>
<p>配置apcupsd</p>
<ol>
<li>
<p>编辑 <code>/etc/apcupsd/apcupsd.conf</code></p>
<ul>
<li>
<p>配置通信方式</p>
<pre tabindex="0"><code>UPSCABLE usb #usb表示通过USB端口连接
UPSTYPE usb #usb表示通过USB端口通信
DEVICE #留空表示让APCUPSD自行获取UPS串口
</code></pre></li>
<li>
<p>配置为断电一定时间后就关机</p>
<pre tabindex="0"><code>TIMEOUT 0 #当值为0时,表示不设置该属性;当值为非零正数N时,表示切换到UPS电池供电N秒后就会通知主机关机
</code></pre></li>
<li>
<p>配置为可用电量或可用时间达到指定额度时关机</p>
<pre tabindex="0"><code>BATTERYLEVEL 5 #表示当可用电量为5%时,通知主机关机
MINUTES 3 #表示当UPS电池的可用时间为3分钟时,通知主机关机
</code></pre><p>TIMEOUT其值非零时,它与BATTERYLEVEL和MINUTES,这仨任意满足一个时就会关机</p>
</li>
</ul>
</li>
<li>
<p>编辑 <code>/etc/default/apcupsd</code></p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Defaults for apcupsd initscript (unused with systemd as init).</span>
</span></span><span class="line"><span class="cl"><span class="c1"># Set to &#34;yes&#34; to enable startup of apcupsd.</span>
</span></span><span class="line"><span class="cl"><span class="nv">ISCONFIGURED</span><span class="o">=</span>yes
</span></span><span class="line"><span class="cl"><span class="nv">APCACCESS</span><span class="o">=</span>/sbin/apcaccess
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>启动该服务且允许开机自启动</p>
<p><code>systemctl enable apcupsd &amp;&amp; systemctl restart apcupsd</code></p>
</li>
</ol>
</li>
<li>
<p>测试</p>
<p>执行 <code>apcaccess status</code> 后有类似如下信息则表示安装配置成功:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span><span class="lnt">34
</span><span class="lnt">35
</span><span class="lnt">36
</span><span class="lnt">37
</span><span class="lnt">38
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="o">[</span>root@pve<span class="o">]</span>~❯❯❯ apcaccess status
</span></span><span class="line"><span class="cl">APC : 001,036,0865
</span></span><span class="line"><span class="cl">DATE : 2021-03-17 00:14:16 +0800
</span></span><span class="line"><span class="cl">HOSTNAME : pve
</span></span><span class="line"><span class="cl">VERSION : 3.14.14 <span class="o">(</span><span class="m">31</span> May 2016<span class="o">)</span> debian
</span></span><span class="line"><span class="cl">UPSNAME : ups
</span></span><span class="line"><span class="cl">CABLE : USB Cable
</span></span><span class="line"><span class="cl">DRIVER : USB UPS Driver
</span></span><span class="line"><span class="cl">UPSMODE : Stand Alone
</span></span><span class="line"><span class="cl">STARTTIME: 2021-03-16 23:51:50 +0800
</span></span><span class="line"><span class="cl">MODEL : BK650M2-CH
</span></span><span class="line"><span class="cl">STATUS : ONBATT
</span></span><span class="line"><span class="cl">LINEV : 243.0 Volts
</span></span><span class="line"><span class="cl">LOADPCT : 19.0 Percent
</span></span><span class="line"><span class="cl">BCHARGE : 100.0 Percent
</span></span><span class="line"><span class="cl">TIMELEFT : 24.0 Minutes
</span></span><span class="line"><span class="cl">MBATTCHG : <span class="m">10</span> Percent
</span></span><span class="line"><span class="cl">MINTIMEL : <span class="m">5</span> Minutes
</span></span><span class="line"><span class="cl">MAXTIME : <span class="m">0</span> Seconds
</span></span><span class="line"><span class="cl">SENSE : Low
</span></span><span class="line"><span class="cl">LOTRANS : 160.0 Volts
</span></span><span class="line"><span class="cl">HITRANS : 278.0 Volts
</span></span><span class="line"><span class="cl">ALARMDEL : <span class="m">30</span> Seconds
</span></span><span class="line"><span class="cl">BATTV : 13.5 Volts
</span></span><span class="line"><span class="cl">LASTXFER : Automatic or explicit self <span class="nb">test</span>
</span></span><span class="line"><span class="cl">NUMXFERS : <span class="m">1</span>
</span></span><span class="line"><span class="cl">XONBATT : 2021-03-17 00:10:06 +0800
</span></span><span class="line"><span class="cl">TONBATT : <span class="m">255</span> Seconds
</span></span><span class="line"><span class="cl">CUMONBATT: <span class="m">255</span> Seconds
</span></span><span class="line"><span class="cl">XOFFBATT : N/A
</span></span><span class="line"><span class="cl">SELFTEST : OK
</span></span><span class="line"><span class="cl">STATFLAG : 0x05060010
</span></span><span class="line"><span class="cl">SERIALNO : 9B2015A09122
</span></span><span class="line"><span class="cl">BATTDATE : 2001-01-01
</span></span><span class="line"><span class="cl">NOMINV : <span class="m">220</span> Volts
</span></span><span class="line"><span class="cl">NOMBATTV : 12.0 Volts
</span></span><span class="line"><span class="cl">NOMPOWER : <span class="m">390</span> Watts
</span></span><span class="line"><span class="cl">END APC : 2021-03-17 00:14:21 +0800
</span></span></code></pre></td></tr></table>
</div>
</div></li>