ubuntu 安裝 redis server
sudo apt update
sudo apt install redis-server
The following NEW packages will be installed:libhiredis0.14 libjemalloc2 liblua5.1-0 lua-bitop lua-cjson redis-server redis-tools
sudo systemctl start redis-server
sudo systemctl enable redis-server
sudo systemctl status redis-server
sudo vi /etc/redis/redis.conf
bind 0.0.0.0 ::1
protected-mode no
sudo service redis-server restart
命令即可。
測試:
sudo apt install redis-tools
redis-cli -h 192.168.xx.xxx
客戶端安裝后,就可以通過redis-cli命令遠程連接到redis服務器了
二、服務端安裝
1、suao apt install redis
2、redis-server -v
3、ss -nlt 默認端口6379
sudo systemctl disable redis-server
sudo systemctl enable redis-server
默認redis服務器監聽地址為127.0.0.1 如果需要修改,配置文件在/etc/redis/redis.conf。
將bind 127.0.0.1 ::1 這行注釋掉。
然后,如果需要遠程連接redis,需要關閉保護模式。
修改protected-mode yes 為 no
修改后,需要重啟啟動redis服務器
service redis-server restart
1
# Redis數據庫索引(默認為0)
spring.redis.database=0
# Redis服務器地址
spring.redis.host=127.0.0.1
# Redis服務器連接端口
spring.redis.port=6379
# Redis服務器連接密碼(默認為空)
spring.redis.password=
# 連接池最大連接數(使用負值表示沒有限制)
spring.redis.lettuce.pool.max-active=8
# 連接池最大阻塞等待時間(使用負值表示沒有限制)
spring.redis.lettuce.pool.max-wait=-1ms
# 連接池中的最大空閑連接
spring.redis.lettuce.pool.max-idle=8
# 連接池中的最小空閑連接
spring.redis.pool.min-idle=0