Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
max committed Sep 24, 2021
1 parent b61eee5 commit 39ff4c6
Show file tree
Hide file tree
Showing 32 changed files with 3,913 additions and 148 deletions.
39 changes: 20 additions & 19 deletions .md/ELK系列.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@
4. 查看结果: java -version

## elasticsearch安装
1. 进入安装目录
2. 下载tar.gz包解压
1. 下载tar.gz包解压
2. 进入安装目录
3. 写启动脚本:
```bash
#!/bin/bash
./bin/elasticsearch -d
echo '已启动ElasticSearch进程'
```
```bash
#!/bin/bash
./bin/elasticsearch -d
echo '已启动ElasticSearch进程'
```
给启动脚本加执行权限
```bash
chmod +x es-start.sh
```
4. 写停止脚本: `vim es-stop.sh`
```bash
#!/bin/bash
es_ps=`jps|grep Elasticsearch`
OLD_IFS="$IFS"
IFS=" "
arr=($es_ps)
IFS="$OLD_IFS"
echo '正在停止ElasticSearch进程:' ${arr[0]}...
kill -9 ${arr[0]}
echo '已停止'
```
```bash
#!/bin/bash
es_ps=`jps|grep Elasticsearch`
OLD_IFS="$IFS"
IFS=" "
arr=($es_ps)
IFS="$OLD_IFS"
echo '正在停止ElasticSearch进程:' ${arr[0]}...
kill -9 ${arr[0]}
echo '已停止'
```
给脚本启动权限和es用户权限
5. 写重启脚本: `vim es-restart.sh`
```bash
Expand Down Expand Up @@ -157,7 +157,8 @@

## 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://path-to-zip`.
> 是 zip 文件,而且不能在 plugins 文件夾裡.Mac 里把 .DS_Store 文件要删掉.
3. 测试:
> 原生: `curl -XGET "http://localhost:9200/_analyze" -H 'Content-Type: application/json;' -d '{"analyzer": "default","text": "今天天气真好"}'` \
> IK: `curl -XGET "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{"analyzer": "ik_smart","text": "今天天气真好"}'`
Expand Down
25 changes: 13 additions & 12 deletions .md/vim命令.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,36 @@

- vim /usr/share/vim/.vimrc
- vim ~/.vimrc
```sh
# 设置编码
```conf
" 设置编码 "
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
# 显示行号
" 显示行号 "
set nu
# 主题配色
" 主题配色 "
colorscheme moloki/jellybeans/Tomorrow-Night-Eighties/
# 突出当前行
syntax on
" 突出当前行 "
set cul
# 突出当前列
" 突出当前列 "
set cuc
# 启用鼠标
" 启用鼠标 "
set mouse=a
set selection=exclusive
set selectmode=mouse,key
# 显示括号匹配
" 显示括号匹配 "
set showmatch
# 设置缩进
" 设置缩进 "
set tabstop=2
set shiftwidth=2
set autoindent
# 设置粘贴
" 设置粘贴 "
set paste
# 显示状态栏和光标当前位置
" 显示状态栏和光标当前位置 "
set laststatus=2
set ruler
# vim配置变更立即生效
# vim配置变更立即生效
autocmd BufWritePost $MYVIMRC source $MYVIMRC
```

Expand Down
Binary file added CDN/8n2vvkfwum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions CDN/CDN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CDN

## 百度云设置
- 添加加速域名和源域名,添加 cname 到加速域名
- https 跳转设置
116 changes: 116 additions & 0 deletions elasticsearch/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })

const mapping = {
settings: {
number_of_shards: 1,
number_of_replicas: 0,
},
mappings: {
fengshows: {
properties: {
title: {
type: 'text',
analyzer: 'ik_max_word',
search_analyzer: 'ik_max_word',
},
available: {
type: 'integer',
},
created_time: {
type: 'date',
},
modified_time: {
type: 'date',
},
resource_type: {
type: 'keyword',
},
resource_id: {
type: 'keyword',
},
display_type: {
type: 'integer',
},
cover: {
type: 'text',
},
source: {
type: 'text',
},
},
},
},
}
// client.on('request', (err, meta) => {
// console.log(err || meta)
// });

// 创建索引
// client.indices.create({ index: 'global_es', include_type_name: true, body: mapping })
// 查看插件
// client.cat.plugins().then(result => {
// console.log(result.body);
// })

// 查看索引
// client.cat.indices({ index: 'test-index' }).then(result => {
// console.log(result.meta.request.params)
// console.log(result.body)
// })

// 同步一条数据
// client.index({
// index: 'test-index', body: {
// "__last_actived_time": new Date("2021-03-31T10:49:05.401Z"),
// "__v": 0,
// "allow_comment": 1,
// "authorized_countries": [],
// "available": 1,
// "brief": "根據“十四五”規劃綱要,“便利港澳青年到大灣區內地城市就學就業創業,打造粵港澳青少年交流精品品牌”被重點提及。基於此,廣東省積極推出各項政策支持港澳青年到內地創新創業。粵港澳大灣區創新創業孵化基地29日正式營業。目前,40家入駐團隊中包括6個港澳團隊、9個港澳初創企業。 ",
// "category_id": "video_finance",
// "comment_enabled": 1,
// "config_score": 0,
// "cover": "http://c1.fengshows-cdn.com/a/2021_14/a96e6cd832b8432.png",
// "cover_list": [],
// "created_time": new Date("2021-03-30T12:57:39.000Z"),
// "duanmu_enabled": 0,
// "duration": 219,
// "episode": "2021-03-30",
// "flags": [],
// "labels": [
// "粵港澳大灣區"
// ],
// "marks": [],
// "material_id": "81aec930-9157-11eb-8107-195bb48668d9",
// "modified_time": new Date("2021-03-30T11:55:00.000Z"),
// "program_icon": "https://fengshows.oss-cn-hongkong.aliyuncs.com/app/u/2020/04/24/16ebf340-8602-11ea-88c0-8532c0f49738.png",
// "program_id": "2752e260-990d-11eb-9bd0-d327100b92a5",
// "program_name": "新聞朋友圈",
// "resource_type": "video",
// "scheduled_day": 30,
// "scheduled_month": 3,
// "scheduled_time": new Date("2016-08-02T09:48:48.525Z"),
// "scheduled_year": 2021,
// "send_subscription": 0,
// "subscription_id": "298aa4b0-8602-11ea-8037-153953a345c8",
// "title": "灣區創業基地開園 港澳項目或超70%",
// "type": 1
// }
// }).then(result => {
// console.log(result)
// })

// 搜索
// client.search({
// index: 'test-index', body: {
// query: {
// match: { title: '基地' }
// }
// }
// }).then(result => {
// console.log(result.meta.request.params)
// console.log(result.body.hits.hits)
// })

// 根据 id 查询记录.http://localhost:9200/test-index/fengshows/UmYnn3oBEVGA63Euqvt0?pretty
2 changes: 2 additions & 0 deletions git/git命令.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ git pull
git push
```

