部署Docker Registry v2服务
📅 2017-01-06
生成自签名证书 #
因为没有公网ip和域名,所以这里修改/etc/pki/tls/openssl.cnf以生成带SAN 扩展的证书。 在openssl.cnf文件中修改以下内容:
1[ v3_ca ]
2#指定ip
3subjectAltName=IP:192.168.61.100
创建证书目录:
...因为没有公网ip和域名,所以这里修改/etc/pki/tls/openssl.cnf以生成带SAN 扩展的证书。 在openssl.cnf文件中修改以下内容:
1[ v3_ca ]
2#指定ip
3subjectAltName=IP:192.168.61.100
创建证书目录:
...可以使用repoquery,需要先安装yum-utils
:
1yum install -y yum-utils
1repoquery --installed -l ntp
2/etc/dhcp/dhclient.d
3/etc/dhcp/dhclient.d/ntp.sh
4/etc/ntp.conf
5/etc/ntp/crypto
6/etc/ntp/crypto/pw
7/etc/sysconfig/ntpd
8/usr/bin/ntpstat
9......
也可以使用rpm命令:
1rpm -ql ntp
在rpm包安装之前可以提前查看rpm包中的文件:
...进程是Linux系统结构的基础,进程简单的理解就是一段程序的执行过程。系统的每一个进程会有不同的状态。
Linux源码中对进程状态的定义fs/proc/array.c:
1static const char * const task_state_array[] = {
2 "R (running)", /* 0 */
3 "S (sleeping)", /* 1 */
4 "D (disk sleep)", /* 2 */
5 "T (stopped)", /* 4 */
6 "t (tracing stop)", /* 8 */
7 "X (dead)", /* 16 */
8 "Z (zombie)", /* 32 */
9};
系统进程状态包括:
...Go也是垃圾回收的,实现方式和别的语言不太一样。
先从Go的标准库的runtime包说起,这个包有很多运行时相关的类型和函数。
调用runtimea.GC()可以触发GC,但我们一般不会这么做,先读一下这个函数的注释说明。
1GC runs a garbage collection and blocks the caller until the garbage collection is complete.
2It may also block the entire program
大概的意思是,Go的GC触发时会阻塞整个程序的运行。这个在垃圾回收里面有一个比较有名的名词叫STW,Stop the World。就是说程序在GC时“整个世界会停止下来”。 Go垃圾回收的STW一直是Go语言被指责和诟病最多的地方,也是Go的每个版本都努力改进的地方。
...MySQL的错误日志是默认开启,且必须开启。查看错误日志的位置:
...关于leader的选举,Zookeeper提供了三种方式:LeaderElection, AuthFastLeaderElection, FastLeaderElection。 其中FastLeaderElection是Zookeeper默认使用的。 当ZK服务启动的时候首先要做的事情就是Leader的选举。在选举过程中,每个zk server会有以下四种选举状态:
...Go中的map使用哈希表实现的,在源码go runtime/hashmap.go中可以看到对应实现。
1// A header for a Go map.
2type hmap struct {
3 // Note: the format of the Hmap is encoded in ../../cmd/internal/gc/reflect.go and
4 // ../reflect/type.go. Don't change this structure without also changing that code!
5 count int // # live cells == size of map. Must be first (used by len() builtin)
6 flags uint8
7 B uint8 // log_2 of # of buckets (can hold up to loadFactor * 2^B items)
8 noverflow uint16 // approximate number of overflow buckets; see incrnoverflow for details
9 hash0 uint32 // hash seed
10
11 buckets unsafe.Pointer // array of 2^B Buckets. may be nil if count==0.
12 oldbuckets unsafe.Pointer // previous bucket array of half the size, non-nil only when growing
13 nevacuate uintptr // progress counter for evacuation (buckets less than this have been evacuated)
14
15 // If both key and value do not contain pointers and are inline, then we mark bucket
16 // type as containing no pointers. This avoids scanning such maps.
17 // However, bmap.overflow is a pointer. In order to keep overflow buckets
18 // alive, we store pointers to all overflow buckets in hmap.overflow.
19 // Overflow is used only if key and value do not contain pointers.
20 // overflow[0] contains overflow buckets for hmap.buckets.
21 // overflow[1] contains overflow buckets for hmap.oldbuckets.
22 // The first indirection allows us to reduce static size of hmap.
23 // The second indirection allows to store a pointer to the slice in hiter.
24 overflow *[2]*[]*bmap
25}
26
27// A bucket for a Go map.
28type bmap struct {
29 // tophash generally contains the top byte of the hash value
30 // for each key in this bucket. If tophash[0] < minTopHash,
31 // tophash[0] is a bucket evacuation state instead.
32 tophash [bucketCnt]uint8
33 // Followed by bucketCnt keys and then bucketCnt values.
34 // NOTE: packing all the keys together and then all the values together makes the
35 // code a bit more complicated than alternating key/value/key/value/... but it allows
36 // us to eliminate padding which would be needed for, e.g., map[int64]int8.
37 // Followed by an overflow pointer.
38}
先删掉代码原有注释,以便于查看:
...一个slice本质上是一个数组的某个部分的引用。在go runtime/slice.go源码中定义了slice的结构:
1type slice struct {
2 array unsafe.Pointer
3 len int
4 cap int
5}
可以看到在Go的内部,slice是一个包含3个字段的结构体:
...iptables是带有状态机制的防火墙,可以跟踪连接状态,我们可以根据状态编写更细致的规则。 iptables可以跟踪一下四种状态:
例如:
...iptables是Linux中基于内核的防火墙,功能十分强大。 iptables工作在网络层,不需要把数据发送到用户空间,在系统内核空间中进行数据过滤可以保证数据处理效率。 当数据包到达iptables之后,如果MAC地址相符,就会由内核中的相应驱动程序接收,通过一系列操作决定将数据包发送给本地程序或转发到其他主机,或进行其他操作。 iptables由一系列表(table)组成,表再由一系列链(chain)组成,当数据包到达iptables之后,就会基于规则按一定顺序穿越不同的表和链。
...