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

02_Redis入门介绍--3_Redis的安装

时间:2020-07-29 15:08:53      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:write   lease   pst   bit   使用   cli   mon   tcl   variables   

一、下载redis(这里以redis-6.0.6为例)

下载路径

安装下载工具wget
yum install wget

直接使用 wget 在 centos7 上下载
wget http://download.redis.io/releases/redis-6.0.6.tar.gz

使用如下方式,需要先在windows下载,然后上传到linux中的 opt 目录下

官网 :https://redis.io 或 http://www.redis.cn/

二、安装redis

1、解压

tar -zxvf  redis-6.0.6.tar.gz

2、进入redis-6.0.6目录

cd redis-6.0.6

3、编译

make

4、问题

使用 make 会出现错误,原因是没有 gcc 编译环境,或 gcc 版本太低。

5、办法

安装高版本的 gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
source /opt/rh/devtoolset-9/enable
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

6、删除刚才出错的文件

make distclean

7、将redis安装到 /usr/local/redis 目录下

make install PREFIX=/usr/local/redis

8、查看安装结果

ll /usr/local/redis/bin
-rwxr-xr-x. 1 root root 4739824 7月  28 13:38 redis-benchmark
-rwxr-xr-x. 1 root root 9653552 7月  28 13:38 redis-check-aof
-rwxr-xr-x. 1 root root 9653552 7月  28 13:38 redis-check-rdb
-rwxr-xr-x. 1 root root 5059024 7月  28 13:38 redis-cli
lrwxrwxrwx. 1 root root      12 7月  28 13:38 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 9653552 7月  28 13:38 redis-server

三、测试

1、查看解压 redis-6.0.6.tar.gz后的目录

ll /opt/redis-6.0.6
-rw-rw-r--.  1 root root 80561 7月  21 02:08 00-RELEASENOTES
-rw-rw-r--.  1 root root    51 7月  21 02:08 BUGS
-rw-rw-r--.  1 root root  2381 7月  21 02:08 CONTRIBUTING
-rw-rw-r--.  1 root root  1487 7月  21 02:08 COPYING
drwxrwxr-x.  6 root root   192 7月  28 13:15 deps
-rw-r--r--.  1 root root   107 7月  28 14:01 dump.rdb
-rw-rw-r--.  1 root root    11 7月  21 02:08 INSTALL
-rw-rw-r--.  1 root root   151 7月  21 02:08 Makefile
-rw-rw-r--.  1 root root  6888 7月  21 02:08 MANIFESTO
-rw-rw-r--.  1 root root 20806 7月  21 02:08 README.md

# 注意不要修改原版的配置
-rw-rw-r--.  1 root root 83392 7月  21 02:08 redis.conf

-rwxrwxr-x.  1 root root   275 7月  21 02:08 runtest
-rwxrwxr-x.  1 root root   280 7月  21 02:08 runtest-cluster
-rwxrwxr-x.  1 root root   679 7月  21 02:08 runtest-moduleapi
-rwxrwxr-x.  1 root root   281 7月  21 02:08 runtest-sentinel
-rw-rw-r--.  1 root root 10743 7月  21 02:08 sentinel.conf
drwxrwxr-x.  3 root root  8192 7月  28 13:38 src
drwxrwxr-x. 11 root root   182 7月  21 02:08 tests
-rw-rw-r--.  1 root root  3055 7月  21 02:08 TLS.md
drwxrwxr-x.  9 root root  4096 7月  21 02:08 utils

2、创建 myredis目录, 保存 redis.conf

mkdir /myredis

3、复制redis.conf

cp /usr/local/redis/redis.conf  /myredis/

4、进入 myredis 目录

cd /myredis

5、修改 /myredis/redis.conf 文件(找到GENERAL中的 daemonize no,将 no 改为 yes)

vim redis.conf

218 ################################# GENERAL #####################################
 219 
 220 # By default Redis does not run as a daemon. Use ‘yes‘ if you need it.
 221 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
 
 222 daemonize yes
 
 223 
 224 # If you run Redis from upstart or systemd, Redis can interact with your
 225 # supervision tree. Options:
 226 #   supervised no      - no supervision interaction
 227 #   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
 228 #   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
 229 #   supervised auto    - detect upstart or systemd method based on
 230 #                        UPSTART_JOB or NOTIFY_SOCKET environment variables
 231 # Note: these supervision methods only signal "process is ready."
 232 #       They do not enable continuous liveness pings back to your supervisor.
 233 supervised no
 234 
 235 # If a pid file is specified, Redis writes it where specified at startup

6、到 /usr/local/redis/bin 目录下

cd /usr/local/redis/bin

7、加载 /myredis/redis.conf文件

./redis-server /myredis/redis.conf
1511:C 29 Jul 2020 13:37:36.613 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1511:C 29 Jul 2020 13:37:36.613 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=1511, just started
1511:C 29 Jul 2020 13:37:36.613 # Configuration loaded

8、测试是否安装成功

./redis-cli -p 6379

9、显示结果

[root@hadoop1 bin]# ./redis-cli -p 6379
127.0.0.1:6379> 

02_Redis入门介绍--3_Redis的安装

标签:write   lease   pst   bit   使用   cli   mon   tcl   variables   

原文地址:https://www.cnblogs.com/zwxo1/p/13396668.html

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