Centos 6.9 安裝 Redis 3.2.9,centosredis
依賴包和常用包
yum install gcc gcc-c++ make zlib-devel readline readline-devel tkutil tk tkutil-devel tk-devel openssl openssl-devel wget vim ntp -y
下載redis
wget http://download.redis.io/releases/redis-3.2.9.tar.gz
解壓redis
tar -zxvf redis-3.2.9.tar.gz
重新命名redis
mv redis-3.2.9 /usr/local/redis
編譯安裝redis
cd /usr/local/redis
make & make install
建立連接埠
cd /usr/local/redis/utils
sh ./install_server.sh
6379
一直Enter
修改串連IP
vi /etc/redis
62 bind IP
redis 目錄結構
/usr/local/redis
/etc/redis
/var/lib/redis
redis 開機自啟動(3.2.9預設預設有啟動指令碼/etc/init.d)
chkconfig --add redis_6379
chkconfig redis_6379 on
連接埠狀態查看
ps -ef|grep 6379
netstat -lntp | grep 6379
測試
redis-cli -h ip -p 6379
———————————————————————————————————————————————————————————————————————————————
編譯(make)時:
(1)若出現如下提示,則說明未安裝gcc,使用命令安裝gcc:yum install gcc
[root@localhost redis-2.8.17]# makecd src && make allmake[1]: Entering directory `/root/redis-2.8.17/src‘ CC adlist.o/bin/sh: cc: command not foundmake[1]: *** [adlist.o] Error 127make[1]: Leaving directory `/root/redis-2.8.17/src‘make: *** [all] Error 2
(2)若出現如下提示,則將make改為make MALLOC=libc,推測是因為編譯庫的問題。
[root@localhost redis-2.8.17]# makecd src && make allmake[1]: Entering directory `/root/redis-2.8.17/src‘ CC adlist.oIn file included from adlist.c:34:zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: #error "Newer version of jemalloc required"make[1]: *** [adlist.o] Error 1make[1]: Leaving directory `/root/redis-2.8.17/src‘make: *** [all] Error 2
5. 安裝編譯後的檔案:make install,redis可執行檔將被複製到/usr/local/bin/,但沒有配置,手動複製配置:cp redis.conf /usr/local/bin
6. 設定Redis密碼,編輯剛剛複製的設定檔:vi redis.conf,解除requirepass參數的注釋,並設定值,例如:requirepass ljx520
7. 使用設定檔啟動Redis資料庫:./redis-server redis.conf
如果看到如下的介面,那麼恭喜你,Redis已安裝成功