centos7.6 安装redis5.0.4 单机
admin
2023-02-27 22:22:17
0次

centos7.6 安装redis5.0.4

查看列表
http://download.redis.io/releases/

目前最新版稳定版为5.0.6

[ ] redis-5.0.6.tar.gz

[root@VM_147_31_centos src]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@VM_147_31_centos src]# uname -a
Linux VM_147_31_centos 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@VM_147_31_centos src]#

创建目录
mkdir /home/redis

进入目录
cd /home/redis/

下载redis
wget http://download.redis.io/releases/redis-5.0.4.tar.gz
编译

解压redis:
tar -xvf redis-5.0.4.tar.gz

编译redis(腾讯的试验环境已经安装了GCC所以可以直接编译):
进入redis解压目录
cd redis-5.0.4/

编译
make

安装

用 make 安装 redis
make install PREFIX=/usr/local/mysoft/redis

后面是你自己的安装路径。PREFIX参数指定redis的安装目录。一般软件安装到/usr目录下
[root@VM_147_31_centos redis-5.0.4]# ll /usr/local/mysoft/redis/
total 4
drwxr-xr-x 2 root root 4096 Nov 13 17:53 bin
[root@VM_147_31_centos redis-5.0.4]# ll /usr/local/mysoft/redis/bin/
total 32700
-rwxr-xr-x 1 root root 4366640 Nov 13 17:53 redis-benchmark
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-check-aof
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-check-rdb
-rwxr-xr-x 1 root root 4806872 Nov 13 17:53 redis-cli
lrwxrwxrwx 1 root root 12 Nov 13 17:53 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-server
[root@VM_147_31_centos redis-5.0.4]#

修改配置
文件由于安装目录仅仅是二进制文件,不包含配置文件,这里我们要把编译目录的配置文件拷贝过来,我们先进入到安装目录, cd /usr/local/mysoft/redis 拷贝配置文件,顺便命名为 single.conf

cp /home/redis/redis-5.0.4/redis.conf single.conf
修改配置文件,把 redis 启动改成后台启动

编辑 /home/redis/redis-5.0.4/single.conf

键入 ctrl+F 进行搜索,找到 daemonize no,把 no 改为 yes ,键入 ctrl+S 保存即可。

[root@VM_147_31_centos redis-5.0.4]# cp /home/redis/redis-5.0.4/redis.conf single.conf
[root@VM_147_31_centos redis-5.0.4]# vi /home/redis/redis-5.0.4/single.conf
[root@VM_147_31_centos redis-5.0.4]#
[root@VM_147_31_centos redis-5.0.4]# grep daemonize /home/redis/redis-5.0.4/single.conf
#Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
#When the server runs non daemonized, no pid file is created if none is
#specified in the configuration. When the server is daemonized, the pid file
output for logging but daemonize, logs will be sent to /dev/null
[root@VM_147_31_centos redis-5.0.4]# pwd
/home/redis/redis-5.0.4
[root@VM_147_31_centos redis-5.0.4]#

启动 redis-server
cd src

./redis-server ../single.conf

查看redis是否正常启动
ps aux|grep redis

[root@VM_147_31_centos redis-5.0.4]# cd src
[root@VM_147_31_centos src]# ./redis-server ../single.conf
28677:C 13 Nov 2019 17:56:42.855 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
28677:C 13 Nov 2019 17:56:42.855 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=28677, just started
28677:C 13 Nov 2019 17:56:42.855 # Configuration loaded
[root@VM_147_31_centos src]# ps -ef | grep redis
root 28678 1 0 17:56 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 28700 22792 0 17:56 pts/0 00:00:00 grep --color=auto redis
[root@VM_147_31_centos src]#

测试试验

使用 redis-cli 客户端连接本机 redis
./redis-cli -h 127.0.0.1 -p 6379
设值
set test 123456
获取值
get test

[root@VM_147_31_centos src]# ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> set test 123456docker19.3
OK
127.0.0.1:6379> get test
"123456docker19.3"
127.0.0.1:6379> exit
[root@VM_147_31_centos src]#

[root@VM_147_31_centos bin]# pwd
/usr/local/mysoft/redis/bin
[root@VM_147_31_centos bin]# ll
total 32700
-rwxr-xr-x 1 root root 4366640 Nov 13 17:53 redis-benchmark
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-check-aof
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-check-rdb
-rwxr-xr-x 1 root root 4806872 Nov 13 17:53 redis-cli
lrwxrwxrwx 1 root root 12 Nov 13 17:53 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8101312 Nov 13 17:53 redis-server
[root@VM_147_31_centos bin]# ./redis-cli -v
redis-cli 5.0.4
[root@VM_147_31_centos bin]#

相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...