### 删除本地 commit 但未 push的
- `git reset --hard HEAD~1`
### 删除历史commit(密码等敏感记录)
- 删除最近一个commit: `git reset --hard HEAD~1` => `git push --force`
- 切换新分支: git checkout --orphan temp (空的)
Expand Down
2 changes: 2 additions & 0 deletions gogs/gogs-data/backups/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
14 changes: 13 additions & 1 deletion gogs/gogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,16 @@
- 访问 ip:port
- 设置
- 管理员 user pass email
- 设置hosts ip:port git.site.com
- 设置hosts ip:port git.site.com

## docker启动
- docker-compose up -d
- 设置.数据库有 pg 的...
- 注册第一个账号
-
## 备份
- 查看版本: `/app/gogs/gogs -v`
- 进入容器: `docker exec -ti gogs-git bash`
- 切换用户: `su - git`
- 备份: `/app/gogs/gogs backup --config /data/gogs/conf/app.ini --target /app/gogs/backups`
- 恢复: `/app/gogs/gogs restore --config /data/gogs/conf/app.ini --from /data/backups/gogs-backup.zip /tempdir=/data`.FATAL了还是恢复成功
16 changes: 15 additions & 1 deletion linux/linux系统相关.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,18 @@ curl
- centos查看版本: `lsb_release -a`, `rpm -q centos-release`, `cat /etc/issue`
- 查看Linux版本: `cat /proc/version`
- 查看Linux64位还是32位: `getconf LONG_BIT`
- 安装tree: `yum -y install tree`
- 安装tree: `yum -y install tree`

## ssh登陆
```sh
ssh -p 22 root@baidu
```
> .ssh/config
```
Host 别名
HostName ip或域名
Port 22
User root
IdentityFile ~/.ssh/id_rsa.pub
IdentitiesOnly yes
```
2 changes: 2 additions & 0 deletions mongo/backup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
10 changes: 8 additions & 2 deletions mongo/mongoDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@
- 备份单个表:`mongoexport -u root -p 123456 -h 127.0.0.1 -d test --authenticationDatabase admin --collection test -o /data/backup/test/test.json`
- 还原整个库:`mongorestore -u root -p 123456 -h 127.0.0.1 --authenticationDatabase admin -d test /data/backup/test`
- 还原单个表:`mongoimport -u root -p 123456 -h 127.0.0.1 --authenticationDatabase admin -d test --collection test --file /data/backup/test/test.json`

mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection tv -o /data/backup/media/tv.json
mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection cartoon -o /data/backup/media/cartoon.json
mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection children -o /data/backup/media/children.json
mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection movie -o /data/backup/media/movie.json
mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection variety -o /data/backup/media/variety.json
mongoexport -u root -p 123456 -h 127.0.0.1 -d media2 --authenticationDatabase admin --collection documentary -o /data/backup/media/documentary.json
## 复制数据库
-

