Windows Development Environment Setup
For Windows-based development, refer to external documentation for detailed MSYS2 configuration. Begin by downloading and installing MSYS2 from the official website, then install required compilation dependencies:
pacman -S gcc make pkg-config
If encountering compiler errors related to undefined types like 'Dl_info', modify the system header file at D:/msys64/usr/include/dlfcn.h by removing conflicting declarations.
Navigate to your Redis source directory and execute the build process:
cd /e/env/redis-7.4.1
make PREFIX=/e/env/redis-7.4.1/bin install
Linux Compilation Proces
Retrieve the Redis source package and extract it:
cd /ycx
wget http://download.redis.io/releases/redis-7.4.1.tar.gz
tar zxvf redis-7.4.1.tar.gz
Create the target installation directory and compile:
cd redis-7.4.1
mkdir /ycx/data/redis
make PREFIX=/ycx/data/redis install
Adjust system memory allocasion settings:
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
Server Configuration
Edit the primary configuration file located at /ycx/data/redis/redis.conf:
bind 0.0.0.0
port 6378
requirepass 123456
daemonize yes
maxclients 20000
appendonly no
save ""
protected-mode no
Service Management
To start the Redis server:
cd /ycx/data/redis/bin/
./redis-server /ycx/data/redis/redis.conf
systemctl start redis-server
systemctl restart redis-server
To gracefully shutdown the service:
cd /ycx/data/redis/bin/
./redis-cli -h 127.0.0.1 -p 6379
> auth 123456
> shutdown
> exit
Performance Monitoring Settnigs
Enable slow query logging with custom thresholds:
slowlog-log-slow-queries yes
slowlog-max-len 200
slowlog-threshold-microseconds 20000
Master-Slave Replication Setup
Master node configuration:
bind 0.0.0.0
port 6379
requirepass 123456
daemonize yes
maxclients 20000
appendonly no
save ""
protected-mode no
repl-diskless-sync no
Slave node configuration:
bind 0.0.0.0
port 6379
requirepass 123456
masterauth 123456
appendonly no
save ""
protected-mode no
replicaof 192.168.0.100 6379
replica-read-only yes