programing

Ubuntu에서 Neo4j의 최대 파일 열기 제한 (ulimit)을 늘리는 방법은 무엇입니까?

nasanasas 2020. 10. 16. 07:29
반응형

Ubuntu에서 Neo4j의 최대 파일 열기 제한 (ulimit)을 늘리는 방법은 무엇입니까?


현재 ulimit -n표시 10000됩니다. 나는 그것을 40000. 나는 "/etc/sysctl.conf"를 편집하고 fs.file-max=40000. 또한 /etc/security/limits.conf하드 및 소프트 값을 편집 하고 업데이트 했습니다 . 그러나 여전히 ulimit 보여줍니다 10000. 이러한 변경을 모두 수행 한 후 랩톱을 재부팅했습니다. 루트 암호에 액세스했습니다.

usr_name@usr_name-lap:/etc$ /sbin/sysctl fs.file-max
fs.file-max = 500000

/etc/security/limits.conf-에 다음 줄이 추가되었습니다.

*     soft    nofile          40000
*     hard    nofile          40000

나는 또한 다음 줄을 추가했습니다 /etc/pam.d/su.

session    required   pam_limits.so

다른 포럼에서 제공하는 가능한 모든 방법을 시도했지만 최대 한도까지 도달 할 수 있습니다 10000. 무엇이 문제 일 수 있습니까?

neo4j최대 열린 파일 제한이 오류에 도달 했기 때문에이 변경을하고 있습니다 .


Debian을 사용하고 있지만이 솔루션은 Ubuntu에서 잘 작동합니다. neo4j-service 스크립트에
줄을 추가해야합니다 . 내가 한 일은 다음과 같습니다.

나노 /etc/init.d/neo4j-service
«추가 ulimit를 -n 40000 »바로 전에 시작 - 중지 - 데몬 라인 에서 do_start 섹션

버전 2.0 Enterprise Edition을 사용하고 있습니다. 이것이 당신을 도울 것입니다.


수행중인 작업은 루트 사용자에게는 작동하지 않습니다. 서비스를 루트로 실행하고 있으므로 변경 사항을 볼 수 없습니다.

루트 사용자의 ulimit를 늘리려면 루트로 대체해야 *합니다. *루트 사용자에게는 적용되지 않습니다. 휴식은 당신과 동일합니다. 여기서 다시 인용하겠습니다.

파일에 다음 행을 추가하십시오. /etc/security/limits.conf

root soft  nofile 40000

root hard  nofile 40000

그리고 파일에 다음 줄을 추가합니다. /etc/pam.d/common-session

session required pam_limits.so

그러면 루트 사용자의 ulimit가 업데이트됩니다. 의견에서 언급했듯이 변경 사항을 확인하기 위해 재부팅 할 필요조차 없습니다.


1) sysctl file-max제한 확인 :

$ cat /proc/sys/fs/file-max

제한이 원하는 값보다 낮 으면을 열고 sysctl.conf파일 끝에 다음 줄을 추가합니다.

fs.file-max = 65536

마지막으로 sysctl제한을 적용 합니다.

$ sysctl -p 

2) /etc/security/limits.conf위에서 언급 한 내용을 편집 하고 추가하십시오.

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

이러한 제한은 root사용자에게 적용되지 않습니다. 제한 을 변경하려면 root명시 적으로 수행해야합니다.

root soft     nofile         65535   
root hard     nofile         65535
...

3) 시스템을 재부팅하거나 끝에 다음 줄을 추가하십시오 /etc/pam.d/common-session.

session required pam_limits.so

로그 아웃하고 다시 로그인하십시오.

4) 소프트 한계 확인 :

$ ulimit -a

및 엄격한 제한 :

$ ulimit -Ha
....

open files                      (-n) 65535

참조 : http://ithubinfo.blogspot.in/2013/07/how-to-increase-ulimit-open-file-and.html


