Dlaczego systemctl nie uruchamia serwera redis na CentOS 7?


13

Zainstalowałem redis na nowym komputerze CentOS 7, ale nie mogę go uruchomić przy użyciu systemctl.

Został zainstalowany w następujący sposób:

rpm -i http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
yum install redis

Próba uruchomienia w ten sposób wydawała się po cichu zawieść (nie było danych wyjściowych):

systemctl start redis-server # also tried redis-server.service

Oto, co dzieje się podczas próby połączenia:

redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

Ale uruchomienie go ręcznie działa:

[root@redis ~]# redis-server /etc/redis.conf
[root@redis ~]# redis-cli
127.0.0.1:6379>

Ktoś wie, co się dzieje źle lub jak to debugować?

AKTUALIZACJA: Dane wyjściowe /var/log/redis/redis.logsą poniżej. Btw to pamięć RAM VPS o pojemności 512 MB.

[1972] 29 Jul 18:52:16.258 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[1972] 29 Jul 18:52:16.258 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1972] 29 Jul 18:52:16.258 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1972
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

[1972] 29 Jul 18:52:16.259 # Server started, Redis version 2.8.13
[1972] 29 Jul 18:52:16.259 # 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.
[1972] 29 Jul 18:52:16.260 * DB loaded from disk: 0.001 seconds
[1972] 29 Jul 18:52:16.260 * The server is now ready to accept connections on port 6379
[1972] 29 Jul 18:52:16.265 # User requested shutdown...
[1972] 29 Jul 18:52:16.265 * Saving the final RDB snapshot before exiting.
[1972] 29 Jul 18:52:16.267 * DB saved on disk
[1972] 29 Jul 18:52:16.267 * Removing the pid file.
[1972] 29 Jul 18:52:16.267 # Redis is now ready to exit, bye bye...

I status:

[root@redis ~]# systemctl status redis-server
redis-server.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis-server.service; disabled)
   Active: inactive (dead)

Jul 29 18:52:16 redis systemd[1]: Starting Redis persistent key-value database...
Jul 29 18:52:16 redis systemd[1]: Started Redis persistent key-value database.

2
Oczywiście zaczęło się OK, a potem User requested shutdown...Nie ma wyraźnego powodu.
Michael Hampton

@MichaelHampton tak, natychmiast się wyłącza. Naprawdę chciałbym wiedzieć, dlaczego! Jedyną różnicą, którą widzę, uruchamiając go ręcznie, jest to, że działa jako root (nie użytkownik redis).
Zubin

Odpowiedzi:


25

Wreszcie to naprawiłem. Systemd wymaga redis do uruchomienia bez demonizacji, więc konfiguracja musiała się zmienić:

# /etc/redis.conf
daemonize yes # << comment this out

Świetny. Jest to błąd w pliku jednostki systemowej i należy go zgłosić .
Michael Hampton

Czy kiedykolwiek to rozwiązałeś? Nie oznaczyłeś tego jako rozwiązanego.
Michael Hampton

1
@MichaelHampton Tak, powyższa technika zadziałała. Ponadto zgłosiłem błąd i został on naprawiony.
Zubin

na
zdrowie

Odkryłem, że muszę również edytować plik redis.service (w /etc/systemd/system/multi-user.target.wants), który jest powiązany z /usr/lib/systemd/system/redis.server. Zmieniłem --daemonize yessię, zgadliście, --daemonize no.
Martin
Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.