1 | // 用于staff的排序 |
ssh-usage
发表于
更新于
本文字数: 1.1k 阅读时长 ≈ 1 分钟
本文字数: 1.1k 阅读时长 ≈ 1 分钟
连接
-i指定密钥
-o加option
1
2-o TCPKeepAlive=yes //长连接
-o ServerAliveInterval=30 //
端口转发
1 | ssh -L local_port:localhost:remote_port -N -T user@server_address -p server_ssh_port |
配置
config文件配置: ~/.ssh/config
1
2
3
4
5
6
7
8#配置
Host gitee.com
HostName gitee.com
IdentityFile xxx/xxx/_id_rsa
PreferredAuthentications publickey
User xxx
TCPKeepAlive=yes
ServerAliveInterval 60配置服务端
- 件位置,全局位置: /etc/ssh/sshd_config
- 文件位置,termux: $PREFIX/etc/ssh/sshd_config
- 配置:
- PasswordAuthentication (密码验证) yes/no
- 启用密钥验证
- RSAAuthentication (rsa秘钥) yes/no
- PubkeyAuthentication (公钥) yes/no
- 认证秘钥,将公钥写入该文件(authorized_keys),就可使用该公钥登陆
- 位置: ~/.authorized_keys
工具
windows terminal
1
2
3
4
5
6
7
8
9
10连接远程机器使用 ssh 配置
{
"guid": "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}",
"hidden": false,
"name": "xxxxxxx",
//密钥放在本地,-i 指定密钥位置
"commandline": "ssh -i xxxxxxx_id_rsa user@host -p xxxxxxxx -o TCPKeepAlive=yes -o ServerAliveInterval=30",
"startingDirectory": "/home/xxxxxxx",
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png"
}
How to Deal With Error in Golang
微服务总结帖
golang excelize read date type data
- excelize 介绍
1 |
- 时间格式读取
excel表格操作库,对日期格式的数据读写还不是很完善,能识别的日期格式返回一个01-02-06(day-month-day)格式的字符串,无法识别时直接返回的是excel表格中的原始数据,一个浮点型数,在excel中支持很多种日期格式显示。
1 | file,err:=excelize.OpenFile(filepath) |
- 时间格式写入
通过excelize写入时间格式的数据到文件,需要设置单元格格式,excelize支持写入的格式包含有time.Time,但是写入时需要使用UTC格式。
1 | file:=excelize.NewFile() |
github-action-hexo-next
发表于
更新于
本文字数: 248 阅读时长 ≈ 1 分钟
本文字数: 248 阅读时长 ≈ 1 分钟
bug
系统依赖
- Jenkins
- nginx
- golang后端
- 前端
问题
- 接口调用失败,到服务器上本地请求接口失败
- 通过ps搜索后端进程,发现服务进程不存在,判定=>Jenkins构建失败
- 然后到Jenkins上查看构建日志,发现报错信息,’sudo stop xxxx [no runing]’,错误判定为有人修改了服务器配置,问了一圈人,没有修改
- 排除员工原因,查找代码原因,尝试直接执行在服务器本地的后端可执行程序,报错
- 排查代码原因
反思
大部分错误最先从代码层面开始找,比较有效率,服务器配置之类的改动毕竟比较少;错误日志需要仔细查看,往往兜兜转转找了一圈会发现
错误提示一开始就清晰地摆在面前.
下决定前多思考.
learn unix
发表于
更新于
本文字数: 67 阅读时长 ≈ 1 分钟
本文字数: 67 阅读时长 ≈ 1 分钟
lsb_release
发表于
更新于
本文字数: 592 阅读时长 ≈ 1 分钟
本文字数: 592 阅读时长 ≈ 1 分钟
description & usage
- LSB (Linux Standard Base)
- tldr description
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15lsb_release
Provides certain LSB (Linux Standard Base) and distribution-specific information.
- Print all available information:
lsb_release -a
- Print a description (usually the full name) of the operating system:
lsb_release -d
- Print only the operating system name (ID), suppressing the field name:
lsb_release -i -s
- Print the release number and codename of the distribution, suppressing the field names:
lsb_release -rcsexample
1
2
3
4
5LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 8.2.2004 (Core)
Release: 8.2.2004
Codename: Core
mysql-slow-query
发表于
更新于
本文字数: 2.3k 阅读时长 ≈ 2 分钟
本文字数: 2.3k 阅读时长 ≈ 2 分钟
Waht
slow_log table
table
column type null default description start_time timestamp(6) NO CURRENT_TIMESTAMP(6) Time the query began. user_host mediumtext NO NULL User and host combination. query_time time(6) NO NULL Total time the query took to execute. lock_time time(6) NO NULL Total time the query was locked. rows_sent int(11) NO NULL Number of rows sent. rows_examined int(11) NO NULL Number of rows examined. db varchar(512) NO NULL Default database. last_insert_id int(11) NO NULL last_insert_id. insert_id int(11) NO NULL Insert id. server_id int(10) unsigned NO NULL The server’s id. sql_text mediumtext NO NULL Full query. thread_id bigint(21) unsigned NO NULL Thread id. rows_affected int(11) NO NULL Number of rows affected by an UPDATE or DELETE (from MariaDB 10.1.2) reference
- slow_log https://mariadb.com/kb/en/mysqlslow_log-table/
HOW
Setting
- 查看相关参数
1
2show variables like 'long%';
show variables like 'slow%';- long_query_time,SQL语句执行时间超过此数值,记录日志
- slow_query_log,是否开启慢查询(ON/OFF)
- slow_query_log_file,慢查询日志文件
- slow_launch_time
- log_output,慢查询日志输出方式,可选FILE(文件,通过slow_query_log_file查询),TABLE(数据表是mysql.slow_log表)
- 设置参数开启慢查询日志,需要设置如下参数:
1
set long_query_time=0.5;
- 通过sql查询
1
select * from mysql.slow_log;
- 通过文件查询
查询slow_query_log_file参数得到慢查询日志文件所在位置,查看文件.
Solution 性能优化
索引
在无索引的表中查询会进行全表扫描,如果表的数据量很大,则扫描大量的数据,执行效率过
慢,占用数据库连接,连接数堆积很快达到数据库的最大连接数设置,新的应用请求将会被拒绝导致故障发生。
隐式转换也会导致索引无法使用.
创建索引
- 在经常查询而不经常增删改操作的字段加索引。
- order by与group by后应直接使用字段,而且字段应该是索引字段。
- 一个表上的索引不应该超过6个。
- 索引字段的长度固定,且长度较短。
- 索引字段重复不能过多。
- 在过滤性高的字段上加索引。
使用索引注意事项
- 使用like关键字时,前置%会导致索引失效。
- 使用null值会被自动从索引中排除,索引一般不会建立在有空值的列上。
- 使用or关键字时,or左右字段如果存在一个没有索引,有索引字段也会失效。
- 使用!=操作符时,将放弃使用索引。因为范围不确定,使用索引效率不高,会被引擎自动改为全表扫描。
- 不要在索引字段进行运算。
- 在使用复合索引时,最左前缀原则,查询时必须使用索引的第一个字段,否则索引失效;并且应尽量让字段顺序与索引顺序一致。
- 避免隐式转换,定义的数据类型与传入的数据类型保持一致。
验证
使用mysql的explain分析sql,查看执行计划.
- 执行计划参数含义
- 例如一个sql执行计划如下:增加索引后:
1
2
3
4
5
6
7
8
9
10
11// type为ALL,是全表扫描,每次执行需要扫描505560行数据
id: 1
select_type: SIMPLE
table: customers
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 505560
Extra: Using where1
2
3
4
5
6
7
8
9
10
11// 执行计划看到type为ref,基于索引的等值查询,或者表间等值连接
id: 1
select_type: SIMPLE
table: customers
type: ref
possible_keys: idx_cus
key: idx_cus
key_len: 31
ref: const
rows: 4555
Extra: Using index condition参考
- 阿里云: https://help.aliyun.com/document_detail/52274.html?spm=a2c4g.11186623.2.8.1b1945135Wahhf