yum list installed | grep java
yum install -y java # jre
yum install -y java-1.8.0-openjdk # jre
yum install -y java-1.8.0-openjdk-devel # javac
apt install default-jdk
# 看那个java
which java
ls -lrt /usr/bin/java
ls -lrt /etc/alternatives/java
# vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
# ln
ln -sf /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/bin/java /etc/alternatives/java
sentry
<!-- bitdata -->
<script src="https://cdn.ravenjs.com/3.26.4/raven.min.js" crossorigin="anonymous"></script>
<script>
Raven.config('https://dd21f2cdb6e5465fa93b57b7e8522735@sentry.io/1280151').install()
</script>
kafka 安装配置
kafka
- Kafka快速入门 https://colobu.com/2014/08/06/kafka-quickstart/
- Go连接Kafka https://blog.csdn.net/dazheng/article/details/52995260
quick demo
# session 1
kafka-console-producer --broker-list localhost:32773 --topic chat
# session 2 sync from 1
kafka-console-consumer --broker-server localhost:32773 --topic chat --form-beginning
deploy
docker run -d --name zookeeper -p 2181:2181 zookeeper
docker run -d --name kafka -p 9092:9092 \
--link zookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=192.168.31.229:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=192.168.31.229 \
--env KAFKA_ADVERTISED_PORT=9092 \
wurstmeister/kafka
old
#第二步: 启动服务
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
#第三步: 新建一个话题Topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
bin/kafka-topics.sh --list --zookeeper localhost:2181
#第四步: 发送消息
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
#第五步: 消费消息
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
#info
bin/kafka-topics.sh --describe --zookeeper localhost:2181
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
postgresql 基础
- 预览 https://github.com/Vonng/pg
- PG好处都有啥 https://github.com/Vonng/pg/blob/master/misc/pg-yoxi.md 后端懒得写怎么办 需要用到Redis的功能 需要做分析 用到地理 存储时序数据 流计算 任意程序的输出,监控系统信息
- PostgreSQL, Greenplum 培训视频下载 https://github.com/digoal/blog
postgres
docker run --restart=unless-stopped --name pg-1 -it -d -v "$PWD":/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=12341234 postgres:10.5
docker exec -it --user=postgres -w /var/lib/postgresql/data pg-1 sh
psql -d at-dev -U postgres -f 1.sql
pgadmin
docker run --restart=unless-stopped --name pgadmin -d -p 54320:80 -e "PGADMIN_DEFAULT_EMAIL=admin" -e " PGADMIN_DEFAULT_PASSWORD=12341234" dpage/pgadmin4
timescale
docker run --restart=unless-stopped --name timescaledb -it -d -v "$PWD":/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=12341234 timescale/timescaledb:0.11.0-pg10
connect
docker exec -it timescaledb psql -U postgres
配置
- PostgreSQL配置优化 https://cloud.tencent.com/developer/article/1030449
max_connections = 200
fsync = off
shared_buffers = 1GB
work_mem = 10MB
effective_cache_size = 2GB
maintenance_work_mem = 512MB
\x 切换一行行显示
创建数据库
postgres=# CREATE DATABASE exampledb OWNER dbuser;
postgres=# GRANT ALL PRIVILEGES ON DATABASE exampledb to dbuser;
postgres=# \c exampledb;
postgres=# ALTER SCHEMA public OWNER to dbuser;
postgres=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO dbuser;
postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO dbuser;
ALTER TABLE kline_a RENAME TO kline_b;
救急操作
查看连接
show max_connections;
SELECT COUNT(*)
from pg_stat_activity;
select min_val, max_val
from pg_settings
where name = 'max_connections';
关闭连接
SELECT pg_terminate_backend(pg_stat_activity.procpid)
FROM pg_stat_get_activity(NULL::integer)
WHERE datid = (SELECT oid from pg_database where datname = 'your_database');
show max_connections;
SELECT *
from pg_stat_activity;
select pg_cancel_backend(93); -- kill select
select pg_terminate_backend(93); -- kill DML
切换db \c gis
备份
https://docs.timescale.com/v0.12/using-timescaledb/backup
-- save
pg_dump -U postgres -s --table kline_1d -N _timescaledb_internal | grep -v _timescaledb_internal > kline_1d.sql
psql -U postgres -c "\COPY (SELECT * FROM kline_1d) TO kline_1d.csv DELIMITER ',' CSV"
-- import
psql -U postgres -c "\COPY kline_1d FROM kline_1d.csv CSV"
explain
explain analyze select * from a;
elasticsearch 全文搜索
install
docker run -d -p 9200:9200 -p 9300:9300 --name es-1 elasticsearch:5.6.16-alpine
# 查询tool
docker run -d -p 5601:5601 --name kibana --link es-1:elasticsearch kibana:5.6.16
# 查询tool sql转es
docker run -d -p 9800:9800 --name es-hd --link es-1:demo containerize/elastichd
doc
http://how2j.cn/k/search-engine/search-engine-index-manage/1694.html
http api
http://<url>:9200/<index>/<type>/<id>
curl http://localhost:9200/db_name/table_name/a
curl http://localhost:9200/db_name/table_name/_search?q=sql
htop
#磁盘
curl http://localhost:9200/_cat/shards?v
curl http://localhost:9200/_cat/allocation?v
help
/_cat/
/_cat/indices?v
kibana操作
# 查询 排序
GET /how2java/_search
{
"query": { "match_all": {} },
"sort": [
{ "price": "desc" }
]
}
# 部分字段
GET /how2java/_search
{
"query":{"match_all":{}},
"_source":["name","price"]
}
# 条件
GET /how2java/_search
{
"query":{"match":{"name":"时尚连衣裙"}}
}
# 聚合 select count(*),place from product group by place limit 0,3
GET /how2java/_search
{
"size": 0,
"aggs": {
"group_by_place": {
"terms": {
"field": "place.keyword",
"size": 3
}
}
}
}
curl操作
# 1 加索引 其实就是database
curl -X PUT http://172.16.30.13:9200/how2java?pretty # 添加
curl http://172.16.30.13:9200/_cat/indices?v # 1 检查索引
curl -X DELETE http://172.16.30.13:9200/how2java?pretty # 1 删除索引
# 2 装插件 分词
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.16/elasticsearch-analysis-ik-5.6.16.zip
## 检查插件
curl -s http://172.16.30.13:9200/_analyze -H 'content-type: application/json' -d '{
"analyzer":"ik_max_word",
"text":"护眼带光源"
}' | jq
# 添加
curl -s -X PUT http://172.16.30.13:9200/how2java/product/1?pretty -H 'content-type: application/json' -d '{
"name": "蜡烛"
}' | jq
# 查询
curl http://172.16.30.13:9200/how2java/product/1?pretty
# 修改 添加覆盖用
## POST /how2java/product/1/_update
# 删除单个
curl -X DELETE http://172.16.30.13:9200/how2java/product/1?pretty
# 批量添加
curl -s -X POST http://172.16.30.13:9200/_bulk -H 'content-type: application/json' -d '
{"index":{"_index":"how2java","_type":"product","_id":10001}}
{"code":"540785126782","price":398,"name":"房屋卫士自流平美缝剂瓷砖地砖专用双组份真瓷胶防水填缝剂镏金色","place":"上海","category":"品质建材"}
{"index":{"_index":"how2java","_type":"product","_id":10002}}
{"code":"24727352473","price":21.799999237060547,"name":"艾瑞泽手工大号小号调温热熔胶枪玻璃胶枪硅胶条热溶胶棒20W-100W","place":"山东青岛","category":"品质建材"}
{"index":{"_index":"how2java","_type":"product","_id":10003}}'
# 批量文件导入 http://how2j.cn/k/search-engine/search-engine-curl-batch/1704.html
## pan.baidu source_java/products_16w条elasticsearch.json.rar
curl -X POST http://172.16.30.13:9200/how2java/product/_bulk?refresh -H 'content-type: application/json' --data-binary "@products.json"
# search
## 部分字段 "_source": ["name","price"]
## 条件 "query": { "match_all": {} },
## 条件 "query": { "match": { "name": "时尚连衣裙" } },
## 分页 "from": 1, "size": 3,
curl -s http://172.16.30.13:9200/how2java/_search -d '{
"query": { "match": { "name": "时尚连衣裙" } },
"sort": [
{ "price": "desc" }
],
"_source": ["name","price"]
}' | jq
# 清空索引
curl -X DELETE http://localhost:9200/_all
curl -X POST http://localhost:9200/_delete_by_query -d '{
"query": {
"match_all": {}
}
}'
redis
redis
- 命令参考 http://doc.redisfans.com
- 持久化persistence http://doc.redisfans.com/topic/persistence.html
- x stream https://zhuanlan.zhihu.com/p/37591626
stream
redis-cli -h 10.231.9.159 -p 32621
xrange x:topic:test - + count 10
xadd x:topic:test * name youming age 60
# 控制长度
xadd x:topic:test maxlen ~ 100 * name youming age 60
xtrim x:topic:test maxlen ~ 100
xlen x:topic:test
java stream
public static void main(String[] args) {
Jedis r = new Jedis("x.x.x.x", 6379);
r.select(11);
XReadGroupParams p = XReadGroupParams.xReadGroupParams().count(20).noAck();
Map<String, StreamEntryID> entry = Collections.singletonMap("jdddddd", StreamEntryID.UNRECEIVED_ENTRY);
List<Map.Entry<String, List<StreamEntry>>> entries = r.xreadGroup("gggn", "cccn", p, entry);
if (entries != null) {
for (Map.Entry<String, List<StreamEntry>> stringListEntry : entries) {
for (StreamEntry sEntry : stringListEntry.getValue()) {
Map<String, String> fields = sEntry.getFields();
System.out.println(fields);
}
}
}
}
clash 设置
clash
# install win mac
https://github.com/Fndroid/clash_for_windows_pkg/releases
https://github.com/Fndroid/clash_for_windows_pkg/releases/download/0.19.12/Clash.for.Windows.Setup.0.19.12.exe
D:\clash
# setting
https://docs.cfw.lbyczf.com/contents/quickstart.html
https://portal.shadowsocks.nz/knowledgebase/182/
# shell
host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
export ALL_PROXY="http://$host_ip:7890"
export ALL_PROXY="http://127.0.0.1:7890"
trojan
https://github.com/trojan-gfw/trojan/releases tar -xvf trojan-1.16.0-linux-amd64.tar.xz
"cert": "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem",
docker
- api https://clash.wiki/runtime/external-controller.html
- dashboard http://localhost:17890/ui/#/proxies
cd /etc/clash
version: "3"
services:
svc-clash:
image: dreamacro/clash
restart: always
ports:
- "7890:7890"
- "17890:9090"
volumes:
- .:/root/.config/clash
environment:
- TZ=utc-8
mixed-port: 7890
allow-lan: true
external-controller: 0.0.0.0:9090
external-ui: /root/.config/clash/ui
#secret: bb975c61-c6b6-4ffe-9a22-0f5d00d7342e
# 后半段 copy windows profiles 里的内容
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export ALL_PROXY=http://127.0.0.1:7890
# 测试代理可用
curl -i google.com
# 在终端取消代理
unset http_proxy
unset https_proxy
atom
atom-material-syntax
material-ui
atom必备插件及主题 https://www.jianshu.com/p/eac1879cb2e9
beautify
config.cson
"*":
"atom-beautify":
bash: {}
php: {}
nginx:
indent_size: 4
brace_style: "expand"
keymap.cson
'.platform-darwin':
'cmd-e': 'fuzzy-finder:toggle-file-finder'
'cmd-t': 'tree-view:reveal-active-file'
'cmd-b': 'script:run'
vscode 设置
hey压测工具 ab的go实现
go install -v github.com/rakyll/hey
./hey -c 50 -n 1000 http://api.bitdata.inner/market/coin
./hey -c 200 -n 20000 -m POST -d '{
"bids": [
["6331.25", "1.1"],
["6331.1", "0.339"],
["633.97", "0.255"],
["633.55", "0.255"],
["633.75", "0.7371"]
],
"asks": [
["6343.87", "0.255"],
["6343.88", "0.6"],
["6343.95", "0.5"],
["6344.31", "0.511"],
["6344.39", "0.3457"]
]
}' http://192.168.199.201:1777/depth?len=5&coinbase_id=1000&coinquote_id=2392&exchange_id=4
hey -c 10 -H "cookie: pii_session=74baa3e0-c50e-49a6-8332-e60975bfb57e;" https://dev2.gimc.grundfos.cn/api/application/124
Summary:
Total: 21.2181 secs
Slowest: 6.3987 secs
Fastest: 0.1012 secs
Average: 0.9542 secs
Requests/sec: 47.1295
Response time histogram:
0.101 [1] |
0.731 [445] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
1.361 [366] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
1.990 [111] |∎∎∎∎∎∎∎∎∎∎
2.620 [50] |∎∎∎∎
3.250 [12] |∎
3.880 [7] |∎
4.509 [7] |∎
5.139 [0] |
5.769 [0] |
6.399 [1] |
Latency distribution:
10% in 0.3092 secs
25% in 0.4710 secs
50% in 0.7908 secs
75% in 1.2031 secs
90% in 1.7972 secs
95% in 2.2439 secs
99% in 3.7303 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0007 secs, 0.1012 secs, 6.3987 secs
DNS-lookup: 0.0004 secs, 0.0000 secs, 0.0086 secs
req write: 0.0000 secs, 0.0000 secs, 0.0005 secs
resp wait: 0.9529 secs, 0.1009 secs, 6.3980 secs
resp read: 0.0004 secs, 0.0001 secs, 0.0063 secs
Status code distribution:
[200] 1000 responses