Redis
 sql >> डेटाबेस >  >> NoSQL >> Redis

रेडिस अधिकतम खुली फ़ाइल क्यों सेट नहीं कर सकता

खैर, इस पोस्ट के लिए थोड़ा देर हो चुकी है, लेकिन चूंकि मैंने उबंटू 16.04 पर एक नया रेडिस सर्वर 3.0.6 कॉन्फ़िगर करने के लिए अभी बहुत समय (पूरी रात) बिताया है। मुझे लगता है कि मुझे बस यह लिखना चाहिए कि मैं इसे कैसे करता हूं ताकि दूसरों को अपना समय बर्बाद न करना पड़े...

एक नए स्थापित रेडिस सर्वर के लिए, आप शायद रेडिस लॉग फ़ाइल में निम्नलिखित मुद्दों को देखने जा रहे हैं जो कि /var/log/redis/redis-server.log है।

अधिकतम खुली फ़ाइलें

3917:M 16 Sep 21:59:47.834 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
3917:M 16 Sep 21:59:47.834 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
3917:M 16 Sep 21:59:47.834 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.

मैंने बहुत सी पोस्ट देखी हैं जो आपको संशोधित करने के लिए कह रही हैं

/etc/security/limits.conf
redis soft nofile 10000
redis hard nofile 10000

या

/etc/sysctl.conf
fs.file-max = 100000

यह उबंटू 14.04 में काम कर सकता है, लेकिन यह निश्चित रूप से उबंटू 16.04 में काम नहीं करता है। मुझे लगता है कि इसका अपस्टार्ट से सिस्टमड में बदलने से कुछ लेना-देना है, लेकिन मैं लिनक्स कर्नेल का विशेषज्ञ नहीं हूं!

इसे ठीक करने के लिए आपको यह करना होगा systemd रास्ता

/etc/systemd/system/redis.service
[Service]
...
User=redis
Group=redis
# should be fine as long as you add it under [Service] block
LimitNOFILE=65536
...

फिर आपको डेमॉन को फिर से लोड करना होगा और सेवा को फिर से शुरू करना होगा

sudo systemctl daemon-reload
sudo systemctl restart redis.service

यह जांचने के लिए कि क्या यह काम करता है, कैट प्रोक लिमिट्स का प्रयास करें

cat /run/redis/redis-server.pid
cat /proc/PID/limits

और आप देखेंगे

Max open files            65536                65536                files     
Max locked memory         65536                65536                bytes   

इस स्तर पर, अधिकतम खुली हुई फ़ाइल हल हो जाती है।

सॉकेट अधिकतम कनेक्शन

2222:M 16 Sep 20:38:44.637 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

मेमोरी ओवरकमिट

2222:M 16 Sep 20:38:44.637 # Server started, Redis version 3.0.6
2222:M 16 Sep 20:38:44.637 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

चूंकि ये दोनों संबंधित हैं, इसलिए हम इसे तुरंत हल कर देंगे।

sudo vi /etc/sysctl.conf

# Add at the bottom of file
vm.overcommit_memory = 1
net.core.somaxconn=1024

अब इन कॉन्फिग के काम करने के लिए, आपको कॉन्फिग को फिर से लोड करना होगा

sudo sysctl -p

पारदर्शी विशाल पृष्ठ

1565:M 16 Sep 22:48:00.993 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

इसे स्थायी रूप से हल करने के लिए, लॉग के सुझाव का पालन करें, और rc.local को संशोधित करें

sudo vi /etc/rc.local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

इसके लिए आपको रिबूट . करना होगा , अपने डेटा का बैकअप लें या वास्तव में ऐसा करने से पहले आपको जो कुछ भी चाहिए वह करें !!

sudo reboot

अब आप फिर से रेडिस लॉग की जांच करें, आपके पास बिना किसी त्रुटि या चेतावनियों के एक रेडिस सर्वर होना चाहिए।



  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. कॉन्फ़िगरेशन फ़ाइल त्रुटि के कारण Redis सर्वर प्रारंभ करने में असमर्थ

  2. रेडिस में एक निश्चित आकार का क्रमबद्ध सेट?

  3. Redis पब/सब विश्वसनीयता के साथ

  4. जावा के लिए सर्वश्रेष्ठ रेडिस पुस्तकालय

  5. फ्लशडीबी रेडिस में सभी चाबियाँ साफ़ नहीं करता है?