如何在liunx部署redis
下載
所有版本的下載地址:http://download.redis.io/releases/
先安裝下載工具:wget
yum install –y wget
wget http://download.redis.io/releases/redis-3.2.7.tar.gz
解壓縮
tar –zxvf redis-3.2.7.tar.gz
編譯
前提條件:需要gcc編譯器
yum install –y gcc-c++
make
如果報錯,加參數再執行make
make MALLOC=libc
安裝
可以指定安裝的路徑:
make install PREFIX=/usr/local/redis
啟動服務
執行這個文件就可以!
./redis-server
退出:ctrl+c
指定配置文件啟動服務
舉例:以守護進程方式啟動
需要指定一個配置文件
可以復制解壓縮文件裏的redis.conf文件(/root/redis-3.2.9/redis.conf)
創建一個目錄保存配置文件
mkdir /usr/local/redis/conf
復制到創建的目錄下
cp /root/redis-3.2.9/redis.conf /usr/local/redis/conf/
進入該目錄:
cd /usr/local/redis/conf/
修改redis.conf文件
vi redis.conf
啟動服務為守護進程
./redis-server ../conf/redis.conf
查看進程:
[[email protected] bin]# ps aux | grep redis root 4284 0.1 0.1 30000 1868 ? Ssl 10:51 0:00 ./redis-server 127.0.0.1:6379 root 4288 0.0 0.0 4360 764 pts/0 S+ 10:53 0:00 grep redis |
使用自帶的客戶端連接服務
./redis-cli
退出客戶端:
quit
關閉服務:
[[email protected] bin]# ./redis-cli shutdown
開機自啟動
vi /etc/rc.local
添加一行:
/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
可以重啟系統: reboot測試是否能開機自啟動!!
Redis客戶端
Redis-cli 命令行
Redis-desktop-manage 圖形化
官網:https://redisdesktop.com/
下載頁面:https://redisdesktop.com/download
安裝就是下一步即可!!
打開軟件:配置需要連接的服務器 (But 但是連接不上 是不是,需要開起防火墻)
連接失敗的原因:為在服務器開啟端口
1, 開啟服務器的防火墻vi /etc/sysconfig/iptables
2, 開起端口號 6379
3, 重啟防火墻:[[email protected] bin]# service iptables restart
4, Redis的配置文件裏需要綁定實際的ip地址
5, 重啟redis服務器:
[[email protected] bin]# ./redis-cli shutdown
[[email protected] bin]# ./redis-server redis.conf
連接成功
如何在liunx部署redis