CentOS 7 Source Installation Redis

Keywords: Redis Database yum vim

June 6, 2017 Redis's latest stable version is 3.2.9

1. Dependencies required to install and compile

Update the software to the latest version

yum update && yum upgrade

Install compile dependencies

yum install gcc make tcl

2. Download and unzip redis

cd /usr/local
wget http://download.redis.io/releases/redis-3.2.9.tar.gz
tar zxvf redis-3.2.9.tar.gz
mv redis-3.2.9 redis

3. Compile and install redis

cd redis
make
make test

At this time, the running programs (green files) will appear in our src directory.

4. Move files to corresponding directories

We create bin (running files) directory and etc (configuration files) directory under / usr/local/redis directory

mkdir -p /usr/local/redis/etc
mkdir -p /usr/local/redis/bin

Assign seven green files in the / usr/local/redis/src directory to the / usr/local/redis/bin directory

Assign the / usr/local/redis/redis.conf file to the / usr/local/redis/etc directory

5. Start Redis Service

cd /usr/local/redis/bin
./redis-server

However, in doing so, we did not use the following configuration file for etc to start (the red line section in the figure).
If you want to start through the specified configuration file, you need to specify the configuration file at startup.
Here we first terminate the service with ctrl+C, then check whether redis service terminates cleanly, and then start the service by setting configuration files.

ps -aux | grep redis
lyt      14631  0.0  0.0 112648   960 pts/1    R+   18:48   0:00 grep --color=auto redis

Now let's run redis with the configuration file / usr/local/etc/redis.conf

./redis-server /usr/local/redis/etc/redis.conf

We found that redis was started by reading our configuration file.

However, redis is still running in the foreground.
If you need to run in the background, change the daemonize configuration item to yes

vim /usr/local/redis/etc/redis.conf

Search:' daemonize'
Change the daemonize configuration item to yes to save and exit
Then we use the configuration file to start redis-server again.
As you can see, redis is started in the background, and you can see that redis is running through the ps command.

6. Client login

/usr/local/redis/bin/redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 

Enter ping and return PONG to indicate that the client logged in successfully.


7. Close Redis Service

Stop the Redis instance
We can use it.

pkill redis-server

8.redis.conf related configuration

daemonize #If you need to run in the background, change this item to yes
pidfile #The address for configuring multiple PIDs defaults to / var/run/redis.pid
bind #Bind ip and only accept requests from that ip after setting
port #Listener port, default 6379
loglevel #There are four levels: debug verbose notice warning
logfile #Used to configure log file address
databases #Set the number of databases. The default database is 0.
save #Set the frequency of redis for database mirroring.
rdbcompression #Whether to compress during mirror backup
dbfilename #File Name of Mirror Backup File
Dir #File Placement Path for Database Mirror Backup
Slaveof #Setting up a database as a slave database for other databases
Masterauth #Password Validation Required for Main Database Connection
Requriepass #Password is required for login settings
Maxclients #Limit the number of simultaneous users
Maxmemory #Set the maximum memory redis can use
Appendonly #Open append only mode
Appendfsync #Set the frequency of appendonly.aof file synchronization (the second way to backup data)
vm-enabled #Whether or not virtual memory support is enabled (all parameters at the beginning of the vm are configured for virtual memory)
vm-swap-file #Setting Exchange File Path for Virtual Memory
vm-max-memory #Set the maximum physical memory size used by redis
vm-page-size #Setting the page size of virtual memory
vm-pages #Set the total number of page s to exchange files
vm-max-threads #Set the number of threads that VM IO uses at the same time
Glueoutputbuf #Store small output caches together
hash-max-zipmap-entries #Setting the critical value of hash
Activerehashing #Rehash

Posted by sevenupcan on Mon, 24 Jun 2019 14:57:30 -0700