共計 1529 個字符,預計需要花費 4 分鐘才能閱讀完成。
這篇文章主要介紹了 Ubuntu 安裝并配置 redis 的方法是什么的相關知識,內容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇 Ubuntu 安裝并配置 redis 的方法是什么文章都會有所收獲,下面我們一起來看看吧。
使用命令行更新所有的軟件包
sudo apt-get update
###### 在 Linux Ubuntu 中安裝 Redis 數據庫
```LINUX
#安裝 Redis 服務器端
~ sudo apt-get install redis-server
安裝完成后,Redis 服務器會自動啟動,我們檢查 Redis 服務器程序
# 檢查 Redis 服務器系統進程
~ ps -aux|grep redis
redis 4162 0.1 0.0 10676 1420 ? Ss 23:24 0:00 /usr/bin/redis-server /etc/redis/redis.conf
conan 4172 0.0 0.0 11064 924 pts/0 S+ 23:26 0:00 grep --color=auto redis
# 通過啟動命令檢查 Redis 服務器狀態
~ netstat -nlt|grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
# 通過啟動命令檢查 Redis 服務器狀態
~ sudo /etc/init.d/redis-server status
redis-server is running
通過命令行客戶端訪問 Redis
安裝 Redis 服務器,會自動地一起安裝 Redis 命令行客戶端程序。
在本機輸入 redis-cli 命令就可以啟動,客戶端程序訪問 Redis 服務器。
~ redis-cli
redis 127.0.0.1:6379
# 命令行的幫助
redis 127.0.0.1:6379 help
redis-cli 2.2.12
Type: help @ to get a list of commands in
help for help on
help to get a list of possible help topics
quit to exit
redis 127.0.0.1:6379 keys *
(empty list or set)
修改 Redis 的配置
默認情況下,訪問 Redis 服務器是不需要密碼的,為了增加安全性我們需要設置 Redis 服務器的訪問密碼。設置訪問密碼為 redisredis。
用 vi 打開 Redis 服務器的配置文件 redis.conf
~ sudo vi /etc/redis/redis.conf
#取消注釋 requirepass
requirepass redisredis
讓 Redis 服務器被遠程訪問
~ sudo vi /etc/redis/redis.conf
#注釋 bind
#bind 127.0.0.1
修改后,重啟 Redis 服務器。
~ sudo /etc/init.d/redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.
我們檢查 Redis 的網絡監聽端口
檢查 Redis 服務器占用端口
~ netstat -nlt|grep 6379
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
關于“Ubuntu 安裝并配置 redis 的方法是什么”這篇文章的內容就介紹到這里,感謝各位的閱讀!相信大家對“Ubuntu 安裝并配置 redis 的方法是什么”知識都有一定的了解,大家如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道。
正文完