查看内存占用
1 | |
ssh动态端口转发
1 | |
chrome 浏览器配置socks代理
1 | |
date 格式化输出当前时间
在备份的时候可以用来指定当前备份的时间
1 | |
查看服务器当前虚拟内存使用偏移量
1 | |
修改值swappiness
临时修改
1
sysctl vm.swappiness=10永久修改
1
2
3
4
5
6
7
8# 编辑主配置
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
# 或创建独立配置文件(推荐)
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
# 重载配置
sudo sysctl --system
yum源设置
本地yum源挂载使用
1
2
3
4
5
6
7
8
9
10
11
12
13
141. 备份
(1.)mkdir /beifen
(2.)mv /etc/yum.repos.d/* /beifen
2. 创建本地yum仓库
(1.)mount /dev/sr0 /mnt
(2.)vim /etc/yum.repos.d/Base.repo
3、Base.repo配置如下
[Base]
name=Base
baseurl=file:///mnt
enabled=1
gpgcheck=0
yum clean all -- 删除缓存数据
yum makecache -- 重建缓存网络yum配置使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15# 这里使用的是阿里巴巴开源镜像站的centos的yum仓库
https://developer.aliyun.com/mirror/
1、备份:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all -- 删除缓存数据
yum makecache -- 重建缓存
3、设置epel源
备份:
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
下载新repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo查看进程limit值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20# 查找 PostgreSQL 主进程 PID
pgrep -f postgres
# 查看特定 PostgreSQL 进程打开的文件描述符数量(替换 <PID> 为实际进程 ID)
ls -l /proc/<PID>/fd | wc -l
# 查看该进程的具体限制配置
cat /proc/<PID>/limits | grep "Max open files"
# 执行脚本指定输出文件并实时查看
./test.sh | tee -a test.log
# 永久修改/etc/security/limits.conf
haproxy soft nofile 65535
haproxy hard nofile 100000
haproxy soft nproc 65535
haproxy hard nproc 100000
[service]
LimitNOFILE=65535
LimitNPROC=65535清楚缓存命令
1
2
3
4
5
6
7
8
9
10
11# 同步内存中的数据到磁盘,确保数据安全
sync
# 清除 PageCache(页缓存)
echo 1 > /proc/sys/vm/drop_caches
# 清除 dentries 和 inodes
echo 2 > /proc/sys/vm/drop_caches
# 同时清除 PageCache、dentries 和 inodes(最彻底)
echo 3 > /proc/sys/vm/drop_caches