The installation and configuration CentOS7.5 Redis5.0.5

https://www.cnblogs.com/cdw0724/p/10876869.html

Preface
install Redis need to know which version they need, targeted installation.
For example, if you need this feature geography redis GEO collection, then redis version can not be lower than the 3.2 version, since this feature is unique to version 3.2.
Also note that, the Redis agreed minor version number (i.e., after the first decimal number) is even stable release version (e.g., version 2.8, version 3.0), non-stationary plate odd version (e.g., version 2.7, version 2.9) , production environment generally requires the use of a stable version.
Redis is installed so the official description: Download, extract and compile Redis with :
namely: download, extract and compile.
Therefore, the document only experimental early adopters, the latest official version redis5.0.5 so installation
steps:
1. Download the installation package

[root @ CentOS7 opt] # pwd # view the current directory, download the source package in this directory
/ opt
[root @ CentOS7 opt] wget http://download.redis.io/releases/redis-5.0.5.tar.gz #
2. extract the source package

[root @ CentOS7 opt] # tar -zxvf redis-5.0.5.tar.gz # decompression will generate a directory of redis-5.0.5
3. GCC mounted reliance

[root @ CentOS7 opt] # yum install gcc gcc-c ++ # encounter selection, input y to
compile & install

[root @ CentOS7 opt] # cd redis-5.0.5 / # redis into the directory
[root @ CentOS7 redis-5.0.5] # make # compiled to wait, i.e. not being given to the next step
[root @ CentOS7 redis- 5.0.5] # make install # installation, when performing the copy will make install several src the following command to the / usr / local / bin / lower
5. run Redis

[CentOS7 the root @ ~] # /opt/redis-5.0 .5 / src / redis-server # directory, run at redis
[root @ CentOS7 ~] # redis -server # run in any directory, because redis-server command in the directory / usr / local / bin directory, and the configuration in the PATH, so you can go to perform redis-cli or redis-server commands such as execution mode ls, mkdir, etc. commands.
After installing the operating
background process started after redis
first step: Modify redis.conf file, redis.conf file in the directory under redis

① configuration allows all ip can access redis, before bind 127.0.0.1 add "#" to commented
② default protection mode, the protected-mode yes changed the mODE nO-protected
③ the default is no daemon mode, the daemonize no change daemonize yes
④ front of requirepass foobared "#" removed, changed the password to the password you want to set (training set to 123456, 123456 upcoming foobared changed)
Step Two: Specify redis.conf file to start

[root @ CentOS7 redis-5.0. 5] # redis-server /opt/redis-5.0.5/redis.conf
third step: Close redis process

[root @ CentOS7 redis-5.0.5] # ps -ef | grep redis #ps -aux | grep redis View redis process
? root 17311 1 0 15:23 00:00:00 redis-Server 127.0.0.1:6379
[root @ CentOS7 redis-5.0.5] # # kill off the kill -9 17311 redis process
step 4: check whether to open All access Ip:

[@ CentOS7 the root-Redis 5.0.5] # the netstat -lunpt
If the port number in front of the display or 0.0.0.0 * then the client can access, if it is 127.0.0.1, showing the machine only access to the configuration file did not comment it out
set redis boot from the start
1. in the / etc directory redis new directory

[root @ CentOS7 redis-5.0.5] # mkdir -pv / etc / redis
2. copy the configuration file into the under / etc / redis /, and was named 6379.conf

[root @ CentOS7 Redis] # cp /opt/redis-5.0.5/redis.conf /etc/redis/6379.conf
3. Create a service

with the service to manage the service, in the /etc/init.d/ directory create a script file to manage start and stop services.
in systemctl, but also similar, different file directory, create a script file redis.service in etc / systemd under / / system directory, which reads as follows:
[ Unit]
the Description = the Redis
the After network.target =

[-Service]
the Type = the forking
ExecStart = / usr / local / bin / Redis-Server /etc/redis/6379.conf
ExecStop = / usr / LOCL / bin / CLI-Redis -H the shutdown -p 6379 127.0.0.1

RestartSec = 10
the Restart = Always

[the Install]
WantedBy = multi-user.target
4. refresh configuration, so that the identification systemctl obtained

[the root @ CentOS7 Redis] # systemctl daemon-reload
5. The startup closed Redis

[the root @ CentOS7 system] # systemctl start redis # start redis service
[root @ CentOS7 system] # systemctl stop redis # redis service shut down
6. Set redis boot

[root @ CentOS7 system] # systemctl enable redis
summarized
in the process of creating the service, due to excessive reference document does not specify the type Type forking. Redis lead to unsuccessful start (no error), by systemctl status redis View error, combined with the Internet to find information to solve temporarily not studied systemctl service, type of type of configuration also do not understand. Then find out. Also under study redis persistence.

 

Guess you like

Origin www.cnblogs.com/yaok430/p/11957045.html