linux下redis安装和使用
一、安装下载地址 http://redis.io/download
或者 直接wget http://download.redis.io/releases/redis-2.8.4.tar.gz
tar xzvf redis-2.8.4.tar.gz
cd / redis-2.8.4
make && make install
二、启动
cd /redis-2.8.4/bin
./redis-server --port 9999
控制台出现如下提示信息:
16 Jan 15:30:32.946 # Unable to set the max number of files limit to 10032 (Operation not permitted), setting the max clients configuration to 992.
_._
_.-``__ ''-._
_.-`` `.`_.''-._ Redis 2.8.4 (00000000/0) 64 bit
.-`` .-```.```\/ _.,_ ''-._
( ' , .-`| `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 9999
| `-._ `._ / _.-' | PID: 31726
`-._ `-._`-./_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
16 Jan 15:30:32.955 # Server started, Redis version 2.8.4
16 Jan 15:30:32.955 * The server is now ready to accept connections on port 9999
三、测试
进入Redis安装目录的bin子目录。
./redis-cli -h 127.0.0.1 -p 9999
127.0.0.1:9999> ping
PONG
127.0.0.1:9999> set name zhang
OK
127.0.0.1:9999> get name
"zhang"
三、测试:
存值:
./redis-cli set hx value
取值:
./redis-cli get hx
> quit
退出连接
> dbsize
(integer) 12
当前数据库中key的数量
> info
服务器基本信息
monitor
实时转储收到的请求
config get
获取服务器的参数配置
flushdb
清空当前数据库
flushall
清除所有数据库 注意上面的最后一行,我们通过PREFIX指定了安装的目录。如果make失败,一般是你们系统中还未安装gcc,那么可以通过yum安装:
yum install gcc
页:
[1]