centos6.3下安装phpredisadmin,以及配置文件 http://wktdhe.blog.51cto.com/4764978/1144514
关于命令:
redis-cli 命令总结 http://www.178-go.com/archives/redis-cli-%E5%91%BD%E4%BB%A4%E6%80%BB%E7%BB%93.html
关于配置密码:
http://blog.csdn.net/zyz511919766/article/details/42268219
修改redis.conf
requirepass 12345
然后启动服务器
./redis-server ../redis.conf
登录
./redis-cli -h 127.0.0.1 -p 6379 -a 12345
几个命令:
keys * : 查看所有key信息
keys PANDY* : 查看所有PANDY开头的key
exists(key):确认一个key是否存在
del(key):删除一个key
type(key):返回值的类型
flushdb:删除当前选择数据库中的所有key
flushall:删除所有数据库中的所有key
安装测试
wget http://download.redis.io/releases/redis-2.8.24.tar.gz
tar xzf redis-2.8.24.tar.gz
cd redis-2.8.24
make
#启动服务器
cd src
./redis-server
#客户端链接测试
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
输出:
......
......
[18380] 03 May 21:02:31.295 * The server is now ready to accept connections on port 6379
表示安装成功
package com.pandy.test; import redis.clients.jedis.Jedis; /** * 项目名称: wp_idea_linux * 功能说明: * 创建者: Pandy, * 邮箱: [email protected], [email protected] * 版权: * 官网: * 创建日期: 15-5-11. * 创建时间: 下午12:55. * 修改历史: * ----------------------------------------------- */ /** * Redis的测试程序 */ public class RedisTest { public static void main(String[] args) { Jedis jedis = new Jedis("192.168.0.198",6379); jedis.auth("12345"); //如果有密码,则设定密码 jedis.set("foo", "这个是中文"); String value = jedis.get("foo"); System.out.println(value); } }
安装sh
#!/bin/bash # From here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ # Based on: https://github.com/saxenap/install-redis-amazon-linux-centos # Thanks to https://raw.github.com/gist/2776679/b4f5f5ff85bddfa9e07664de4e8ccf0e115e7b83/install-redis.sh # Uses redis-server init script from https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server ############################################### # To use: ## wget https://raw.github.com/jorgerc/install-redis-amazon-linux-centos/master/redis-install-script.sh ## chmod 777 redis-install-script.sh ## ./redis-install-script.sh ############################################### # Set up SO: #### yum -y update ln -sf /usr/share/zoneinfo/UTC /etc/localtime yum -y install gcc gcc-c++ make #### # Download and install Redis: #### version=2.8.12 wget -q http://download.redis.io/releases/redis-$version.tar.gz tar xzf redis-$version.tar.gz rm -f redis-$version.tar.gz cd redis-$version make make install #### # Set up Redis #### rm -rf /etc/redis /var/lib/redis mkdir /etc/redis /var/lib/redis cp src/redis-server src/redis-cli /usr/local/bin cp redis.conf /etc/redis sed -e "s/^daemonize no$/daemonize yes/" -e "s/^# bind 127.0.0.1$/bind 0.0.0.0/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel verbose$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf #### # Redis correctly installed. # Download script for running Redis #### wget -q https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server mv redis-server /etc/init.d chmod 755 /etc/init.d/redis-server chkconfig --add redis-server chkconfig --level 345 redis-server on #### # To start Redis just uncomment this line #### #service redis-server start