0%

前言

前段时间因为有任务,需要四个电商(京东、淘宝、天猫、拼多多)的数据。而其中京东的没什么反爬,基本是随便抓。拼多多的加密参数有点复杂,而且变化也挺频繁的,用的是 selenium,也没什么可提的。抓淘宝和天猫因为用 selenium 滑块过不了,于是就改成了 pyppeteer。现在我说一下使用的心得。有些细节因为当时没有记录,现在也记不起来了。

阅读全文 »

1
2
npm config set prefix "C:\\Users\\Admin\\.nodejs\\node_global"
npm config set cache "C:\\Users\\Admin\\.nodejs\\node_cache"
阅读全文 »

当你执行一个32位程序的时候,你可能会发现提示No such file ordirectory,这就是说明你的64位系统没有安装32位的lib库,如何知道一个程序是32位还是64位呢,也很简单,可以通过readelf来看。呃,如果你确定你执行的是32位程序,而你是64位系统,则出现Nosuch file or directory错误就是因为你缺少了32位的库文件。解决方法也很简单:

阅读全文 »

1、运行Docker镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
docker run -d \
--name=softethervpn \
--restart=always --cap-add NET_ADMIN \
-p 500:500/udp \
-p 4500:4500/udp \
-p 1701:1701/tcp \
-p 1194:1194/udp \
-p 5555:5555/tcp \
-e SPW=超级管理员密码 \
-e HPW=普通管理员密码 \
-e PSK=vpn \
-e USERNAME=用户名 \
-v /dev/null:/usr/vpnserver/server_log \
-v /dev/null:/usr/vpnserver/packet_log \
-v /dev/null:/usr/vpnserver/security_log\
-e PASSWORD=密码 \
siomiz/softethervpn:alpine

第一章、操作系统概述

一、为什么要区分系统态和用户态?

​ 防止操作系统和关键数据受到用户程序有意或无意的破坏,通常将处理机的执行状态分为系统态和用户态

阅读全文 »

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
任务描述
相关知识
如何使用happpybase连接HBase数据库
编程要求
好了,到你啦,使用本关知识,在右侧命令行完成下面的任务要求:
任务描述
本关任务:使用python代码在HBase中创建表。

相关知识
为了完成本关任务,你需要掌握:1.如何使用happybase 连接HBase数据库,2.如何使用python代码在HBase中创建表。

如何使用happpybase连接HBase数据库
一、连接(happybase.Connection)
import happybase
happybase.Connection(host=’localhost’, port=9090, timeout=None, autoconnect=True, table_prefix=None, table_prefix_separator=b’_’, compat=’0.98’, transport=’buffered’, protocol=’binary’)
获取连接实例
host:主机名
port:端口
timeout:超时时间
autoconnect:连接是否直接打开
table_prefix:用于构造表名的前缀
table_prefix_separator:用于table_prefix的分隔符
compat:兼容模式
transport:运输模式
protocol:协议
例:
connection = happybase.Connection(host=”192.168.0.156”,port=9090,timeout=None,autoconnect=True,table_prefix=None,table_prefix_separator=b’_’,compat=’0.98’, transport=’buffered’,protocol=’binary’)

当connection被创建的时候,默认自动与Hbase建立socket连接的。
若不想自动与Hbase建立socket连接,可以将autoconnect参数设置为False
connection = happybase.Connection(‘10.1.13.111’, autoconnect=False)
然后手动与Hbase建立socket连接
connection.open()
open():打开传输,无返回值
close():关闭传输,无返回值
connection.close()
连接建立好之后查看可以使用的table
print connection.tables()
因为还没有创建table,所以返回结果是 []

二、创建一个table
create_table(name,families):创建表,无返回值
name:表名
families:列族
families = { “cf”:dict(), “df”:dict()}
connection.create_table(name,families)
如果连接时,有传递表前缀参数时,真实表名将会是:”{}_{}”.format(table_prefix,name)

connection.create_table(
‘my_table’,
{
‘cf1’: dict(max_versions=10),
‘cf2’:dict(max_versions=1,block_cache_enabled=False),
‘cf3’: dict(), # use defaults
}
)
此时,我们再通过connection.tables()查看可以使用的table,结果为[‘my_table’]
创建的table即my_table包含3个列族:cf1、cf2、cf3

编程要求
好了,到你啦,使用本关知识,在右侧命令行完成下面的任务要求:
1执行环节搭建脚本,为使用Python语言操作hbase做好准备。
cd /data/workspace/myshixun/opt/
chmod +x setup-env.sh
./setup-env.sh
这里可能需要等待几分钟,让脚本执行完,thrift和happybase就安装好了。
接下来可以查看各个服务进程是否启动
jps
‘’
root@evassh-2932225:~# jps
1808 ResourceManager
4785 Jps
2820 ThriftServer
1317 NameNode
2694 HRegionServer
1447 DataNode
2506 HQuorumPeer
1626 SecondaryNameNode
2570 HMaster
‘’
如果启动过程中出现:
localhost: zookeeper running as process 2474. Stop it first. master running as process 2538. Stop it first. : regionserver running as process 2665. Stop it first. thrift running as process 2789. Stop it first.

需要我们重新
/app/hbase-2.1.1/binhbase-daemon.sh stop thrift stop-dfs.sh 和stop-hbase.sh,然后再重启。

2 进入Python编译器完成连接和创建表
python3

3 建立一个本地连接对象conn,使用本机和默认端口建立连接
4 创建一个名为student1的表,有两个列族:info和scores
注意:列族定义之间的逗号后要空一格,否则会出错。
5 可以使用conn.tables()查看表是否创建好。
如果出现‘BrokenPipeError: [Errno 32] Broken pipe’提示,说明连接已经自动关闭,每次连接如果超过60秒没有操作,就会自动关闭,需要重新建立连接。
6 退出Python编译器

开始你的任务吧,祝你成功!
阅读全文 »

4、调度与死锁

磁盘效率的计算

image-20201218103303641

调度算法

image-20201218103417049

2分钟

0第一轮:A B C D E

8第二轮:A B D E

6第三轮: A B E

阅读全文 »

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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="../webapps/app" reloadable="true" />

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
</Engine>
</Service>
</Server>
阅读全文 »