나는 같은 문제가 있었고 항목을 /etc/security/limits.d/90-somefile.conf. 제한이 작동하는지 확인하려면 ssh 세션에서 완전히 로그 아웃 한 다음 다시 로그인해야합니다.

서비스를 실행하는 특정 사용자에 대한 제한을 설정하고 싶었지만 로그인 한 사용자에 대해 설정된 제한을 받고있는 것 같습니다. 다음은 유효 사용자가 아닌 인증 된 사용자를 기반으로 ulimit가 설정되는 방법을 보여주는 예입니다.

$ sudo cat /etc/security/limits.d/90-nofiles.conf
loginuser    soft    nofile   10240
loginuser    hard    nofile   10240
root         soft    nofile   10241
root         hard    nofile   10241
serviceuser  soft    nofile   10242
serviceuser  hard    nofile   10242

$ whoami
loginuser
$ ulimit -n
10240
$ sudo -i
# ulimit -n
10240    # loginuser's limit
# su - serviceuser
$ ulimit -n
10240    # still loginuser's limit.

You can use an * to specify an increase for all users. If I restart the service as the user I logged in, and add ulimit -n to the init script, I see that the initial login user's limits are in place. I have not had a chance to verify which user's limits are used during a system boot or of determining what the actual nofile limit is of the service I am running (which is started with start-stop-daemon).

There's 2 approaches that are working for now:

  1. add a ulimit adjustment to the init script, just before start-stop-daemon.
  2. wildcard or more extensive ulimit settings in the security file.

You could alter the init script for neo4j to do a ulimit -n 40000 before running neo4j.

However, I can't help but feel you are barking up the wrong tree. Does neo4j legitimately need more than 10,000 open file descriptors? This sounds very much like a bug in neo4j or the way you are using it. I would try to address that.


I have lots of trouble getting this to work.

Using the following allows you to update it regardless of your user permission.

sudo sysctl -w fs.inotify.max_user_watches=100000

Edit

Just saw this from another user also on another stackexchange site (both work, but this version permanently updates the system setting, rather than temporarily):

echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; 
sudo sysctl -p

Try run this command it will create a *_limits.conf file under /etc/security/limits.d

echo "* soft nofile 102400" > /etc/security/limits.d/*_limits.conf && echo "* hard nofile 102400" >> /etc/security/limits.d/*_limits.conf

Just exit from terminal and login again and verify by ulimit -n it will set for * users


tl;dr set both the soft and hard limits

I'm sure it's working as intended but I'll add it here just in case. For completeness the limit is set here (see below for syntax): /etc/security/limits.conf

some_user       soft    nofile          60000
some_user       hard    nofile          60000

and activated with the following in /etc/pam.d/common-session:

session required pam_limits.so

If you set only the hard limit, ulimit -a will show the default (1024): If you set only the soft the limit ulimit -a will show (4096)

If you set them both ulimit -a will show the soft limit (up to the hard limit of course)


I did it like this

echo "NEO4J_ULIMIT_NOFILE=50000" >> neo4j
mv neo4j /etc/default/

ULIMIT configuration:

  1. Login by root
  2. vi security/limits.conf
  3. Make Below entry

    Ulimit configuration start for website user

    website   soft   nofile    8192
    website   hard   nofile    8192
    website   soft   nproc    4096
    website   hard   nproc    8192
    website   soft   core    unlimited
    website   hard   core    unlimited
    
  4. Make Below entry for ALL USER

    Ulimit configuration for every user

    *   soft   nofile    8192
    *   hard   nofile    8192
    *   soft   nproc    4096
    *   hard   nproc    8192
    *   soft   core    unlimited
    *   hard   core    unlimited
    
  5. After modifying the file, user need to logoff and login again to see the new values.

참고URL : https://stackoverflow.com/questions/21515463/how-to-increase-neo4js-maximum-file-open-limit-ulimit-in-ubuntu

반응형