码迷,mamicode.com
首页 > 其他好文 > 详细

centos7.6 安装redis5.0.4 单机

时间:2019-11-14 09:39:34      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:ctrl   安装   auto   not   for   dha   var   后台   doc   

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]#

centos7.6 安装redis5.0.4 单机

标签:ctrl   安装   auto   not   for   dha   var   后台   doc   

原文地址:https://blog.51cto.com/guanhaizhan/2450086

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!