## 用户管理
- 创建用户
```js
mongo
use admin
use admin // (如果是在当前数据库,这链接无需 authSource 选项)
db.createUser({user:"root",pwd:"123456",roles:[{role:"readWrite",db:"test"}]})
db.auth("root","123456")
```
- 创建管理员, `roles: [ { role: "userAdminAnyDatabase", db: "admin"} ]` 对所有数据库进行管理
- 删除用户, `db.dropUser("test")`
- 角色类型
```
数据库用户角色
Expand Down
11 changes: 11 additions & 0 deletions mongo/mongoose语法.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ https://docs.mongodb.com/manual/reference/operator/aggregation/sum/
- replaceOne(condition,data,option) 覆盖一条数据
- updateMany 相当update中multi为true,也必须是原子操作$


## 创建索引
```js
db.getCollection('point_info').createIndexes([
{
"subscription._id ": 1,
"created_time ": 1,
"type": 1
}
], {background:true, name: "subscriptionId_createTime_type"})
```
## 批量修改
- bulkWrite中修改: updateOne{ {filter}, {$set: data}, {option}}
- skip比cursor方便.
Expand Down
1 change: 1 addition & 0 deletions mysql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
image: mysql
restart: always
env_file: .env
command: --default-authentication-plugin=mysql_native_password
networks:
- allinone
ports:
Expand Down
4 changes: 3 additions & 1 deletion mysql/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ STARTS 2018-08-20 14:44:54
> window里可以到C:\Users\username\Documents\Kitematic\mysql-demo\var\lib\mysql 删除文件
> ip是192.168.99.100
- docker mysql mysqld: Error on realpath() on '/var/lib/mysql-files' No such file or directory
> 在启动容器时 需要加上 -v /home/mysql/mysql-files:/var/lib/mysql-files/
> 在启动容器时 需要加上 -v /home/mysql/mysql-files:/var/lib/mysql-files/
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
>
22 changes: 22 additions & 0 deletions nginx/certs/example.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDnDCCAoQCCQCfOIsiBGJdDTANBgkqhkiG9w0BAQsFADCBjjELMAkGA1UEBhMC
Q04xEjAQBgNVBAgMCWd1YW5nZG9uZzERMA8GA1UEBwwIc2hlbnpoZW4xEjAQBgNV
BAoMCXBob2VuaXh0djENMAsGA1UECwwEbm9uZTENMAsGA1UEAwwEbm9uZTEmMCQG
CSqGSIb3DQEJARYXcnVhbmppYXlvdTEyM0BnbWFpbC5jb20wIBcNMjEwNzI5MDcx
ODA3WhgPMjEyMTA3MDUwNzE4MDdaMIGOMQswCQYDVQQGEwJDTjESMBAGA1UECAwJ
Z3Vhbmdkb25nMREwDwYDVQQHDAhzaGVuemhlbjESMBAGA1UECgwJcGhvZW5peHR2
MQ0wCwYDVQQLDARub25lMQ0wCwYDVQQDDARub25lMSYwJAYJKoZIhvcNAQkBFhdy
dWFuamlheW91MTIzQGdtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAMryPV5GJ/qM6rcSWOEYaS2aaD5QHl9E8UFF/klX/BrikVUfp1cOG6CJ
+GrmCuzTHjW+uZGRiZt0ojZmTUoAFJ44zsaguj3XJo6r29eISdtp28Mrx3K15JEd
3HYUGV1tZ7AJCROGgW4fR0eCmEJ+vmwmVudawMnvFTmJWsgVly2bUmDM4o4osVW9
1LbTDRxILmfRro/3JKMXDxpc3nI2pk1nFqkgUKq7JhM4Rb3XE8j5zVF+FwnsYenz
HY41vBmp/r4yhXr7rCz0ASQisrdB3g2WP8GTyTO4pxaDdrjWdMsJV8JE3e2Cy4b+
VreTCBVw7HjgX4O2p+pEVFOsW8tyfCkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
nUlryNqefOzJvIWr56T7IFxOadOtw51++zFy4PDwJT5UwpWGuDmvoEqo30SwShd8
wSk+HKqvk25XjIg5Z8QyaMkDMHnUSeSzLLLE9ey+xV+Cv6dUv8awk3i7TQanja+t
dH9VKPyiifRQs+ab6wnBive7pGi6ePrk2y+G6NQUTS5nersM5hQLJ3TeMUmln+Bd
gf8j1noFMH19AZKNz5UQ4rqUO2nch+kkuzfsb/mwCdsykQAa+MtHG7sWjVonwIdW
pNWODFVuDp7WjGgaMuooCIZMXuReOl1900kkbUDsybpoG9oyVx9oIkmnUzNfGTzB
5r7Jj0MNVofqzKGiaFP2Jw==
-----END CERTIFICATE-----
Loading

0 comments on commit 39ff4c6

Please sign in to comment.