0%

确保安装xcode和brew

安装编译工具和部分依赖

1
$ brew install automake libtool boost curl lzlib libsigc++ openssl xmlrpc-c

编译安装libtorrent

1
2
3
4
5
6
$ git clone https://github.com/rakshasa/libtorrent.git
$ cd libtorrent
$ ./autogen.sh
$ CC=clang CXX=clang++ CXXFLAGS="-Wno-deprecated-declarations -O3 -std=c++11 -stdlib=libc++ -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" ./configure
$ make
$ make install

libtorrent安装到/usr/local/lib

编译安装rtorrent

1
2
3
4
5
6
7
$ git clone https://github.com/rakshasa/rtorrent.git
$ cd rtorrent
$ ./autogen.sh
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ CC=clang CXX=clang++ CXXFLAGS="-Wno-deprecated-declarations -O3 -std=c++11 -stdlib=libc++ -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" ./configure --with-xmlrpc-c
$ make
$ make install

rtorrent安装到/usr/local/bin

运行

1
$ rtorrent

默认配置文件为~/.rtorrent.rc

References:
[1]libtorrent and rtorrent on mac.sh
[2]rTorrent cheatsheet
[3]Navigating

alacritty在使用wayland的系统上无法切换出中文输入法,将alacritty菜单项执行的命令更改为:

1
env WINIT_UNIX_BACKEND=x11 alacritty

这样将渲染后端更改为x11

比如~/.local/share/applications/alacritty.desktop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\[Desktop Entry\]
Type=Application
TryExec=alacritty
Exec=env WINIT_UNIX_BACKEND=x11 alacritty
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;

Name=Alacritty
GenericName=Terminal
Comment=A cross-platform, GPU enhanced terminal emulator
StartupWMClass=Alacritty
Actions=New;

\[Desktop Action New\]
Name=New Terminal
Exec=alacritty

下载

下载64位安装包

安装

1
2
3
$ sudo apt install libqt4-declarative
$ sudo dpkg -i sogoupinyin_2.3.1.0112_amd64.deb
$ sudo apt install -f

如果不安装libqt4-declarative,搜狗输入法无法正常使用,并且会报
“搜狗输入法异常:删除~/.config/SogouPY并重新启动”,
如果终端内输入命令sogou-qimpanel,会提示:

1
2
$ sogou-qimpanel
sogou-qimpanel: error while loading shared libraries: libQtDeclarative.so.4: cannot open shared object file: No such file or directory

配置
安装完毕后,运行fcitx-config-gtk3或者fcitx-configtool,然后在input method页签内点击+号添加sogou pinyin输入法,搜索输入法时去掉“only show current language”选项。

1
2
$ sudo mv /var/lib/dpkg/info/PACKAGE_NAME.* /tmp/
$ sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME

此配置主要用于监控主机状态,prometheus还可以监控各种服务的状态,只要使用相应的exporter即可。

prometheus

监控节点安装prometheus,被监控节点只需安装prometheus-node-exporter

1
$ sudo apt install prometheus

/etc/prometheus/prometheus.yml文件中添加被监控节点

1
2
3
4
5
6
7
8
9
10
11
12
- job_name: node
# If prometheus-node-exporter is installed, grab stats about the local
# machine by default.
static_configs:
# 被监控节点,默认
- targets: \['localhost:9100'\]
labels:
hostname: 'vmin'
# 被监控节点
- targets: \['10.100.0.31:9100'\]
labels:
hostname: 'vmsvr02'

添加主机名标签,方便管理。
通过监控主机的9090端口访问prometheus,http://ip_of_monitor:9090/

alertmanager
在监控主机安装

1
$ sudo apt install prometheus-alertmanager

