Install and uninstall Redis under Linux system
Install Redis
1. Download the redis installation package
download address: https://redis.io/download
2. Put the installation package in the Linux file system and use the WinSCP tool
3. Unzip
tar -zxf redis-4.0.2.tar.gz
4. Switch to the decompressed directory
cd redis-4.0.2
5. Compile
make
6. Go to the src directory
cd src
7. Execute the installation
make install
At this point the installation is complete. However, since we did not choose the installation path when installing redis, it is installed in the default location. Here, we can move the executable and configuration files to the directory we are used to.
cd /usr/local
mkdir -p /usr/local/redis/bin
mkdir -p /usr/local/redis/etc
cd /usr/local/redis-4.0.2
mv ./redis.conf /usr/local/redis /etc
cd src
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server redis-sentinel /usr/local/redis/bin
Three important executable files :
redis-server: Redis server program
redis-cli: Redis client program, it is a command line operation tool. It is also possible to use telnet to operate according to its plain text protocol.
redis-benchmark: Redis performance test tool, test the read and write performance of Redis under your system and configuration
Redis startup command:
/usr/local/redis/bin/redis-server
or
cd /usr/local/redis/bin
./redis-server /usr/local/redis/etc/redis.conf Specify configuration for redis-server document
Second, the configuration of Redis
Some common configuration items in Redis are listed below:
daemonize If you need to run the Redis service as a daemon process in the background, change the value of this item to yes
pidfile configures the addresses of multiple pids, the default is /var/run/redis/pid
bind binds the ip, and only accepts requests from this ip after setting
port listening port, the default is 6379
timeout Client connection timeout setting, the unit is seconds
loglevel is divided into 4 levels, debug, verbose, notice, warning
logfile configure the log file address
databases Set the number of databases, the default database used is 0
save sets the frequency of database mirroring by redis
rdbcompression Whether to compress when performing image backup
Dbfilename The filename of the mirror backup file
Dir database mirror backup file storage path
Slaveof sets the database as the slave database of other databases
Masterauth The password authentication required for the main database connection
Requirepass Set the password to be used when logging in
Maxclients Set the maximum number of clients connected at the same time
Maxmemory Set the maximum memory that redis can use
Appendonly Enable append only mode
Appendfsync Set the frequency of synchronizing the appendonly.aof file
vm -enabled Whether to enable virtual memory support
vm-swap-file Set the swap file path of virtual memory
vm-max-memory Set the maximum virtual memory that redis can use
vm-page-size Set the page size of virtual memory
vm-pages Set the size of the swap file The total number of pages
vm-max-threads Set the number of threads used by VMIO at the same time
Glueoutputbuf Store small output buffers together
hash-max-zipmap-entries Set the threshold of
hash Activerehashing Re-hash
Modify the configuration parameters of redis :
vi /usr/local/redis/etc/redis.conf
Change daemonize no to daemonize yes, save and exit.
Then start the redis server
cd /usr/local/redis/bin
./redis-server /usr/local/redis/etc/redis.conf Start redis and specify the configuration file
ps aux | grep redis to see if redis started successfully
netstat -tlun to see if the host's port 6379 is in use (listening)
./redis-cli open the redis client
quit to quit the redis client
pkill redis-server shuts down the redis server
./redis-cli shutdown can also shut down the redis server with this command
Uninstall Redis
1. First check if redis-server starts
ps aux | grep redis
2. Close these processes
3. Delete the corresponding folder of redis.