如果报错:[root@localhost ~]#yum -y install gcc gcc-c++ libstdc++-devel tcl wget vim tree gcc gcc-c++ autoconf curl-devel ruby ruby-devel rubygems rpm-build #安装依赖包
[root@localhost ~]#su - jjzb
[jjzb@localhost ~]$mkdir /home/jjzb #安装文件请直接下载到要安装的路径下
[jjzb@localhost ~]$ wget http://mirror.cnop.net/redis/redis-3.2.6.tar.gz
[jjzb@localhost ~]$ tar -zxvf redis-3.2.6.tar.gz
[jjzb@localhost ~]$ mv redis-3.2.6 redis #这里要安装到 /home/jjzb/redis 目录所以要重命名下。
[jjzb@localhost ~]$ cd redis
[jjzb@localhost ~]$make
[jjzb@localhost ~]$ make MALLOC=libc
[jjzb@localhost ~]$ make test #测试安装,没有报错就可以安装了
修改守护进程模式和绑定ip:[jjzb@localhost ~]$ vi /home/jjzb/redis/redis.conf
修改:daemonize no
为
daemonize yes
bind 127.0.0.1
为
bind 0.0.0.0 #本机所有可用ip(根据情况绑定)
maxmemory 6442450944 #限制最大内存6G
requirepass 123456 # 123456为访问redis密码
[root@localhost ~]# cp /home/jjzb/redis/src/redis-trib.rb /usr/local/bin/
[root@localhost ~]# cp /home/jjzb/redis/src/redis-cli /usr/local/bin/
[root@localhost ~]# cp /home/jjzb/redis/src/redis-server /usr/local/bin/
[root@localhost ~]# chown jjzb.jjzb /usr/local/bin/redis*
或[jjzb@localhost ~]$/home/jjzb/redis/src/redis-server /home/jjzb/redis/redis.conf #启动
[jjzb@localhost ~]$redis-server /home/jjzb/redis/redis.conf
vi /etc/rc.local
或
vi /etc/rc.d/rc.local
su - jjzb -c "redis-server /home/jjzb/redis/redis.conf"
[jjzb@localhost ~]$redis-cli
127.0.0.1:6379> set foo bar
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> keys * #查询所有
1) "foo"