Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ruanjiayou/notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanjiayou committed May 26, 2023
2 parents 8c28fe3 + 26533fb commit 9a85543
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .md/ELK系列.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ echo '已停止'

## IK分词器
1. 找对应版本zip下载到本地: https://github.com/medcl/elasticsearch-analysis-ik/releases
2. 到es目录安装: `./bin/elasticsearch-plugin install file://path-to-zip`.
2. 到es目录安装: `./bin/elasticsearch-plugin install file:/home/files/xxx.zip`.
> 是 zip 文件,而且不能在 plugins 文件夾裡.Mac 里把 .DS_Store 文件要删掉.
3. 测试:
> 原生: `curl -XGET "http://localhost:9200/_analyze" -H 'Content-Type: application/json;' -d '{"analyzer": "default","text": "今天天气真好"}'` \
Expand Down
12 changes: 11 additions & 1 deletion elasticsearch/es.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
- 挂载`elasticseawrch.yml`(关闭ssl,去掉证书文件)
- 环境变量: `discovery.type=single-node`
- 设置密码: `./bin/elasticsearch-setup-passwords interactive`(kibana_system的密码不能纯数字)

```
elastic 123456
apm_system apm123456
kibana/kibana_system k123456
logstash_system ls123456
beats_system b123456
remote_monitoring_user rm123456
```
- 安装plugins
- ./bin/elasticsearch-plugin install file:/home/files/xxxx.zip
- 查看安装的插件列表: http://192.168.0.124:9200/_cat/plugins
## setting

## mapping
Expand Down
2 changes: 1 addition & 1 deletion git/git命令.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
git init // 初始化版本库
git add . // 添加文件到缓存区
git commit -m "init" // 提交
//取消没push的commit git reset --soft HEAD^
//取消没push的commit git reset --soft HEAD~1

git remote add origin 仓库地址 // 把本地与远程库关联 http://host/user/repo-name
git pull/push -u origin master // 第一次拉取/推送
Expand Down
1 change: 1 addition & 0 deletions message-queue/rabbitmp.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
## 注意事项
- exchange需要手动添加,queue可以自动创建
- 消息投递到不存在的exchange,会报错,需要捕获(channel.on("error")),channel会被销毁
- mq心跳包超时会抛出异常,需要捕获: mq.on('error').error后会自动调用close
- topic类型匹配的. 默认将.作为分割符 #和*的匹配不包括.
- message都不建议直接调用sendToQueue,要通过exchange
## 参考
Expand Down
13 changes: 13 additions & 0 deletions mongo/mongoose语法.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ or:有多少个条件就会查询多少次,最后合并结果集,所以尽
- db.killOp
-

## 文件恢复
- `tar (child): cannot run bzip2: No such file or directory`
> apt-get install bzip2
- `E: Package 'mongodb' has no installation candidate`
- 卸载mongo: apt-get purge mongo*
- mongod -f /etc/mongod.conf &(启动后才能连接..)
- wget http://source.wiredtiger.com/releases/wiredtiger-3.0.0.tar.bz2
- apt-get install bzip2
- tar -xvf wiredtiger-3.0.0.tar.bz2 && cd wiredtiger-3.0.0
- ./configure --enable-snappy
- make
-

## 问题
- MongoError: no primary found in replicaset or invalid replica set name 连不上数据库集群 ===> 停电挂了...
- db.getCollection('crawler_url').updateMany({finished:true},{$set:{finished:false}})
Expand Down
9 changes: 7 additions & 2 deletions nas/nas.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
## 绿联nas

### ssh登录
- 启动远程调试后要重启设备
> `ssh root@ip -p 922`, 密码是固定的 L#W$%W1uGa 加上远程协助功能的验证码
- ssh里重启docker: service dockerd restart
花生壳

## nas登录步骤
- curl "https://down.oray.com/hsk/linux/phddns_5.2.0_amd64.deb" -o phddns_5.2.0_amd64.deb
- dpkg -i phddns_5.2.0_amd64.deb
- b.oray.com 使用SN登录跳转后立即用账号再登陆一次绑定设备
- b.oray.com 使用SN登录跳转后立即用账号再登陆一次绑定设备

## docker拉取失败
> 进到ssh可以拉取..
- 换镜像源: https://registry.cn-hangzhou.aliyuncs.com
6 changes: 5 additions & 1 deletion ngrok/ngrok.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@

## 其他
- godaddy的域名不能解析到ngrok的域名上。需要付费。302跳转都不行
-

## supervisor
- 删除进程或重启ubantu
- 指定配置启动服务: supervisord -c /etc/supervisor/supervisod.conf
- https://xie.infoq.cn/article/4404b2658d06d55871604f4dc
10 changes: 10 additions & 0 deletions registry/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
- REGISTRY_HTTP_TLS_KEY=/certs/server.key
- REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.crt

## registry-ui(jc21/registry-ui)
```SH
REGISTRY_DOMAIN=192.168.0.124:5000 # UI界面拼接地址用的
REGISTRY_PASS=123456
REGISTRY_USER=registry
REGISTRY_HOST=192.168.0.124:5000 # 请求api用的
# 开启了https的话
REGISTRY_STORAGE_DELETE_ENABLED=true
REGISTRY_SSL=true
```
## docker插件使用
- window docker desktop 设置开放调试端口2375
-
Expand Down
176 changes: 176 additions & 0 deletions scripts/mongo/house.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
const mongoose = require('mongoose');
const cheerio = require('cheerio');
const got = require('got').default;

