Download and install Redis
- address
Wget HTTP: / / http://download.redis.io/releases/redis-4.0.6.tar.gzCopy the code
- In Linux,
[root@localhost local]# mkdir redis
[root@localhost local]# cd redis/
[root@localhost redis]# pwd
/usr/local/redis
Copy the code
- download
[root@localhost redis]Wget # http://download.redis.io/releases/redis-4.0.6.tar.gz
[root@localhost redis]# pwd
/usr/local/redis
[root@localhost redis]# llTotal 1684-RW-r --r--. 1 root root 1723533 Jun 27 2020 Redis-4.0.6.tar. gz [root@localhost redis]#
Copy the code
- Unpack the
[root@localhost redis]# tar - ZXVF redis - 4.0.6. Tar. Gz
[root@localhost redis]# llTotal 1688 drwxrwxr-x. 6 Root root 4096 Dec 5 2017 Redis-4.0.6-RW-r --r-- 1 root root 1723533 Jun 27 2020 Redis - 4.0.6. Tar. GzCopy the code
- Install GCC dependencies
[root@localhost redis]# yum install gcc
Copy the code
- Compiling redis
[root@localhost redis]# CD redis - 4.0.6[root @ localhost redis - 4.0.6]# make MALLOC=libc
Copy the code
- Add the files in /usr/local/redis-4.0.6/src to /usr/local/bin
[root @ localhost redis - 4.0.6]# cd src && make install
Copy the code
Start Redis in background process mode
[root @ localhost redis - 4.0.6]# vim redis.conf
Copy the code
will
- Modify the redis.conf file
daemonize no
Copy the code
Instead of
daemonize yes
Copy the code
- Configure a password
will
# requirepass foobared
Copy the code
Instead of
requirepass 123456
Copy the code
- Remove the binding
will
bind 127.0.0.1
Copy the code
Instead of
# bind 127.0.0.1
Copy the code
- Specify the redis. Conf file to start
[root@localhost src]#. / redis server/usr/local/redis/redis - 4.0.6 / redis. Conf3190: Oct 23 C 11:55:04. 899# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo3190: Oct 23 C 11:55:04. 899# Redis version=4.0.6, bits=64, commit=00000000, Modified =0, PID =3190, just started3190: Oct 23 C 11:55:04. 899# Configuration loaded
[root@localhost src]#
Copy the code
- Close the Redis process
[root@localhost src]# ps -ef | grep redis
root 3191 1 0 11:55 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 3196 2264 0 11:55 pts/0 00:00:00 grep --color=auto redis
[root@localhost src]# kill -9 3191
Copy the code
Set redis to start automatically upon startup
- Create a new redis directory under /etc
[root@localhost src]# cd /etc/
[root@localhost etc]# mkdir redis
Copy the code
- Copy the /usr/local/redis/redis-4.0.6/redis.conf file to the /etc/redis directory and name it 6379.conf
[root@localhost etc]# cp/usr/local/redis/redis - 4.0.6 / redis. Conf/etc/redis / 6379. Conf
Copy the code
- Make a copy of the redis startup script and place it in /etc/init.d
[root@localhost etc]# cp/usr/local/redis/redis - 4.0.6 / utils/redis_init_script/etc/init. D/redisd
Copy the code
- Set redis to start automatically upon startup
[root@localhost etc]# cd /etc/init.d/
[root@localhost init.d]# chkconfig redisd on
service redisd does not support chkconfig
Copy the code
Redisd does not support chkconfig solution: Edit the redisd file using vim, add the following two lines to the first line, save and exit.
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
Copy the code
- Run the automatic startup command again
[root@localhost init.d]# chkconfig redisd on
Copy the code
- Start the
[root@localhost init.d]# service redisd start
/var/run/redis_6379.pid exists, process is already running or crashed
Copy the code
If the preceding situation occurs, run the following command to resolve the problem
[root@localhost init.d]# redis-server /etc/redis/6379.conf3293: Oct 23 C 12:05:59. 906# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo3293: Oct 23 C 12:05:59. 906# Redis version=4.0.6, bits=64, commit=00000000, Modified =0, PID =3293, just started3293: Oct 23 C 12:05:59. 906# Configuration loaded
[root@localhost init.d]# ps -ef | grep redisroot 3294 1 0 12:05 ? 00:00:00 redis-server 127.0.0.1:6379 root 3299 2264 0 12:06 PTS /0 00:00:00 grep --color=auto redisCopy the code
- stop
[root@localhost init.d]# service redisd stop
Copy the code
- To start again
[root@localhost init.d]# service redisd startStarting Redis server... 3331: Oct 23 C 12:06:26. 551# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo3331: Oct 23 C 12:06:26. 551# Redis version=4.0.6, bits=64, commit=00000000, Modified =0, PID =3331, just started3331: Oct 23 C 12:06:26. 551# Configuration loaded
[root@localhost init.d]# ps -ef | grep redis
root 3332 1 0 12:06 ? 00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379 root 3337 2264 0 12:06 PTS /0 00:00:00 grep --color=auto redisCopy the code
The remote connection
- Disabling the Firewall
[root@localhost bin]# systemctl stop firewalld.service
Copy the code
Access to Redis is successful;
- Open port 6379
[root@localhost bin]# sudo firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[root@localhost bin]# sudo firewall-cmd --reload
success
Copy the code
The resources
https://www.cnblogs.com/zuidongfeng/p/8032505.html
Copy the code