Linux Centos 7 - Redis Offline Installation

Keywords: Programming Redis RPM CentOS OpenSSL

Install Redis in a disconnected environment.

1. Reference Articles

  • Ali Cloud Mirror centos7 rpm package download address http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
  • Redis download address http://download.redis.io/releases/
  • https://blog.csdn.net/u010177412/article/details/81780844
  • https://www.cnblogs.com/yy3b2007com/p/10513752.html
  • https://www.cnblogs.com/xu-qian-gang/p/10671764.html

2. gcc environment preparation

Check that the gcc-c++ environment already exists on the server using the following commands.

rpm -qa | grep gcc-c++
//or
gcc –version

If not, install the gcc environment first, download the corresponding 26 rpm packages from the following web address, and upload them to the server for installation.

# Ali Cloud Mirror Address
http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

# 26 rpm packages
autogen-5.18-5.el7.x86_64
cpp-4.8.5-36.el7.x86_64
gcc-4.8.5-36.el7.x86_64
gcc-c++-4.8.5-36.el7.x86_64
glibc-devel-2.17-260.el7.x86_64
glibc-headers-2.17-260.el7.x86_64
kernel-headers-3.10.0-957.el7.x86_64
keyutils-libs-devel-1.5.8-3.el7.x86_64
krb5-devel-1.15.1-34.el7.x86_64
libcom_err-devel-1.42.9-13.el7.x86_64
libmpc-1.0.1-3.el7.x86_64
libselinux-devel-2.5-14.1.el7.x86_64
libsepol-devel-2.5-10.el7.x86_64
libstdc++-devel-4.8.5-36.el7.x86_64
libverto-devel-0.2.5-4.el7.x86_64
mpfr-3.1.1-4.el7.x86_64
ntp-4.2.6p5-28.el7.centos.x86_64
ntpdate-4.2.6p5-28.el7.centos.x86_64
openssl-1.0.2k-16.el7.x86_64
openssl098e-0.9.8e-29.el7.centos.3.x86_64
openssl-devel-1.0.2k-16.el7.x86_64
openssl-libs-1.0.2k-16.el7.x86_64
pkgconfig-0.27.1-4.el7.x86_64
tcl-8.5.13-8.el7.x86_64
zlib-1.2.7-18.el7.x86_64
zlib-devel-1.2.7-18.el7.x86_64

Install the rpm package, enter the path where the rpm is stored, and use the following commands to install or upgrade.(Download or upgrade your own packages if they are missing or have an asymmetric package version, not to mention here)

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

After the installation is complete, use the following commands to view the gcc and g++ versions.

gcc -v
g++ -v

3. installation and configuration of redis

3.1 Installation

Redis version: redis-3.2.12.tar.gz

Go to the redis installation package path and unzip to the specified directory.

tar -zxvf redis-3.2.12.tar.gz -C /mnt/sdb1/soft

Compile.

make

Install to the specified directory.

make install PREFIX=/mnt/sdb1/redis

3.2 Configuration, Servicing, Startup

3.2.1 Front desk open (not recommended)

This startup method requires a link that cannot be operated on or closed for the current session page after startup, or the redis service will exit.Start redis-server by entering the bin directory under the installation directory of redis with the following commands:

cd /mnt/sdb1/redis/bin
./redis-server

3.2.2 Background boot (recommended)

Copy the redis.conf file under redis to the bin directory.

cp /mnt/sdb1/redis/redis.conf /mnt/sdb1/redis/bin

Modify this profile to make the following configuration changes.

  1. Set port number: port 6379
  2. Allow remote connections: bind 0.0.0.0
  3. Allow background runs: daemonize yes
  4. Set password: requirepass password
vim /mnt/sdb1/redis/bin/redis.conf

Start.

cd /mnt/sdb1/redis/bin
./redis-server redis.conf

3.2.3 Servicization

3.2.3.1 system directory

Add a new file: vim/etc/systemd/system/redis.service. It is recommended that the file be edited externally and uploaded to the specified folder directory with the following encoding.

[Unit]
Description=The redis-server Process Manager
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/mnt/sdb1/redis/bin/redis-server /mnt/sdb1/redis/bin/redis.conf        
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=always
PrivateTmp=true

[Install]
WantedBy=multi-user.target

3.2.3.2 init.d directory

 

3.2.4 Start-up self-start

Set the following commands.

systemctl daemon-reload

systemctl start redis.service

systemctl enable redis.service

3.2.5 Test

Start the redis client.

cd /mnt/sdb1/redis/bin
./redis-cli

Test, write a string, take out the string.

# Storage String
set name "hello"
# Remove String
get name

Close the redis client.

cd /mnt/sdb1/redis/bin
./redis-cli shutdown

Posted by cmancone on Tue, 24 Sep 2019 09:58:43 -0700