下载构建
mkdir -p /home/packages && cd /home/packagescurl -O https://download.redis.io/releases/redis-6.2.6.tar.gztar -zxvf redis-6.2.6.tar.gzcd redis-6.2.6make install PREFIX=/home/rediscp redis.conf /home/redis/cp sentinel.conf /home/redis/
修改配置
sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' /home/redis/redis.confsed -i 's/protected-mode yes/protected-mode no/g' /home/redis/redis.confsed -i 's/daemonize no/daemonize yes/g' /home/redis/redis.conf# 下方语句修改redis访问密码sed -i 's/# requirepass foobared/requirepass password/g' /home/redis/redis.conf
服务化启动
tee /usr/lib/systemd/system/redis.service <<- 'EOF'[Unit]Description=redis-serverAfter=network.targetBefore=redis-sentinel.service[Service]Type=forkingExecStart=/home/redis/bin/redis-server /home/redis/redis.confPrivateTmp=true[Install]WantedBy=multi-user.targetEOFtee /usr/lib/systemd/system/redis-sentinel.service <<- 'EOF'[Unit]Description=redis-sentinelAfter=network.target redis.serviceRequires=redis.serviceBindTo=redis.service[Service]Type=forkingExecStart=/home/redis/bin/redis-server /home/redis/sentinel.conf --sentinelPrivateTmp=true[Install]WantedBy=multi-user.targetEOFsystemctl daemon-reloadsystemctl enable --now redissystemctl status redis