diff --git a/sheep/sheep.c b/sheep/sheep.c
index 8755dc4..4e1bd2b 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -19,6 +19,7 @@
 #include <signal.h>
 #include <linux/limits.h>
 #include <sys/syslog.h>
+#include <sys/resource.h>
 
 #include "sheep_priv.h"
 
@@ -71,6 +72,7 @@ int main(int argc, char **argv)
 	int is_daemon = 1;
 	int log_level = LOG_INFO;
 	char path[PATH_MAX];
+	struct rlimit rlim_nofile;
 
 	signal(SIGPIPE, SIG_IGN);
 
@@ -121,6 +123,15 @@ int main(int argc, char **argv)
 	if (is_daemon && daemon(0, 0))
 		exit(1);
 
+	ret = getrlimit(RLIMIT_NOFILE, &rlim_nofile);
+	if (ret)
+		exit(1);
+	rlim_nofile.rlim_max += NR_WORKER_THREAD * SD_MAX_NODES;
+	rlim_nofile.rlim_cur = rlim_nofile.rlim_max;
+	ret = setrlimit(RLIMIT_NOFILE, &rlim_nofile);
+	if (ret)
+		exit(1);
+
 	jrnl_recover();
 
 	ret = init_event(EPOLL_SIZE);