添加节点监控规则文件/etc/prometheus/node-alert.rules:

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
# hostStatsAlert
groups:
- name: hostStatsAlert
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
labels:
severity: page
annotations:
summary: "Instance {{$labels.instance}} down"
description: "{{$labels.instance}} of job {{$labels.job}} has been down for more than 5 minutes."
- alert: hostCpuUsageAlert
expr: sum(avg without (cpu)(irate(node_cpu_seconds_total{mode!='idle'}\[5m\]))) by (instance) > 0.85
for: 1m
labels:
severity: page
annotations:
summary: "Instance {{ $labels.instance }} CPU usgae high"
description: "{{ $labels.instance }} CPU usage above 85% (current value: {{ $value }})"
- alert: hostMemUsageAlert
expr: (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)/node_memory_MemTotal_bytes > 0.85
for: 1m
labels:
severity: page
annotations:
summary: "Instance {{ $labels.instance }} MEM usgae high"
description: "{{ $labels.instance }} MEM usage above 85% (current value: {{ $value }})"
- alert: filesystemUsageAlert
expr: 100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype=~"ext4xfs"} * 100) / node_filesystem_size_bytes {mountpoint="/",fstype=~"ext4xfs"}) > 85
for: 1m
labels:
severity: page
annotations:
summary: "Instance {{ $labels.instance }} root DISK usgae high"
description: "{{ $labels.instance }} root DISK usage above 85% (current value: {{ $value }})"

此规则文件主要监测主机在线状态,cpu、memory和filesystem使用率

/etc/prometheus/prometheus.yml引用此规则文件:

1
2
rule_files:
- "node-alert.rules"

alertmanager配置邮件报警/etc/prometheus/alertmanager.yml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
global:
# The smarthost and SMTP sender used for mail notifications.
smtp_smarthost: 'smtp.163.com:25'
smtp_from: 'abc@163.com'
smtp_auth_username: 'abc@163.com'
smtp_auth_password: 'password'
...
# A default receiver
receiver: team-X-mails
...
receivers:
- name: 'team-X-mails'
email_configs:
- to: '123@163.com'

重新装载prometheus和alertmanager服务,停止一个被监控节点的监控服务,就可以收到报警邮件了。

grafana

可以使用grafana来展示prometheus监控信息
安装grafana

1
2
3
4
5
$ sudo apt-get install -y software-properties-common
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
$ wget -q -O - https://packages.grafana.com/gpg.key sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install grafana

通过http 3000端口来访问grafana,然后添加prometheus数据源,添加展示prometheus数据的dashboard

References:
[1]Prometheus Alertmanager 基本配置
[2]alertmanager报警规则详解

移除osd节点

查看当前osd状态

1
2
3
4
5
6
7
8
9
10
11
$ ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 9.74405 root default
-9 0.95409 host bank1
3 hdd 0.95409 osd.3 up 1.00000 1.00000
-3 5.99799 host vm01
0 hdd 5.99799 osd.0 up 1.00000 1.00000
-5 1.81929 host vm02
1 hdd 1.81929 osd.1 up 1.00000 1.00000
-7 0.97269 host web
2 hdd 0.97269 osd.2 up 1.00000 1.00000

将osd标记为out,准备踢出集群,{osd-num}为osd编号,比如osd.2

1
$ ceph osd out {osd-num}

集群会进行重新平衡和数据迁移,查看

1
$ ceph -w

ceps -s也可以查看进度,当完成时集群状态会重新回归到actice+clean状态
如果卡在active+clean+remapped或者active+remapped状态,先将osd回归集群

1
$ ceph osd in {osd-num}

等集群恢复到active+clean状态后,执行

1
$ ceph osd crush reweight osd.{osd-num} 0

等集群状态再次变成active+clean状态后,将osd标记为out,并停止ceph-osd服务

1
2
$ ceph osd out {osd-num}
$ sudo systemctl stop ceph-osd@2.service

移除osd

1
2
$ ceph osd purge osd.{osd-num} --yes-i-really-mean-it
purged osd.2

移除mon节点

1
$ ceph mon remove {mon-name}

移除mgr节点
在将要被移除的mgr节点上执行

1
2
3
$ sudo systemctl stop ceph-mgr@{mgr-name}
$ sudo systemctl disable ceph-mgr@{mgr-name}
$ sudo rm -rf /var/lib/ceph/mgr/ceph-{mgr-name}

移除mds节点
在将要被移除的mds节点上执行

