信步漫谈之Redis—Linux下环境搭建

一、环境

Linux 系统:Suse11(SLES-11-SP3-DVD-x86_64-GM-DVD1)
Redis 安装包:redis-4.0.11.tar.gz
     下载地址:http://download.redis.io/releases/

二、操作步骤

1)安装suse环境

2)将redis-4.0.11.tar.gz传到/opt/redis目录下

3)解压 redis-4.0.11.tar.gz(命令:tar -zxvf redis-4.0.11.tar.gz)

4)进入redis-4.0.11目录

5)执行make命令

6)执行make test命令

7)进入源码包目录下的src目录,执行命令:make install

8)测试是否安装成功,进入源码包目录下的src目录,执行命令:./redis-server,跑起来了,效果如下:
image
redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。按 ctrl + c可以关闭窗口。

9)修改配置文件,以后台进程方式启动redis ,步骤如下:
     ①进入/opt/redis/redis-4.0.11,修改redis.conf文件

修改daemonize
daemonize no #默认为no
修改为
daemonize yes #后台进程方式改为yes

修改bind 配置
bind 127.0.0.1 #默认只有本机才能够连接
修改为
bind 192.168.1.101 #改为本机ip地址

修改protected-mode配置
protected-mode yes #在默认保护模式下启用
修改为
protected-mode no #禁用它,任何client不用认证即可连接

修改port端口号
port 6379 #默认为6379端口
修改为
port 6379  #可根据实际情况配置(此处没有修改)

     ②指定redis.conf文件启动,进入源码包目录下的src目录,执行命令:./redis-server ../redis.conf,以后台进程启动redis
     ③测试redis,进入源码包目录下的src目录,执行命令:./redis-cli -h 127.0.0.1 -p 6379,效果如下:
     image
     以上127.0.0.1连接问题原因是地址映射/etc/hosts配置未修改导致,直接使用本机地址后则正常
     ④关闭redis进程(命令:./redis-cli –h 192.168.1.101 –p 6379 shutdown 或 kill –9 进程号)
     ⑤确认 redis 进程是否关闭(命令:ps -aux | grep redis)
     image

10)通过执行src文件夹下的redis-cli, 可以访问redis服务
     image

三、问题解决

1)make 编译提示 /bin/sh: cc: command not found
解决方式:安装 gcc(命令:zypper install gcc)

2)make 编译提示 /deps/hiredis/libhiredis.a: No such file or directory
解决方式:进入源码包目录下的deps目录,执行命令:make hiredis jemalloc linenoise lua

3)make 编译提示 error: jemalloc/jemalloc.h: No such file or directory
原因:jemalloc重载了Linux下的ANSI C的malloc和free函数
解决方式:make时添加参数(命令:make MALLOC=libc)

4)make test 编译提示 Makefile:6: recipe for target 'test' failed
解决方式:调整系统时间(命令:date -s "2018-10-02 10:00:00")

猜你喜欢

转载自www.cnblogs.com/alfredinchange/p/9737685.html
今日推荐