mongoose.connect('mongodb://root:123456@localhost:27016/test?authSource=admin&readPreference=primaryPreferred')
const projectModel = mongoose.model('house', new mongoose.Schema({
_id: String,
name: String,
address: String,
region: String,
total: Number,
available: Number,

crawled: Boolean,
status: String, // 在建,
format: String, // 新建 翻新?
product: String, // 开发商
plan_start_date: Date,// 计划开工时间
plan_finish_date: Date,// 计划竣工时间
type: String, // 商品房
area_land: Number,
area_building: Number,
plot_ratio: Number,
green_ratio: Number,
}, { strict: false, collection: 'house' }));
const certificationModel = mongoose.model('certification', new mongoose.Schema({
project_id: String,
_id: String, //预售许可证号
buildings: String,
issue_date: String,
}, { strict: false, collection: 'certification' }));
const pages = 19;

function getList(html) {
const results = [];
const $ = cheerio.load(html, { decodeEntities: true });
const tables = $('div>table');
const main_table = tables.eq(6)
const contain_table = $(main_table).find('table').eq(1);
// $(main_table).remove($(main_table).find('marquee'))
// console.log(contain_table.html());
const trs = $(contain_table).find('table tr');
trs.each((i, e) => {
// console.log($(e).html(), '??')
if (i > 1) {
const tds = $(e).find('td');
const href = $(tds[0]).find('a').attr('href');
const _id = new URL('http://218.200.147.160:83/' + href).searchParams.get('DevProjectId');
results.push({
name: $(tds[0]).text().trim(),
_id,
address: $(tds[1]).text().trim(),
region: $(tds[2]).text().trim(),
total: parseInt($(tds[3]).text().trim()),
available: parseInt($(tds[4]).text().trim()),
})
}
});
return results;
}
async function getDetail(_id) {
const resp = await got.get(`http://218.200.147.160:83/Pub_lpxx.aspx?DevProjectId=${_id}`);
if (resp.statusCode === 200) {
const $ = cheerio.load(resp.body, { decodeEntities: true });
const main_table = $('table').eq(4);
const content_table = $(main_table).find('table').eq(1);
const keys_table = $(main_table).find('table').eq(2);
const certifications = [];
$(keys_table).find('tr').each((i, e) => {
const tds = $(e).find('td');
if (i > 0) {
certifications.push({
_id: $(tds[0]).text().trim(),
buildings: $(tds[1]).text().trim(),
issue_date: $(tds[2]).text().trim(),
})
}
})
const data = { crawled: true };
$(content_table).find('tr').each((i, e) => {
const tds = $(e).find('td');
if (i === 0) {

} else if (i == 1) {
data.format = $(tds).eq(1).text().trim();
data.product = $(tds).eq(3).text().trim();
} else if (i == 2) {
data.status = $(tds).eq(1).text().trim();
data.type = $(tds).eq(3).text().trim();
} else if (i == 3) {

} else if (i == 4) {
data.plan_start_date = $(tds).eq(1).text().trim();
data.area_land = parseFloat($(tds).eq(3).text().replace('m²', '').trim());
} else if (i == 5) {
data.plan_finish_date = $(tds).eq(1).text().trim();
data.area_building = parseFloat($(tds).eq(3).text().replace('m²', '').trim());
} else if (i == 6) {
data.plot_ratio = parseFloat($(tds).eq(1).text().trim());
data.green_ratio = parseFloat($(tds).eq(3).text().replace('%', '').trim());
}
});
// data, certifications
if (certifications.length) {
await certificationModel.bulkWrite(certifications.map(item => ({
updateOne: {
filter: { _id: item._id, project_id: _id },
update: { $set: item },
upsert: true
}
})))
}
await projectModel.updateOne({ _id }, { $set: data });
} else {
console.error(`failed: ${_id}`)
}
}
; (async () => {
// for (let page = pages; page <= pages; page++) {
// const resp = await got.get('http://218.200.147.160:83/More_xm.aspx?page=' + page, { encoding: 'utf-8' });
// const items = getList(resp.body);
// console.log('page: ' + page + ' items: ' + items.length);
// if (items.length) {
// await projectModel.bulkWrite(items.map(item => ({
// updateOne: {
// filter: { _id: item._id },
// update: {
// $set: item
// },
// upsert: true
// }
// })))
// }
// }

const cursor = projectModel.find({ }).cursor();
let doc = null, i = 0;
do {
i++;
doc = await cursor.next();
if (doc) {
doc = doc.toObject();
// console.log(doc);
// process.exit(0);
console.log(i)
// await getDetail(doc._id);
await projectModel.updateOne({ _id: doc._id }, {
$set: {
plan_finish_date: new Date(doc.plan_finish_date),
plan_start_date: new Date(doc.plan_start_date),
plot_ratio: parseFloat(doc.plot_ratio),
area_building: parseFloat(doc.area_building),
area_land: parseFloat(doc.area_land),
green_ratio: parseFloat(doc.green_ratio),
}
})
}

} while (doc);
console.log('ended');
process.exit(0);
})();

/**
* 开发形式
* 自行开发: 1,续建: 17, 新建: 511
* 状态
* 竣工: 1, 在建: 528
* 区域
* 高新区: 51, 温泉: 101, 咸安: 377
* 类型
* 其他: 2, 经济适用房: 1, 拆迁安置房: 5, 商品房: 521
* 楼盘: 529, 预售许可证: 1439, 开发商: 197家
* 总套数: 250782, 可售套数: 51662
* 总人口: 303.61万 总建筑面积: 38858808.66㎡ 占地面积: 20181636.16
*/

0 comments on commit 9a85543

Please sign in to comment.