三湘古邑

我想在那里最蓝的大海扬帆。

0%

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
import cn.hutool.core.date.DateUtil;
import junit.framework.TestCase;

import java.util.concurrent.*;

public class TestJug extends TestCase {

public void testNewCachedThreadPool() throws InterruptedException {
ExecutorService executorService = Executors.newCachedThreadPool();
for (int i = 0; i < 10; i++) {
final int index = i;
executorService.execute(() -> {
// 获取线程名称,默认格式:pool-1-thread-1
System.out.println(DateUtil.now() + " " + Thread.currentThread().getName() + " " + index);
// 等待2秒
sleep(TimeUnit.SECONDS,2);
});
}
executorService.awaitTermination(3, TimeUnit.SECONDS);
}

public void testNewFixedThreadPool() throws InterruptedException {
ExecutorService executorService = Executors.newFixedThreadPool(5);
for (int i = 0; i < 10; i++) {
final int index = i;
executorService.execute(() -> {
// 获取线程名称,默认格式:pool-1-thread-1
System.out.println(DateUtil.now() + " " + Thread.currentThread().getName() + " " + index);
// 等待2秒
sleep(TimeUnit.SECONDS,2);
});
}
executorService.awaitTermination(3, TimeUnit.SECONDS);

}

public void testNewSingleThreadPool() throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
for (int i = 0; i < 10; i++) {
final int index = i;
executorService.execute(() -> {
// 获取线程名称,默认格式:pool-1-thread-1
System.out.println(DateUtil.now() + " " + Thread.currentThread().getName() + " " + index);
// 等待1秒
sleep(TimeUnit.MILLISECONDS,1000);
});
}
executorService.awaitTermination(11, TimeUnit.SECONDS);

}


public void testNewScheduledThreadPool() throws InterruptedException {
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(3);
System.out.println(DateUtil.now() + " 提交任务");
for (int i = 0; i < 10; i++) {
final int index = i;
executorService.execute(() -> {
// 获取线程名称,默认格式:pool-1-thread-1
System.out.println(DateUtil.now() + " " + Thread.currentThread().getName() + " " + index);
// 等待1秒
sleep(TimeUnit.SECONDS,1);
});
}

executorService.awaitTermination(6, TimeUnit.SECONDS);

}