1
2
3
$ sudo systemctl stop ceph-mds@{mds-name}
$ sudo systemctl disable ceph-mds@{mds-name}
$ sudo rm -rf /var/lib/ceph/mds/ceph-{mds-name}

References:
[1]ADDING/REMOVING OSDS
[2]DEPLOYING METADATA SERVERS

创建测试使用的pool

1
$ ceph osd pool create testbench 32 32

写测试

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
$ rados bench -p testbench 10 write --no-cleanup
hints = 1
Maintaining 16 concurrent writes of 4194304 bytes to objects of size 4194304 for up to 10 seconds or 0 objects
Object prefix: benchmark_data_work_17785
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 0 0 0 0 0 - 0
1 16 18 2 7.99976 8 0.743612 0.641529
2 16 30 14 27.9973 48 1.85864 1.29122
3 16 42 26 34.663 48 1.28555 1.39395
4 16 55 39 38.9956 52 1.32261 1.43965
5 16 58 42 33.5958 12 1.53666 1.44482
6 16 68 52 34.662 40 2.08014 1.50223
7 16 84 68 38.8516 64 0.823587 1.5045
8 16 96 80 39.9944 48 0.899492 1.44845
9 16 114 98 43.5496 72 0.633734 1.40136
10 16 123 107 42.7941 36 0.856593 1.3861
Total time run: 10.6523
Total writes made: 124
Write size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 46.5625
Stddev Bandwidth: 20.2254
Max bandwidth (MB/sec): 72
Min bandwidth (MB/sec): 8
Average IOPS: 11
Stddev IOPS: 5.05635
Max IOPS: 18
Min IOPS: 2
Average Latency(s): 1.3707
Stddev Latency(s): 0.472979
Max latency(s): 2.64427
Min latency(s): 0.539447

顺序读测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ rados bench -p testbench 10 seq
hints = 1
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 0 0 0 0 0 - 0
1 16 42 26 103.976 104 0.588145 0.431675
2 16 69 53 105.983 108 0.593612 0.500811
3 16 98 82 109.319 116 0.555486 0.529656
4 15 124 109 108.986 108 0.408214 0.531251
Total time run: 4.45077
Total reads made: 124
Read size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 111.441
Average IOPS: 27
Stddev IOPS: 1.25831
Max IOPS: 29
Min IOPS: 26
Average Latency(s): 0.567093
Max latency(s): 1.16315
Min latency(s): 0.062019

随机读测试

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
$ rados bench -p testbench 10 rand
hints = 1
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 0 0 0 0 0 - 0
1 16 43 27 107.978 108 0.548233 0.400351
2 16 70 54 107.985 108 0.507102 0.467039
3 16 99 83 110.653 116 0.66861 0.518288
4 16 128 112 111.987 116 0.821184 0.518217
5 16 155 139 111.187 108 0.71247 0.532804
6 16 183 167 111.32 112 0.698042 0.541571
7 16 211 195 111.416 112 0.137 0.545219
8 16 239 223 111.488 112 0.797219 0.549091
9 16 267 251 111.543 112 0.249707 0.547871
10 16 296 280 111.988 116 0.577749 0.555318
Total time run: 10.5902
Total reads made: 297
Read size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 112.179
Average IOPS: 28
Stddev IOPS: 0.816497
Max IOPS: 29
Min IOPS: 27
Average Latency(s): 0.565831
Max latency(s): 1.20987
Min latency(s): 0.0559923

清除测试数据

1
2
$ rados -p testbench cleanup
Removed 124 objects

References:
[1]CHAPTER 9. BENCHMARKING PERFORMANCE

tomcat9默认的文件创建权限UMASK更改为0027,创建的文件/目录其他用户是没有权限访问的,而nginx worker process默认使用nobody用户来运行,因此也无法访问tomcat9创建的文件

更改tomcat9的UMASK

/usr/share/tomcat9/bin目录下如果没有setenv.sh,添加此文件,内容如下:

1
UMASK=0022

使此文件可执行:

1
$ sudo chmod +x setenv.sh

重新启动tomcat9

1
$ sudo systemctl restart tomcat9