Redis Single Node
| Server IP | Host Role |
|---|---|
| 192.168.10.13 | Redis Server |
Redis Server
-
Download the Redis installation package
- Server with Internet Access
- Server without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/redis-8.0.4-glibc2.17-amd64.tar.gz# Link for downloading the Redis installation package, upload to the deployment server after downloadinghttps://pdpublic.mingdao.com/private-deployment/offline/common/redis-8.0.4-glibc2.17-amd64.tar.gz -
Extract to the installation directory
tar -zxvf redis-8.0.4-glibc2.17-amd64.tar.gzmv redis-8.0.4-glibc2.17-amd64 /usr/local/redis -
Adjust kernel parameters
echo 'net.core.somaxconn = 32768' >> /etc/sysctl.d/99-sysctl.confecho 'vm.overcommit_memory = 1' >> /etc/sysctl.d/99-sysctl.confsysctl -p -
Create the redis data directory
mkdir /data/redis -
Modify the configuration file
cat > /usr/local/redis/redis.conf <<'EOF'bind 0.0.0.0protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize nosupervised nopidfile /usr/local/redis/redis.pidloglevel noticelogfile /usr/local/redis/redis.logdatabases 16save 900 1save 300 10save 60 100000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /data/redisslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100lua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 0 0 0hz 10requirepass 123456masterauth 123456maxmemory 6gbmaxmemory-policy allkeys-lrumaxclients 100000rename-command KEYS ""EOF- The password for Redis authentication and master-slave authentication is
123456, it must be changed to a strong password during actual deployment. - If the password contains special characters, only
-or_are allowed, and characters like@ ! # &must be avoided to prevent compatibility issues.
- The password for Redis authentication and master-slave authentication is
-
Create redis user authorization
useradd -U -M -s /sbin/nologin redischown -R redis:redis /usr/local/redis/ /data/redis -
Configure systemd management
cat > /etc/systemd/system/redis.service <<'EOF'[Unit]Description=Redis[Service]User=redisGroup=redisTasksMax=infinityLimitNOFILE=102400LimitNPROC=infinityLimitCORE=0ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.confExecStop=/usr/bin/kill $MAINPIDRestart=on-failure[Install]WantedBy=multi-user.targetEOF -
Start the redis service and enable it on boot
systemctl start redissystemctl enable redis -
Test Redis connection login
/usr/local/redis/bin/redis-cli -a 123456