Redis 全稱:Remote Dictionary Server(遠程字典服務器),是徹底開源免費的,用C語言編寫的,遵照BSD協議,是一個高性能的(key/value)分佈式內存數據庫,基於內存運行並支持持久化的NoSQL數據庫,是當前最熱門的NoSql數據庫之一,也被人們稱爲數據結構服務器。redis
官方網站
https://redis.io
http://www.redis.cn
Redis 與其餘 key - value 緩存產品有如下三個特色docker
Docker 方式安裝 redis 是很是推薦的方式,易於維護。
Redis 鏡像官網:https://hub.docker.com/_/redis/數據庫
執行命令:docker pull redis
,等待鏡像下載成功。後端
~ docker pull redis Using default tag: latest latest: Pulling from library/redis 68ced04f60ab: Pull complete 7ecc253967df: Pull complete 765957bf98d4: Pull complete 91fff01e8fef: Pull complete 76feb725b7e3: Pull complete 75797de34ea7: Pull complete Digest: sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d Status: Downloaded newer image for redis:latest docker.io/library/redis:latest
~ docker run -itd --name local-redis -p 6379:6379 redis b26758de6935aa9f7ab7e85d19fac064fced84ced322f42359741467c4068fdc
~ docker logs -f local-redis 1:C 17 Mar 2020 10:17:22.157 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 17 Mar 2020 10:17:22.157 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 17 Mar 2020 10:17:22.157 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.8 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1:M 17 Mar 2020 10:17:22.161 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 17 Mar 2020 10:17:22.161 # Server initialized 1:M 17 Mar 2020 10:17:22.161 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 1:M 17 Mar 2020 10:17:22.161 * Ready to accept connections
出現上述日誌,即表示 Redis 安裝成功。瀏覽器
redis 自帶的命令行工具,所在目錄/usr/local/bin
緩存
進入到容器控制檯:bash
~ docker exec -it local-redis /bin/bash
連接 redis-cli 並使用 ping 命令:服務器
root@b26758de6935:~# /usr/local/bin/redis-cli 127.0.0.1:6379> ping PONG
官方網站: https://redisdesktop.com/
此工具在 Mac 上會使用高性能顯卡,比較費電,還有點卡,不推薦。
官方網站: https://redislabs.com/redisin...
推薦使用,控制檯是網頁,反正也要打開瀏覽器的,多開一個標籤頁也無所謂,並且顏值還不錯!
Redis 默認安裝目錄:
/usr/local/bin
首先查看下/usr/local/bin
目錄中的內容:數據結構
root@b26758de6935:~# ls -al /usr/local/bin/ total 24580 drwxr-xr-x 1 root root 4096 Mar 13 20:21 . drwxr-xr-x 1 root root 4096 Feb 24 00:00 .. -rwxrwxr-x 1 root root 374 Mar 13 20:20 docker-entrypoint.sh -rwxr-xr-x 1 root root 2294944 Oct 15 2018 gosu -rwxr-xr-x 1 root root 5940736 Mar 13 20:21 redis-benchmark lrwxrwxrwx 1 root root 12 Mar 13 20:21 redis-check-aof -> redis-server lrwxrwxrwx 1 root root 12 Mar 13 20:21 redis-check-rdb -> redis-server -rwxr-xr-x 1 root root 6484736 Mar 13 20:21 redis-cli lrwxrwxrwx 1 root root 12 Mar 13 20:21 redis-sentinel -> redis-server -rwxr-xr-x 1 root root 10424488 Mar 13 20:21 redis-server
下面對主要文件進行介紹:分佈式
歡迎收藏和轉發,感謝你的支持!(๑•̀ㅂ•́)و✧
歡迎關注我:後端小哥,專一後端開發,但願和你一塊兒進步!