redis的安裝(ubuntu版本)


1.使用apt-get命令進行安裝

安裝gcc依賴

root@yatces-virtual-machine:~# apt-get update

root@yatces-virtual-machine:~# apt-get install gcc

安裝redis-server

root@yatces-virtual-machine:~# apt-get install redis-server

安裝位置

 

root@yatces-virtual-machine:/etc# whereis redis
redis: /etc/redis
root@yatces-virtual-machine:/etc/redis# ll
total 76
drwxr-xr-x 6 root root 4096 8月 22 11:06 ./
drwxr-xr-x 131 root root 12288 8月 22 11:06 ../
-rw-r----- 1 redis redis 41623 12月 19 2015 redis.conf
drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.post-down.d/
drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.post-up.d/
drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.pre-down.d/
drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.pre-up.d/

啟動 redis

root@yatces-virtual-machine:~# redis-server  #如果修改為后台進程啟動方式:修改redis.conf 文件中的 daemonize no 為 yes

客戶端連接

root@yatces-virtual-machine:~# redis-cli
127.0.0.1:6379> set k1 helloworld
OK
127.0.0.1:6379> get k1
"helloworld"

卸載

使用命令:dpkg --list查看使用apt-get安裝的軟件

使用apt-get --purge remove 包名 移除軟件

安裝redis-server會安裝兩個包:redis-server 和 redis-tools,直接使用以上方式移除即可。

2.編譯安裝

在以下網址查找需要安裝的版本地址

http://download.redis.io/releases/

下載並解壓redis

root@yatces-virtual-machine:/usr/local/soft# wget http://download.redis.io/releases/redis-3.2.6.tar.gz
root@yatces-virtual-machine:/usr/local/soft# tar -zxvf redis-3.2.6.tar.gz

進入redis目錄編譯、安裝

root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# make&& make install

安裝完后,在/usr/local/bin目錄中會生成一個redis-server啟動命令

將 redis.conf 復制到 /etc/redis/ 目錄下,順便將redis.conf幾個配置修改(便於遠程客戶端連接)

bind 127.0.0.1 ==》 bind 0.0.0.0  
protected-mode no
daemonize yes

啟動redis

root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# /usr/local/bin/redis-server /etc/redis/redis.conf

客戶端連接redis

root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# /usr/local/bin/redis-cli 

停止redis服務,在客戶端使用 shutdown 命令,退出客戶端使用 exit 命令

127.0.0.1:6379> shutdown
not connected> exit

卸載redis

只需把/usr/local/bin/目錄下的redis刪除即可

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM