--- title: Redis 學習記錄 --- ###### tags: `infrastructure` # Redis 學習記錄 1. SpringBoot 使用redis並實現cache機制: https://www.tpisoftware.com/tpu/articleDetails/ 2021/9/22: 聖哥的安裝紀錄 ``` //redis 密碼 /etc/redis/redis.conf 127.0.0.1:6379 //停用 sudo /etc/init.d/redis-server stop //啟用 sudo /etc/init.d/redis-server start //驗證 ubuntu@ip-172-31-16-219:~/kafka_2.11-0.11.0.0$ redis-cli 127.0.0.1:6379> AUTH PASSWORD (error) ERR Client sent AUTH, but no password is set 127.0.0.1:6379> CONFIG SET requirepass "39af0d0a269423fc" OK 127.0.0.1:6379> AUTH amolpass (error) ERR invalid password 127.0.0.1:6379> AUTH 39af0d0a269423fc OK 127.0.0.1:6379> // ubuntu@ip-172-31-16-219:/wwwroot/backend/cmd/app-api$ go run main.go [xorm] [info] 2021/09/22 09:17:02.795211 PING DATABASE postgres {"level":"warn","caller":"/wwwroot/backend/initialize/kafka.go:10","time":"2021-09-22T09:17:02Z","message":"kafka未配置"} ``` ## 常用操作 ### list key keys * keys match_live* ### get key get key hget key lget key... get遇到錯誤訊息: WRONGTYPE Operation against a key holding the wrong kind of value --- 物件類型與使用的get類型不一致。 先確認key 類型: type key ### delete 模糊刪除: redis-cli KEYS "match_live:text*" | xargs redis-cli DEL 模糊刪除 - auth: redis-cli -a '1q2w3e4r..A' KEYS "match_live:inde*" | xargs redis-cli -a '1q2w3e4r..A' DEL ### rename key rename [key] [newkey] ### Redis中存储value中文显示问题 解决方法: 启动redis-cli时,在其后面加上–raw即可,汉字即可显示正常。 [root@localhost redis]# ./bin/redis-cli --raw 127.0.0.1:6379> get China 中国 ## Bloom 介紹文章: https://juejin.cn/post/7058445741097746462 https://blog.csdn.net/qq_41125219/article/details/119982158 linux 安裝配置: https://www.cnblogs.com/simple-record/p/13608210.html docker : [docker hub ](https://hub.docker.com/r/redislabs/rebloom/) cmd: https://github.com/RedisBloom/redisbloom-go#supported-redisbloom-commands cmd 說明: https://redis.io/commands/?group=module 參數說明: https://www.cnblogs.com/shoshana-kong/p/14759439.html ## 遠端連線 $ redis-cli -h host -p port -a password ### version 在服務器: redis-server -v 在redis-cli: info ## 報錯修正 ### connect to redis failed, MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk ## 集群 ##### 集群查keys: ``` redis-cli -c --cluster call 127.0.0.1:6378 keys \match_live:te* ``` addr 換成集群其中一個節點addr
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up