redis版本:redis-4.0.8
redis官方网站可以获取最新版本:https://redis.io/
创建文件夹来存放redis安装包:
mkdir server_redis
下载redis安装包:
wget http://download.redis.io/redis-stable.tar.gz
解压:
tar xzf redis-4.0.8.tar.gz
编译安装:
[root@localhost server_redis]# cd redis-4.0.8 # 进入解压后的文件夹,使用make编译
[root@localhost redis-4.0.8]# make
编译后报错,未找到gcc:
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c make[3]: gcc:命令未找到 make[3]: *** [net.o] 错误 127
可以使用yum insatll 安装gcc 一些依赖库也会自动下载比较方便:
[root@localhost server_redis]# yum search gcc # 找到我们想要的gcc编译器 [root@localhost server_redis]# yum search gcc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.nju.edu.cn * updates: mirrors.nju.edu.cn =============================== N/S matched: gcc =============================== relaxngcc-javadoc.noarch : Javadoc for relaxngcc compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler compat-gcc-44-gfortran.x86_64 : Fortran support for compatibility compiler gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...) gcc-gfortran.x86_64 : Fortran support gcc-go.x86_64 : Go support libgomp.i686 : GCC OpenMP v3.0 shared support library ...部分省略...
这里我下载的是gcc.x86_64 我也不是太懂,但是后来的编译中并没有什么问题 但是有几个warning 求大神指导一下
然后就一路 y 就可以了
[root@localhost server_redis]# yum install gcc.x86_64
Is this ok [y/N]: y
安装成功后就可以编译了:
[root@localhost redis-4.0.8]# make
这里我并没有出现报错但是有的人可能出现编译失败的 可以参考一下这个:
http://blog.csdn.net/qq_26144777/article/details/56839257
进入 src文件夹 执行make install :
[root@localhost src]# make install CC Makefile.dep Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install
到这里就可以运行redis了 可以执行 ./redis-server:
[root@localhost src]# ./redis-server 6195:C 07 Mar 11:58:29.584 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 6195:C 07 Mar 11:58:29.584 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=6195, just started 6195:C 07 Mar 11:58:29.584 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf 6195:M 07 Mar 11:58:29.584 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 4.0.8 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 6195 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
但是这样退出后并不会后台运行:
[root@localhost redis-4.0.8]# ./utils/install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] Selected default - /etc/redis/6379.conf Please select the redis log file name [/var/log/redis_6379.log] Selected default - /var/log/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] Selected default - /var/lib/redis/6379 Please select the redis executable path [/usr/local/bin/redis-server] Selected config: Port : 6379 Config file : /etc/redis/6379.conf Log file : /var/log/redis_6379.log Data dir : /var/lib/redis/6379 Executable : /usr/local/bin/redis-server Cli Executable : /usr/local/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful!
我都是默认的没有修改, 下面就修改配置文件了,进入并打开etc/redis/6379.conf:
[root@localhost server_redis]# cd /etc/redis/ [root@localhost redis]# vim 6379.conf
找到requierpass去掉注释 修改密码 方便后面的redis desktop manager连接
注释掉 bing 127.0.0.1
将appendonly yes 修改为no:
appendonly no
退出并保存
下面就是介绍怎么使用redis desktop manager 连接了 由于linux 安全策略的问题,这里我们要修改防火墙配置,有点麻烦:
命令比较简单:
[root@localhost redis]# iptables -A INPUT -P tcp --dport 6379 -j ACCEPT # centos 7中不知道iptables有没有影响但是还是设置了一下 最后发现保存不了,醉了,网上查要修改文件,不管了先
修改firewall策略:
[root@localhost etc]# firewall-cmd --zone=public --add-port=6379/tcp # 修改firewall规则 success [root@localhost etc]# firewall-cmd --permanent --zone=public --add-port=6379/tcp success [root@localhost etc]# firewall-cmd --reload # 永久保存 successlinux中基本配置完成,下面用redis desktop manager连接:
附带连接成功效果图: