源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Linux下Redis服务器搭建过程

  • 时间:2020-09-27 08:19 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Linux下Redis服务器搭建过程
[b]系统环境[/b] 操作系统:CentOS 6.9 redis版本:redis-4.0.2安装步骤 1,安装预环境 运行以下命令安装预环境。 [code][root@redis02 redis-4.0.2]# yum -y install gcc make[/code] 2,下载redis源代码文件并解压缩 下载完redis源代码后,运行以下命令进行解压缩。 [code][root@redis02 softwares]# tar -xzf redis-4.0.2.tar.gz[/code] [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141117133-1245707384.png][img]http://files.jb51.net/file_images/article/201710/2017102914182413.png[/img] [/url] 3,redis编译 运行make命令进行编译。 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141119086-1931542125.png][img]http://files.jb51.net/file_images/article/201710/2017102914183014.png[/img] [/url] make命令执行完成编译后,会在src目录下生成6个可执行文件,分别是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-dump、redis-sentinel。 4,redis安装配置 运行make install命令。 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141120664-1546634246.png][img]http://files.jb51.net/file_images/article/201710/2017102914183015.png[/img] [/url] 命令执行后会将make编译生成的可执行文件拷贝到/usr/local/bin目录下,如下图。 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141121867-1103029313.png][img]http://files.jb51.net/file_images/article/201710/2017102914183116.png[/img] [/url] 然后,运行./utils/install_server.sh配置向导来配置redis,并且可以将redis服务加到开机自启动中。【重要】 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141124117-917062298.png][img]http://files.jb51.net/file_images/article/201710/2017102914183117.png[/img] [/url] 5,redis服务查看,开启和关闭 此时redis服务已经启动了。可以通过以下命令来操作redis了。 查看redis的运行状态: [code][root@redis02 redis-4.0.2]# service redis_6379 status[/code] 关闭redis服务: [code][root@redis02 redis-4.0.2]# service redis_6379 stop[/code] 开启redis服务: [code][root@redis02 redis-4.0.2]# service redis_6379 start[/code] 最后可以通过redis内置的客户端工具来测试下:
[root@redis02 ~]# redis-cli
127.0.0.1:6379> get name
(nil)
127.0.0.1:6379> set name mcgrady
OK
127.0.0.1:6379> get name
"mcgrady"
127.0.0.1:6379> 
可以看到,redis服务已经成功配置好了! [b]注意事项[/b] 1,运行make命令报错? 错误信息如下:
make[3]: gcc: Command not found
/bin/sh: cc: command not found
解决方案: 因为预环境没有安装,运行以下命令安装预环境。
[root@redis02 redis-4.0.2]# yum -y install gcc make
2,安装完预环境后运行make命令报以下错误? 错误信息:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
解决方案: 运行以下命令。
make MALLOC=libc
3,运行make test命令报以下错误? 错误信息: You need tcl 8.5 or newer in order to run the Redis test 解决方案: 运行以下命令安装tcl。
[root@redis02 redis-4.0.2]# yum -y install tcl
4,调用ConnectionMultiplexer.Connect创建连接的时候报错? 错误信息: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on TIME [b]解决方案:[/b] 1)关闭保护模式,注意默认是打开的。 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141125742-2116422697.png][img]http://files.jb51.net/file_images/article/201710/2017102914183118.png[/img] [/url] 2)绑定IP,注意默认只绑定了127.0.0.1。 [url=http://images2017.cnblogs.com/blog/311549/201710/311549-20171027141126883-1263269924.png][img]http://files.jb51.net/file_images/article/201710/2017102914183119.png[/img] [/url] 有用命令: telnet 192.168.1.29 6379,可以直接测试客户端是否能连上服务器,如果通的话,基本上就没有什么问题。 ps -aux | grep redis,查看redis的进程,看redis是否正常启动。 总结 以上所述是小编给大家介绍的Linux下Redis服务器搭建过程,希望对大家有所帮助!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部