Files
FileManagement/linux/linux常用命令.txt
T
2017-08-23 14:09:21 +08:00

46 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#允许当前用户进程打开的文件数限制
ulimit -n
#修改上述限制
ulimit -n 20000
#修改Linux系统对用户的关于打开文件数的软限制和硬限制
第一步,修改/etc/security/limits.conf文件,在文件中添加如下行:
speng soft nofile 10240
speng hard nofile 10240
其中speng指定了要修改哪个用户的打开文件数限制,可用'*'号表示修改所有用户的限制;soft或hard指定要修改软限制还是硬限制;10240则指定了想要修改的新的限制值,即最大打开文件数(请注意软限制值要小于或等于硬限制)
查看Linux系统级的最大打开文件数限制,使用如下命令:
cat /proc/sys/fs/file-max
第二步,修改/etc/pam.d/login文件,在文件中添加如下行:
session required /lib/security/pam_limits.so
这是告诉Linux在用户完成系统登录后,应该调用pam_limits.so模块来设置系统对该用户可使用的各种资源数量的最大限制(包括用户可打开的最大文件数限制),而pam_limits.so模块就会从/etc/security/limits.conf文件中读取配置来设置这些限制值。修改完后保存此文件。
第三步,查看Linux系统级的最大打开文件数限制,使用如下命令:
cat /proc/sys/fs/file-max
修改此硬限制的方法是修改/etc/rc.local脚本,在脚本中添加如下行:
  echo 22158 > /proc/sys/fs/file-max
内核编译时默认设置的本地端口号范围可能太小,因此需要修改此本地端口范围限制。
  第一步,修改/etc/sysctl.conf文件,在文件中添加如下行:
  net.ipv4.ip_local_port_range = 1024 65000
这表明将系统对本地端口范围限制设置为1024~65000之间。请注意,本地端口范围的最小值必须大于或等于1024;而端口范围的最大值则应小于或等于65535.修改完后保存此文件。
  第二步,执行sysctl命令:
  [speng@as4 ~]$ sysctl -p
  如果系统没有错误提示,就表明新的本地端口范围设置成功。如果按上述端口范围进行设置,则理论上单独一个进程最多可以同时建立60000多个TCP客户端连接。
#设置时间同步
ntpdate ntp.api.bzNTP服务器(上海)
#修改时区为上海
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime