0.conn.ym-ubu24.7.redis
1.安装
cd /data/apk/
wget https://download.redis.io/releases/redis-7.2.4.tar.gz
sudo tar -zxvf /data/apk/redis-7.2.4.tar.gz -C /data/svr
cd /data/svr/redis-7.2.4
sudo make clean
sudo make -j$(nproc)              #用最大线程数来编译
sudo make install
2.配置
  1. 配置文件/data/svr/redis/%i/redis.conf

  2. vim /etc/systemd/system/redis-server@.service

    [Unit]
    Description=Advanced key-value store (%I)
    After=network.target
    Documentation=http://redis.io/documentation, man:redis-server(1)
    
    [Service]
    Type=forking
    ExecStart=/usr/local/bin/redis-server /data/svr/redis/%i/redis.conf
    PIDFile=/data/svr/redis/%i/redis-%i.pid
    TimeoutStopSec=0
    Restart=always
    User=root
    Group=root
    #RuntimeDirectory=redis-%i
    #RuntimeDirectoryMode=2755
    
    UMask=007
    PrivateTmp=yes
    LimitNOFILE=65535
    PrivateDevices=yes
    ProtectHome=yes
    #ReadOnlyDirectories=/
    ReadWritePaths=-/data/svr/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
    ExecStop=/bin/kill -s TERM $MAINPID
    
    # 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
  1. 设置开机启动

    sudo systemctl daemon-reload
    sudo systemctl enable redis-server@4527.service
    sudo systemctl start redis-server@4527.service
    
    sudo systemctl enable redis-server@4528.service
    sudo systemctl start redis-server@4528.service
文档更新时间: 2026-08-17 18:25   作者:morninglu