Redis之在Linux下安裝

Redis的安裝

Redis是c語言開發的。

安裝redis需要c語言的編譯環境。如果沒有gcc需要在線安裝。yum install gcc-c++

安裝步驟:

第一步:redis的源碼包上傳到linux系統。redis-3.0.0.tar.gz

第二步:解壓縮redis。tar -zxvf redis-3.0.0.tar.gz

第三步:編譯。進入redis源碼目錄。cd redis-3.0.0/

make

第四步:安裝。make install PREFIX=/usr/local/redis

PREFIX參數指定redis的安裝目錄。一般軟件安裝到/usr目錄下

 

redis的啓動:

前端啓動:在redis的安裝目錄下直接啓動redis-server

[root@localhost bin]# ./redis-server

後臺啓動:把/root/redis-3.0.0/redis.conf複製到/usr/local/redis/bin目錄下

修改配置文件:

################################ GENERAL  #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.

 

[root@localhost bin]# ./redis-server redis.conf

查看redis進程:

[root@localhost bin]# ps aux|grep redis

root      5190  0.1  0.3  33936  1712 ?        Ssl  18:23   0:00 ./redis-server *:6379    

root      5196  0.0  0.1   4356   728 pts/0    S+   18:24   0:00 grep redis

 

redis的關閉:

[root@localhost bin]# ./redis-cli shutdown或者kill + redis所使用的端口號【溫柔正常關閉】、kill -9 + redis所使用的端口號【強制殺死】

默認連接localhost運行在6379端口的redis服務。

[root@localhost bin]# ./redis-cli -h 192.168.25.153 -p 6379

-h:連接的服務器的地址

-p:服務的端口號

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章