kanjin 发布的文章

centos7下解决journal日志越来越大的问题

  • 查看journal占用磁盘空间大小
    journalctl --disk-usage
  • 指定journal占用磁盘空间大小
    journalctl --vacuum-size=1G
  • 指定journal日志保存时间
    journalctl --vacuum-time=1years
  • 实时查看最新日志
    journalctl -f
  • 查看内核日志
    journalctl -k
  • 查看系统启动日志
    journalctl -b
  • 查看指定时间的日志1
    journalctl --since "20 min ago"
  • 查看指定时间的日志2
    journalctl --since yesterday
  • 查看指定时间的日志3
    journalctl --since 09:00 --until "1 hour ago"

centos 7 日志清理

cat /dev/null > /var/log/boot.log
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/cron
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/firewalld
cat /dev/null > /var/log/grubby
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/mail.info
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/spooler
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/tallylog
cat /dev/null > /var/log/wpa_supplicant.log
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/yum.log

查看服务器运行情况

// 服务器运行情况
tuptime
// 查看脚本运行
top -c

在application.yml配置如下

mybatis:
    // 实体类位置(可以在mapper文件中,不写配置)
    type-aliases-package: com.sskj.entity
    // 配置文件(如果启动外界配置,就不能启动configuration)
    config-location: classpath:mybatis/mybatis-config.xml
    // 映射文件
    mapper-locations: classpath:mybatis/mapper/*.xml

配置文件

xml文件的声明

<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    
</configuration>

配置参考
https://mybatis.org/mybatis-3/zh/configuration.html

mapper文件

xml文件的声明

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper>
    
</mapper>

通过curl获取(任选其中之一)

curl cip.cc
curl ipinfo.io
curl myip.ipip.net
curl http://members.3322.org/dyndns/getip
curl https://ip.cn
curl httpbin.org/ip
curl ip.sb
curl whatismyip.akamai.com
curl ipecho.net/plain
curl icanhazip.com
 
# 淘宝
curl -s  http://ip.taobao.com/service/getIpInfo2.php?ip=myip | awk -F"ip" '{print $2}' | awk -F'"' '{print $3}'
 
curl -s ifcfg.cn/echo | python -m json.tool

查看负担重的sql

mysql> show processlist;
// 或者
mysql> show full processlist

清除mysql查询

mysql> kill 查询ID

添加索引

mysql>  ALTER TABLE tableName ADD INDEX IndexName (`columnName`);

删除索引

mysql> DROP index indexName ON tableName;

sql语句分析

mysql> explain sql语句

mysql57修改用户密码

-- 更改用户密码
update mysql.user set authentication_string=PASSWORD('[userPassword]') where user='[username]';
-- 刷新权限表
flush privileges;

mysql57权限

-- 查看用户权限
show grants for [userName];

-- 创建用户并给予所有权限
GRANT ALL PRIVILEGES ON [dbName].* to [userName]@'[hostName]' identified by '[password]';

  1. 列表项目

文件数量限制

修改文件

vim /etc/security/limits.conf

添加如下内容到此文件的最后:

* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535

查看是否修改成功

// 重启服务器之后,使用命令
ulimit -n

查找大文件

find . -type f -size +800M

批量上传当前目录下空文件

find . -name "*" -type f -size 0c | xargs -n 1 rm -f

docker目录

  • /var/lib/docker

进入容器

docker exec -it [名称] bash

删除所有镜像(记得在启动docker才能操作)

docker rmi -f $(docker images -q)

docker-compose基础

// 正常后台启动
docker-compose up -d
// 重新build
docker-compose up -d --build
// 停止
docker-conpose down
// 清理
docker system prune -a 
// 重新build
docker-compose build 

删除所有目录下所有jpg

find . -name "*.jpg" |  xargs rm -rf