Linux centos install Redis, start Redis, use Redis, stop Redis

redis installation package: the original code in the form provided in the form
.c file
will be compiled to .o .c files need: gcc
the compiled files to install on the Linux system

First, the installation environment

redis is a C language development, you need to first install redis official website to download the original code compiler, gcc compiler-dependent environment. If there is no gcc environment, you need to install gcc:
the case of Linux in network links

[root@localhost ~]# yum install gcc-c++

Here Insert Picture Description
If you are prompted to download, enter y
Here Insert Picture Description
if you are prompted to install, enter y
Here Insert Picture Description
installation is complete

Second, install Redis

Step 1, redis to download Windows

Redis official website: https://redis.io/download
Here Insert Picture Description

Step 2, to upload the compressed file to download Windows Linux, upload through WinSCP, as follows

Upload to / root / can
WinSCP official download: https://winscp.net/eng/download.php
Here Insert Picture Description

Step 3, decompression

Inside the decompression redis-5.0.7.tar.gz Linux
positioned to the root directory

[root@localhost ~]#  cd /root/
[root@localhost ~]# tar -zxvf redis-5.0.7.tar.gz 

Here Insert Picture Description
Here Insert Picture Description
Unzip the file after the success of
Here Insert Picture Description

Step 4, the original code compiler translates the .o files

Enter extract the folder.

[root@localhost ~]# cd redis-5.0.7

Enter redis-5.0.7 to perform

[root@localhost redis-5.0.7]# make

Compile successfully (must be installed before compiling gcc, otherwise it will fail to compile)
Here Insert Picture Description

Step 5, is mounted to the redis / usr / local / redis

a) redis start requires a configuration file, you can modify the port number and other information
to create a folder

[root@localhost ~]# mkdir /usr/local/redis

b) switching to redis-5.0.7 directory

[root@localhost ~]# cd /root/redis-5.0.7

c) mounting the / usr / local / redis /

[root@localhost redis-5.0.7]# make PREFIX=/usr/local/redis/ install

d) the installation is successful
Here Insert Picture Description
after e) the installation is complete, there are several executable files in / usr / local / redis / bin
Here Insert Picture Description

Step 6, copy the file

redis start requires a configuration file, you can modify the port number, etc.

[root@localhost redis-5.0.7]# cp /root/redis-5.0.7/redis.conf /usr/local/redis/

Here Insert Picture Description

Three, Redis start

1, distal Enabler

Direct Run / bin / redis-server will start mode distal end, the distal end mode is started is a disadvantage after startup is completed, other operations can not be performed, if you must use the Ctrl + C , while redis-server program exits, not recommended this method

[root@localhost ~]# /usr/local/redis/bin/redis-server

Run successfully
Here Insert Picture Description
ctrl + c end of the run
Here Insert Picture Description

2, the back-end models start

a) modifying redis.conf profile mode is started after the end daemonize yes

[root@localhost ~]# vim /usr/local/redis/redis.conf

Here Insert Picture Description
Switching the cursor to the desired position by the insertion into the i mode no yes to
Here Insert Picture Description
press Esc wq proceeds to save and exit line mode
Here Insert Picture Description
when b) a promoter, the configuration file specifies
the first change directory

[root@localhost ~]# cd /usr/local/redis/

Start redis-server and specify start to redis.conf

[root@localhost redis]# ./bin/redis-server ./redis.conf

Open port 6379

[root@localhost redis]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT

Save rule

[root@localhost redis]# /etc/rc.d/init.d/iptables save

Port number is turned on and the corresponding rule has been saved
Here Insert Picture Description
to view the corresponding service

[root@localhost redis]# ps -ef|grep -i redis

Here Insert Picture Description
Proof of service is running
c) connected by redis client

[root@localhost redis]# ./bin/redis-cli

Here Insert Picture Description
Test Redis commands
Here Insert Picture Description
d) exit the client

127.0.0.1:6379> quit

Four, Redis stops

1, if it is used apt-get or yum install redis installed, stop / start / restart command directly following redis

[root@localhost redis]# /etc/init.d/redis-server stop
[root@localhost redis]# /etc/init.d/redis-server start
[root@localhost redis]# /etc/init.d/redis-server restart

2, by mounting the redis source, can be restarted by redis redis client application shutdown command redis-cli

[root@localhost redis]# redis-cli -h 127.0.0.1 -p 6379 shutdown

3. If the above methods are not successful stop redis, you can use

[root@localhost redis]# kill -9 
Published 29 original articles · won praise 25 · views 2431

Guess you like

Origin blog.csdn.net/qq_44757034/article/details/104768879