redis的安裝及配置

來源:互聯網
上載者:User

安裝Redis

  下載並編譯Redis

這裡推薦使用編譯源碼的方式來進行安裝,安裝redis之前先要確認系統已經安裝了GCC和libc庫。下載redis源碼,可以在redis.io自行下載指定版本的redis,也可以通過網址http://download.redis.io/redis-stable.tar.gz下載最新穩定版源碼,下載後就可對源碼進行編譯。

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make

  編譯完成以後,Redis目錄下的src目錄中存放了Redis的可執行程式,其中:

  • redis-server Redis服務系統
  • redis-cli redis一個用戶端管理工具
  • redis-benchmark 用來檢測redis效能
  • redis-check-aof and redis-check-dump 用來處理損壞的資料檔案
為了方便起見,可以將redis-server和redis-cli拷貝到bin檔案夾下
sudo cp redis-server /usr/local/bin/
sudo cp redis-cli /usr/local/bin/

  啟動Redis服務

$ redis-server 
[28550] 01 Aug 19:29:28 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[28550] 01 Aug 19:29:28 * Server started, Redis version 2.2.12
[28550] 01 Aug 19:29:28 * The server is now ready to accept connections on port 6379
... and so forth ...

  上面的命令啟動了沒有附帶任何配置資訊的服務,所有的配置資訊將使用reids的預設配置。

  可以通過在redis-server命令後附加上設定檔的絕對路徑,即可啟用設定檔的設定,如:

redis-server /etc/redis.conf

Redis設定檔預設存放在redis檔案夾下,名為redis.conf,可以將該檔案作為配置模版複製到root目錄下。

Redis 服務端的預設串連連接埠是 6379。

  將Redis作為 Linux 服務隨機啟動

  vi /etc/rc.local, 使用vi編輯器開啟隨機啟動設定檔,並在其中加入下面一行代碼。

/root/4setup/redis-2.4.7/src/redis-server

  用戶端串連驗證

  可以通過redis內建的redis-cli用戶端程式連結到redis伺服器,如果返回PONG,則說明服務啟動成功

$ redis-cli ping 
PONG

  也可以通過另外一種不附帶參數的方式驗證

$ redis-cli                                                                
redis 127.0.0.1:6379> ping
PONG

  停止Redis執行個體

  最簡單的方法是在啟動執行個體的session中,直接使用Control-C來將執行個體停止。

  我們還可以用用戶端來停止服務,如可以用shutdown來停止Redis執行個體, 具體如下:

$ src/redis-cli shutdown

 #關閉指定連接埠的redis-server

 $redis-cli -p 6380 shutdown

redis圖形介面管理工具phpMyRedis  https://github.com/colummcgaley/phpMyRedis 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.