public void testCreateThreadPool() throws InterruptedException {
//阻塞队列和拒绝策略根据实际情况可自行选择
ExecutorService executorService = new ThreadPoolExecutor(2, 10,
1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(5, true),
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
for (int i = 0; i < 10; i++) {
final int index = i;
executorService.execute(() -> {
// 获取线程名称,默认格式:pool-1-thread-1
System.out.println(DateUtil.now() + " " + Thread.currentThread().getName() + " " + index);
// 等待2秒
sleep(TimeUnit.SECONDS,2);
});
}
executorService.awaitTermination(5, TimeUnit.SECONDS);
}

private void sleep(TimeUnit timeUnit,int time){
try {
timeUnit.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

Executors返回的线程池对象的弊端如下:
FixedThreadPool和SingleThreadPool:允许的请求队列长度为Integer.MAX_VALUE,可能会堆积大量的请求,从而导致OOM。
CachedThreadPool和ScheduledThreadPool:允许的创建线程数量为Integer.MAX_VALUE,可能会创建大量的线程,从而导致OOM。

执行命令

1
ab -c5 -n500 -p x.txt -T 'application/xml' 'http://192.168.0.8/xxx'

测试结果

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
This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.8 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software: nginx/1.22.0
Server Hostname: 192.168.0.8
Server Port: 80

Document Path: /xxx
Document Length: 138 bytes

Concurrency Level: 5
Time taken for tests: 5.129 seconds
Complete requests: 500
Failed requests: 1
(Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Non-2xx responses: 1
Total transferred: 201850 bytes
Total body sent: 578500
HTML transferred: 68961 bytes
Requests per second: 97.48 [#/sec] (mean)
Time per request: 51.293 [ms] (mean)
Time per request: 10.259 [ms] (mean, across all concurrent requests)
Transfer rate: 38.43 [Kbytes/sec] received
110.14 kb/s sent
148.57 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 11 21 6.4 21 43
Processing: 19 29 8.6 28 88
Waiting: 18 29 8.3 27 88
Total: 30 50 10.6 49 106

Percentage of the requests served within a certain time (ms)
50% 49
66% 52
75% 55
80% 57
90% 62
95% 69
98% 83
99% 100
100% 106 (longest request)

修改配置文件 nsswitch_conf

sudo vim /etc/nsswitch.conf进入配置文件

1
2
#host: files mdns4_minimal [NOTFOUND=return] dns
host: files

先用/etc/hosts文件解析,解析不了再查dns

修改配置文件sshd_config

sudo vim /etc/ssh/sshd_config进入配置文件

更改UseDNS

1
2
# UseDNS yes
UseDNS no

UseDNS 选项打开状态下,当通过终端登录 SSH 服务器时,服务器端先根据客户端的 IP 地址进行 DNS PTR 反向查询出客户端的主机名,然后根据查询出的客户端主机名进行 DNS 正向 A 记录查询,验证与其原始 IP 地址是否一致,这是防止客户端欺骗的一种措施。

更改GSSAPIAuthentication

1
2
# GSSAPIAuthentication yes
GSSAPIAuthentication no

这个 GSSAPI(generic security services application programming interface),是一套通用网络安全系统接口。该接口是对各种不同的客户端服务器安全机制的封装,以消除安全接口的不同,降低编程难度。

修改客户端配置文件 ssh_config

更改GSSAPIAuthentication

1
2
# GSSAPIAuthentication yes
GSSAPIAuthentication no

ssh_config 和 sshd_config 都是 ssh 服务器的配置文件,二者区别在于,前者是针对客户端的配置文件,后者则是针对服务端的配置文件。两个配置文件都允许你通过设置不同的选项来改变客户端程序的运行方式。

序号 大写 小写 英文注音 国际音标注音 中文读音 意义
1 Α α alpha a:lf 阿尔法 角度;系数
2 Β β beta bet 贝塔 磁通系数;角度;系数
3 Γ γ gamma ˈɡæmə 伽马 电导系数(小写)
4 Δ δ delta delt 德尔塔 变动;密度;屈光度
5 Ε ε epsilon ep`silon 伊普西龙 对数之基数
6 Ζ ζ zeta zat 截塔 系数;方位角;阻抗;相对粘度;原子序数
7 Η η eta eit 艾塔 磁滞系数;效率(小写)
8 Θ θ thet θit 西塔 温度;相位角
9 Ι ι iot aiot 约塔 微小,一点儿
10 Κ κ kappa kap 卡帕 介质常数
11 Λ λ lambda lambd 兰布达 波长(小写);体积
12 Μ μ mu mju 磁导系数微(千分之一)放大因数(小写)
13 Ν ν nu nju 磁阻系数
14 Ξ ξ xi ksi 克西
15 Ο ο omicron omik`ron 奥密克戎
16 Π π pi pai 圆周率=圆周÷直径=3.14159 26535 89793
17 Ρ ρ rho rou 电阻系数(小写)
18 Σ σ sigma `sigma 西格马 总和(大写),表面密度;跨导(小写)
19 Τ τ tau tau 时间常数
20 Υ υ upsilon jup`silon 宇普西龙 位移
21 Φ φ phi fai 佛爱 磁通;角
22 Χ χ chi phai 西
23 Ψ ψ psi psai 普西 角速;介质电通量(静电力线);角
24 Ω ω omega o`miga 欧米伽 欧姆(大写);角速(小写);角

使用 Apache Pig 从大数据集中获得所需的信息

Apache Pig 是一个高级过程语言,适合于使用 Hadoop 和 MapReduce 平台来查询大型半结构化数据集。通过允许对分布式数据集进行类似 SQL 的查询,Pig 可以简化 Hadoop 的使用。本文将探索 Pig 背后的语言,并在一个简单的 Hadoop 集群中发现其用途。

Read more »

Elasticsearch 是一个建立在全文搜索引擎 Apache Lucene(TM) 基础上的搜索 引擎,可以说 Lucene 是当今最先进,最高效的全功能开源搜索引擎框架。
但是 Lucene 只是一个框架,要充分利用它的功能,你需要使用 JAVA,并且在 你的程序中集成 Lucene。更糟的是,你需要做很多的学习了解,才能明白它是 如何运行的,Lucene 确实非常复杂。
Elasticsearch 使用 Lucene 作为内部引擎,但是在你使用它做全文搜索时,只 需要使用统一开发好的API即可,而并不需要了解其背后复杂的 Lucene 的运行 原理。

Read more »

查看你现在的存储设备的序列号:

1
ll /dev/disk/by-id

然后就能看到所有存储设备的序列号
1
lrwxrwxrwx 1 root root  9  2月  6 11:47 ata-KINGSTON_SA400S37240G_XXXXX -> ../../sda

然后输入以下代码(请把硬盘序列号换成你硬盘的,100换成你LEDE的虚拟机ID)
1
qm set 100 -sata1 /dev/disk/by-id/ata-KINGSTON_SA400S37240G_XXXXX

如果返回以下信息,说明已成功挂载
1
update VM 100: -sata1 /dev/disk/by-id/ata-KINGSTON_SA400S37240G_XXXXX

然后可以进入PVE管理网页,查看是否真的挂载成功.如果看到LEDE虚拟机硬件设备里有这个,就说明成功.

不压缩备份

1
#tar cvf arch-backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/home/hlooc/data --exclude=/sys --exclude=/mnt --exclude=/run/media / >> back.log &

压缩备份

1
#tar zcvf arch-backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/home/hlooc/data --exclude=/sys --exclude=/mnt --exclude=/run/media / >> back.log &

–exclude排除不备份的目录