1. 程式人生 > >一、Redis安裝

一、Redis安裝

一、Redis介紹     Redis 是用C語言開發的一個開源的高效能鍵值對資料庫。它通過提供多種鍵值對資料型別來適應不同場景下的儲存需求,目前Redis支援的鍵值資料型別如下:
  •  字串型別
  • 雜湊型別
  • 列表型別
  • 集合型別
  • 有序集合型別
二、安裝

下載地址:wget http://download.redis.io/releases/redis-4.0.9.tar.gz

1、將安裝包上傳到linux alt+p//進入sftp模式進行上傳 put G:/redis-3.0.0.tar.gz

2、進行編譯,編譯依賴於gcc環境,所以先安裝gcc環境 yum install gcc-c++ 3、解壓軟體 tar -zxvf redis-3.0.0.tar.gz 4、進入資料夾然後執行make進行編譯 cd redis-3.0.0 make 5、安裝 make PREFIX=/redis install 6、檢視bin檔案
redis-benchmark 效能測試工具
redis-check-dump RDB檔案檢查工具
redis-check-aof AOF檔案修復工具
redis-cli 命令列客戶端
redis-server redis伺服器啟動命令
7、copy 配置檔案 [[email protected] redis-3.0.0]# cp redis.conf /redis/ [
[email protected]
redis-3.0.0]# cd /redis/ [[email protected] redis]# ls bin  redis.conf 三、Redis的啟動模式 1、前端啟動模式     直接執行bin/redis-server啟動前端模式,該方式的缺點是啟動完成後,不能再進行其他操作,如果要進行只能ctrl+C,同時redis-server也被停止 2、後端模式 修改redis.conf配置檔案,修改第37行daemonize yes 3、每次啟動指定配置檔案 [
[email protected]
redis]# ls bin  redis.conf [[email protected] redis]# bin/redis-server redis.conf [[email protected] redis]# ps -ef |grep -i redis root      3163     1  0 04:51 ?        00:00:00 bin/redis-server *:6379     root      3169  2739  0 04:51 pts/0    00:00:00 grep -i redis
繫結ip方式連線

連線後面加上-h 192.168.10.110 ./bin/redis-cli -h 192.168.10.110
4、停止服務 ./bin/redis-cli shutdown 四、測試 1、向Redis服務傳送命令 [[email protected] redis]# ./bin/redis-cli 127.0.0.1:6379> ping PONG 127.0.0.1:6379> 2、設定獲取及刪除資料 127.0.0.1:6379> set name tom OK 127.0.0.1:6379> get name "tom" 127.0.0.1:6379> del name (integer) 1