1 下载Index of /releases/ (redis.io)
通过xftp等方式上传到服务器,安装依赖包
yum install gcc gcc-c++ make tcl -y
[root@localhost software]# ll
total 3308
-rw-r--r--. 1 root root 3386861 May 3 21:56 redis-7.2.4.tar.gz
[root@localhost software]# ll
total 3308
-rw-r--r--. 1 root root 3386861 May 3 21:56 redis-7.2.4.tar.gz
[root@localhost software]# tar xf redis-7.2.4.tar.gz
[root@localhost software]# mv redis-7.2.4/ redis/
[root@localhost software]# cd redis/
[root@localhost redis]# make MALLOC=libc
[root@localhost redis]# make test
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory '/data/software/redis/src'
[root@localhost redis]# make install PREFIX=/usr/local/redis
cd src && make install
make[1]: Entering directory '/data/software/redis/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
make[1]: Leaving directory '/data/software/redis/src'
[root@localhost redis]# mkdir -p /usr/local/redis/etc
[root@localhost redis]# cp redis.conf /usr/local/redis/etc/
[root@localhost redis]# vim /usr/local/redis/etc/redis.conf
bind 127.0.0.1 -::1-->bind 0.0.0.0
# requirepass foobared-->requirepass 123456
daemonize no-->daemonize yes
#vim /etc/profile
export PATH="$PATH:/usr/local/redis/bin"
#source /etc/profile
#过量使用内存设置为0!在低内存环境下,后台保存可能失败
[root@localhost redis]# vim /etc/sysctl.conf
[root@localhost redis]# sysctl -p
2 启动
[root@localhost redis]# redis-cli -v
redis-cli 7.2.4
[root@localhost redis]# redis-server /usr/local/redis/etc/redis.conf
#查看进程
#测试下
#配置系统服务启动
[root@localhost redis]# vim /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载系统服务
systemctl daemon-reload
设置开机自启:
systemctl enable redis
#关闭之前启动的进程
ps -ef | grep redis| grep -v grep| awk -F " " '{print $2}'| xargs kill -9
启动服务
systemctl start redis