多个 redis ubuntu 20.04 LTS

多个 redis ubuntu 20.04 LTS

谁能解释一下,redis 出了什么问题?)

# systemctl status m1-redis
● m1-redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/m1-redis-server.service; enabled; vendor preset: enabled)
     Active: activating (start) since Fri 2022-02-25 12:07:04 UTC; 2h 52min left
       Docs: http://redis.io/documentation,
             man:redis-server(1)
    Process: 765 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 2274)
     Memory: 344.0K
     CGroup: /system.slice/m1-redis-server.service

Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: Starting Advanced key-value store...
Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: m1-redis-server.service: Can't open PID file /run/redis/redis-server-6381.pid (yet?) after start: Operation not permitted
Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: m1-redis-server.service: New main PID 831 does not belong to service, and PID file is not owned by root. Refusing.
Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: m1-redis-server.service: New main PID 831 does not belong to service, and PID file is not owned by root. Refusing.

# systemctl status s2-redis
● s2-redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/s2-redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-02-25 12:07:04 UTC; 2h 52min left
       Docs: http://redis.io/documentation,
             man:redis-server(1)
    Process: 771 ExecStart=/usr/bin/redis-server /etc/redis/redis2.conf (code=exited, status=0/SUCCESS)
   Main PID: 837 (redis-server)
      Tasks: 4 (limit: 2274)
     Memory: 2.6M
     CGroup: /system.slice/s2-redis-server.service
             └─837 /usr/bin/redis-server *:6382 [cluster]

Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: Starting Advanced key-value store...
Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: s2-redis-server.service: Can't open PID file /run/redis/redis-server-6382.pid (yet?) after start: Operation not permitted
Feb 25 12:07:04 rrm-ubuntu1 systemd[1]: Started Advanced key-value store.

# redis-cli -c -h 10.61.10.125 -p 6382
10.61.10.125:6382> ping
PONG
10.61.10.125:6382>
# redis-cli -c -h 10.61.10.125 -p 6381
10.61.10.125:6381> ping
PONG

# ps -aux | grep redis
redis        831  0.1  0.3  63504  7032 ?        Ssl  09:13   0:00 /usr/bin/redis-server *:6381 [cluster]
redis        837  0.2  0.3  55824  6368 ?        Ssl  09:13   0:00 /usr/bin/redis-server *:6382 [cluster]
root        1237  0.0  0.0   6432   736 pts/0    S+   09:15   0:00 grep --color=auto redis

猫單元的。

# cat /lib/systemd/system/m1-redis-server.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
PIDFile=/var/run/redis/redis-server-6381.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755

UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWritePaths=-/var/lib/redis
ReadWritePaths=-/var/log/redis
ReadWritePaths=-/var/run/redis

NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX

# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis

[Install]
WantedBy=multi-user.target
Alias=m1-redis.service


# cat /lib/systemd/system/s2-redis-server.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis2.conf
PIDFile=/var/run/redis/redis-server-6382.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755

UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWritePaths=-/var/lib/redis
ReadWritePaths=-/var/log/redis
ReadWritePaths=-/var/run/redis

NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX

# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis

[Install]
WantedBy=multi-user.target
Alias=s2-redis.service

答案1

/etc/redis 中的配置文件需要编辑

daemonize yes
supervised auto --or systemd

相关内容