Redis 简单搭建
2024-10-12 18:46:12
======== redis ======== 1. redis setup and test : 1. download the package from https://redis.io/download 2. compile source code:
tar xzf redis-3.2.5.tar.gz
cd redis-3.2.5
make 3. start redis server :
[dy83694@retailvm1d redis-3.2.5]$ src/redis-server
28855:C 05 Dec 00:53:54.476 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
..
28855:M 05 Dec 00:53:54.485 * The server is now ready to accept connections on port 6379 4. test redis :
[dy83694@retailvm1d redis-3.2.5]$ src/redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> 5. Data type in redis :
1) String :
redis 127.0.0.1:6379> SET name "yiibai"
OK
redis 127.0.0.1:6379> GET name
"yiibai"
2) HashMap :
redis 127.0.0.1:6379> HMSET user:1 username yiibai password yiibai points 200
OK
redis 127.0.0.1:6379> HGETALL user:1
1) "username"
2) "yiibai"
3) "password"
4) "yiibai"
5) "points"
6) "200"
3) List (1. The max size = 2^32 -1 = 4294967295 ; 2. sort by insert sequence)
redis 127.0.0.1:6379> lpush tutoriallist redis
(integer) 1
redis 127.0.0.1:6379> lpush tutoriallist mongodb
(integer) 2
redis 127.0.0.1:6379> lpush tutoriallist rabitmq
(integer) 3
redis 127.0.0.1:6379> lrange tutoriallist 0 10
1) "rabitmq"
2) "mongodb"
3) "redis"
4) Set (delete and test : o(1))
redis 127.0.0.1:6379> sadd tutoriallist redis
(integer) 1
redis 127.0.0.1:6379> sadd tutoriallist mongodb
(integer) 1
redis 127.0.0.1:6379> sadd tutoriallist rabitmq
(integer) 1
redis 127.0.0.1:6379> sadd tutoriallist rabitmq
(integer) 0
redis 127.0.0.1:6379> smembers tutoriallist
1) "rabitmq"
2) "mongodb"
3) "redis" 6. Redis HyperLogLog : calculate the count of element
redis 127.0.0.1:6379> PFADD tutorials "redis"
redis 127.0.0.1:6379> PFCOUNT tutorials
(integer) 3 7. subscribe and publish message
client 1 : redis 127.0.0.1:6379> SUBSCRIBE redisChat
client 2 : redis 127.0.0.1:6379> PUBLISH redisChat "Redis is a great caching technique" 8. transaction
redis 127.0.0.1:6379> MULTI
OK
List of commands here
redis 127.0.0.1:6379> EXECs 9. Redis script
redis 127.0.0.1:6379> EVAL script numkeys key [key ...] arg [arg ...] 10. Redis Connect between server and client
redis 127.0.0.1:6379> AUTH "password"
OK
redis 127.0.0.1:6379> PING
PONG 11. Redis backup ( dump.rdb in the redis directory )
1) backup
127.0.0.1:6379> CONFIG get dir
1) "dir"
2) "/user/yiibai/redis-2.8.13/src"
127.0.0.1:6379> SAVE
or
127.0.0.1:6379> BGSAVE
Background saving started
2) recovery
copy the dump.rdb into redis directory and restart the redis server 12. redis security
1) client 1 :
127.0.0.1:6379> CONFIG set requirepass "redis"
OK
2) client 2 :
127.0.0.1:6379> CONFIG get requirepass
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth redis
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "redis" 13. redis performance test
src/redis-benchmark [option] [option value]
src/redis-benchmark -n 100000 14. Redis connect client
1. maxclients in redis.conf :
127.0.0.1:6379> config get maxclients
2. set maxclients = 100000 once server start
src/redis-server --maxclients 100000 15. Redis pipe 16. Redis Partition 2. Redis jedis test 1. java connection : JedisPool and Jedis
2. create redis slave :
src/redis-server --port 6380 --slaveof 127.0.0.1 6379 --masterauth "redis"
最新文章
- .NET中使用Redis
- 调用Interop.zkemkeeper.dll无法使用解决方案
- 【水】基于ege的简单3D模拟
- 【网络】ssl与ssh
- js计时器方法 setInterval(),setTimeout()
- 在JSP页面中输出字符"; * ";组成的金字塔
- MySQL分支Percona, cmake编译安装
- Spark Streaming 架构
- EffectiveC#18--用IComparable和IComparer实现对象的顺序关系
- java大数 斐波那契数列
- SAS︱操作语句(if、do、select、retain、array)、宏语言、统计量、运算符号
- POJ 1721 CARDS
- 使用SqlServer_Profiler跟踪慢查询
- linux 路由表 的一些相关资料
- vue实现原理
- 【转】【完全开源】微信客户端.NET版
- Delta DVP 系列 PLC 各装置 Modbus 地址
- Codeforces.618F.Double Knapsack(构造 鸽巢原理)
- Vue-cli3.0开发笔记
- 【转】Git版本控制软件从入门到精通学习手册
热门文章
- SQL 约束
- HTML5 程序设计 - 使用HTML5 Canvas API
- 完美解决CodeSmith无法获取MySQL表及列Description说明注释的方案
- 分布式中使用Redis实现Session共享(二)
- 客服小妹是如何泡到手的——C#定时提醒·语音录制·语音播放·文件转录Demo源码——倾情奉献!
- 巧用 mask-image 实现简单进度加载界面
- html5 audio总结
- 从Maya中把模型搬运至网页的过程
- Redola.Rpc 的一个小目标
- Team Leader 你不再只是编码, 来炖一锅石头汤吧