mysql ulimit_linux系统资源限制-ulimit详解:

linux系统资源限制-ulimit详解:

一.查看文件句柄使用情况:

lsof -n | awk '{print $2}' | sort | uniq -c | grep'pid of mysql'

二.查看3306连接数:

netstat -ano | grep ip:3306 | awk '{print $5}' | awk-F ':' '{print $1}' | sort | uniq -c

三.iptables 限制最大连接数来处理(每个ip并发连接不超过200个):

iptables -A INPUT -p tcp -m tcp --dport 3306--tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 200--connlimit-mask 32 -j REJECT --reject-with tcp-reset

四.文件句柄跟文件描述符都跟文件没关系文件句柄是你操作的一个对象对于程序来说就是文件文件描述符是操作系统维护的一个整数这个整数就是操作系统文件描述符表里关于这个文件句柄的索引值。

系统运行中:文件句柄=文件描述符数!

五.查看系统级别资源限制:

1.系统级别:

sysctl -a (-a:显示当前所有可用的值)

cat /proc/sys/fs/file-max 等一系列值

2.session 设置:

ulimit -a # 查看所有的

ulimit -S -n1024 #设置当前会话的打开文件数软连接数为 1024.

ulimit -H -n1024 #设置当前会话的打开文件数硬连接数为 1024.

ulimit -n 996 #设置当前会话的打开文件数硬&&软连接数都为 1024.

3.设置用户(只针对用户的每个进程):

#

#

* soft nofile 32768

* hard nofile 65536

can be one of the following:

# - core- limits the core file size (KB)

# - data- max data size (KB)

# -fsize - maximum filesize (KB)

# -memlock - max locked-in-memory address space (KB)

# -nofile - max number of open files

# - rss- max resident set size (KB)

# -stack - max stack size (KB)

# - cpu- max CPU time (MIN)

# -nproc - max number of processes

# - as -address space limit

# -maxlogins - max number of logins for this user

# -maxsyslogins - max number of logins on the system

# -priority - the priority to run user process with

# -locks - max number of file locks the user can hold

# -sigpending - max number of pending signals

# -msgqueue - max memory used by POSIX message queues (bytes)

# - nice- max nice priority allowed to raise to

# -rtprio - max realtime priority

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值