CentOs7 installation Redis5.0.5

Note: This is redis in CentOS7.6 environment installed, please be other environmental self-test.

(A) download the package

Excuting an order

wget  http://download.redis.io/releases/redis-5.0.5.tar.gz  download the installation package to the server

Or to Baidu network disk download

Links: https://pan.baidu.com/s/1OV227alpjzvvn5m9F_ANzg

Extraction code: fd8b

(B) extracting installation package to the specified path

tat -zxvf redis-5.0.5.tar.gz -C /usr/local

(C) install redis

Since redis is written in C, you need gcc compile time, if the machine has not been installed, execute the command to install gcc.

yum install gcc -y

Offline install gcc, then you need to download dependencies

Baidu network disk download:

Links: https://pan.baidu.com/s/1JIeiC9e4_XU1g7cK3ftyTQ

Extraction code: i47v

Offline installation

Use WinSCP tool to connect to the server, in / opt a new lower gcc files, and to require gcc dependencies copied to gcc folder.

 

Use tools SecureCRT to connect to the server, enter the gcc directory.

cd /opt/gcc

Installation gcc and dependencies

rpm -Uvh *.rpm --nodeps --force

 

Command to see if the installation was successful.

gcc -v

 

Run the installation redis

make PREFIX=/usr/local/redis-5.0.5 install

No error represents a successful installation

(D) initialization redis configuration

1. change Password

In the configuration file /usr/local/redis-5.0.5/redis.conf next file. Find requirepass foobared

In the next line add requirepass 123456

Expressed redis password is 123456

 

2. Support background

Edit the configuration file redis.conf, will be changed to yes daemonize

 

(E) Setting the boot

1. Use root privileges to create redis file directory, and copy redis-server redis-cli

mkdir -p /usr/local/redis  

cp /usr/local/redis-5.0.5/src/redis-server /usr/local/redis/  

cp /usr/local/redis-5.0.5/src/redis-cli /usr/local/redis/  

cp /usr/local/redis-5.0.5/redis.conf /usr/local/redis/  

sudo groupdadd redis

sudo useradd -g redis redis --no-create-home

sudo chown -R redis:redis /usr/local/redis

2. Add the boot service

vim /etc/systemd/system/redis-server.service

 Adding content is as follows:

[Unit]

Description=Redis Server Manager

After=syslog.target

After=network.target

[Service]

Type=simple

User=redis

Group=redis

PIDFile=/var/run/redis_6379.pid

ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf

ExecStop=/usr/local/redis/redis-cli shutdown

Restart=always

[Install]

WantedBy=multi-user.target

3. Set to boot

systemctl daemon-reload

systemctl start redis-server.service

systemctl enable redis-server.service

4. Create redis-cli soft connection

ln -s /usr/local/redis/redis-cli /usr/bin/redis-cli

Guess you like

Origin www.cnblogs.com/renshengruxi/p/11803280.html