Install redis:
Download redis source code and compile:
Official source code package address
Use the following commands to download, extract and compile Redis:
wget https://download.redis.io/releases/redis-6.0.10.tar.gz
tar xzf redis-6.0.10.tar.gz
cd redis-6.0.10
make
Start redis
The compiled binaries are now available in the src directory. Use the following command to run Redis: After
executing the make command, the compiled redis service program redis-server will appear in the src directory of redis-6.0.8, as well as the client program redis-cli for testing:
start the redis service below:
The first one:
Note that this way to start redis uses the default configuration. You can also tell redis to use the specified configuration file through the startup parameters to start with the second command below.
cd src
./redis-server
The second type:
redis.conf is a default configuration file. We can use our own configuration file as needed.
cd src
./redis-server ../redis.conf
Set redis background startup
1) Place the redis file in the designated folder for management
mv ./redis-6.0.10/ /usr/local/
2) Configure redis to start in the background
vim /usr/local/redis-6.0.10/redis.conf
Find daemonize and change the value to yes
daemonize yes
3) Start redis in the background
cd /usr/local/redis-6.0.10/src
./redis-server ../redis.conf
View the reids process start
ps -ef|grep redis
4) Set Redis directory permissions
chmod -R 755 /usr/local/redis-6.0.10/
5) Add redis to boot
vim /etc/rc.local
/usr/local/redis-6.0.10/src/redis-server /usr/local/redis-6.0.10/redis.conf
Set redis password
/usr/local/redis-6.0.10/src/redis-cli
config set requirepass xxxx
Connect to redis again
/usr/local/redis-6.0.10/src/redis-cli -h 127.0.0.1 -p 6379 -a xxxx
Set environment variables
vim /etc/profile
export PATH="$PATH:/usr/local/redis-6.0.10/src/"
Restart the linux server
reboot
Interact with the client
You can interact with Redis using the built-in client:
/usr/local/redis-6.0.10/src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
Close the redis process
pkill redis
ps -ef|grep redis
Problems and solutions:
1. Install the gcc package:
yum install cpp
yum install binutils
yum install glibc
yum install glibc-kernheaders
yum install glibc-common
yum install glibc-devel
yum install gcc
yum install make
2. Upgrade gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
3. Set permanent upgrade:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
Reference document:
Cainiao:
https://www.runoob.com/redis/redis-install.html
server.c:5171:176: Error:'struct redisServer' has no member named'maxmemory'
https://blog.csdn.net/happyzwh/article/details/106373688