Redis在3.0之前只有單機模式,並沒有叢集模式,所以這裡選擇2.8版本進行測試
搭建步驟:
1. 上傳解壓redis
root@hadoop01 ~]# mv redis-2.8.18 /opt/software/ (移動到軟體目錄好管理)
2. 下載gcc,tcl 命令編譯器 yum -y install gcc tcl (要使用redis伺服器必須得有一個叫做gcc的編譯器支援,還得有一個語言支援叫tcl)
3. 找到redis目錄下可以看到有個Makefile命令
(編譯、建立目錄、拷貝make && make PREFIX=/opt/software/redis install)
這個操作完成後,相當於把redis啟動程式拷貝到/opt/software/redis目錄下了
4. 配置redis環境變數
配置完記得重新載入
. /etc/profile
5. 安裝redis服務(/opt/software/redis-2.8.18/utils目錄下)
Welcome to the redis service installer
This script will help you easily set up a running redis server
# 如果不用預設配置 , 需要手動輸入連接埠號碼 , 我們這裡就用預設連接埠 ,按 按 Enter
Please select the redis port for this instance: [6379]
Selecting default: 6379
# 選擇預設的設定檔的名稱 ,按 按 Enter , 使用別的路徑和名稱需要手動指定
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
# 日誌存放位置,處理同上
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
# 持久化資料目錄 ,處理同上
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
# 指定 redis 的命令執行路徑,因為已經在環境變數中配置過,這裡不再做處理
Please select the redis executable path [/opt/sxt/redis/bin/redis-server]
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /opt/sxt/redis/bin/redis-server
Cli Executable : /opt/sxt/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort. # Enter
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
可以多次執行 install_server.sh 指令碼安裝不同連接埠下的 redis 服務
6. 啟動redis用戶端