GBase 8a
运维管理
文章

修改Linux系统的open files连接数

发表于2025-03-03 09:14:2730次浏览0个评论

方法一:

    [root@i-iivphroy ~]# cat  /etc/security/limits.conf

    *  soft nofile 65535

    *  hard nofile 65535

    * soft nproc 65535

    * hard nproc 65535

    其中nofile对应open_files

    nproc对应max_user_processes

    但是在Linux 6.4之后,如果只修改了该文件中的nproc,那么其他非root用户对应的max_user_processes并不会改变,仍然是1024,这个是因为受到了下面这个文件的影响

    /etc/security/limits.d/90-nproc.conf

    修改/etc/security/limits.d/90-nproc.conf将

    * soft nproc 1024

    修改为:

    * soft nproc 65535

    或者

    修改/etc/security/limits.conf,将

    * soft nofile 10240

    修改为

    Oracle  soft nofile 10240

方法二:这样为每一个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。也就是说,当用户shell执行了bash时,运行这个文件,如果这个服务器上有多个用户,最好是用方法一。

    修改了/etc/bashrc,成功了,并且不用重启。

    vi /etc/bashrc

    添加 :

    ulimit -u 65535

    退出session,从新开session再次ulimit -a 发现已经变化了

    [root@i-iivphroy ~]# ulimit -a

    core file size          (blocks, -c) 0

    data seg size           (kbytes, -d) unlimited

    scheduling priority             (-e) 0

    file size               (blocks, -f) unlimited

    pending signals                 (-i) 62842

    max locked memory       (kbytes, -l) 64

    max memory size         (kbytes, -m) unlimited

    open files                      (-n) 1024

    pipe size            (512 bytes, -p) 8

    POSIX message queues     (bytes, -q) 819200

    real-time priority              (-r) 0

    stack size              (kbytes, -s) 10240

    cpu time               (seconds, -t) unlimited

    max user processes              (-u) 65535

    virtual memory          (kbytes, -v) unlimited

    file locks                      (-x) unlimited

评论

登录后才可以发表评论