centos7安裝redis

來源:互聯網
上載者:User

關閉防火牆:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
firewall-cmd --state #查看預設防火牆狀態(關閉後顯示notrunning,開啟後顯示running)
配置編譯環境:
sudo yum install gcc-c++
下載源碼:
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
解壓源碼:
tar -zxvf redis-3.2.8.tar.gz
進入到解壓目錄:
cd redis-3.2.8
執行make編譯Redis:
make MALLOC=libc
注意:make命令執行完成編譯後,會在src目錄下產生6個可執行檔,分別是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-rdb、redis-sentinel。
安裝Redis:
make install 
配置Redis能隨系統啟動:
./utils/install_server.sh
顯示結果資訊如下:
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
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
Please select the redis executable path [/usr/local/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     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
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!

Redis服務查看、開啟、關閉:
a.通過ps -ef|grep redis命令查看Redis進程
b.開啟Redis服務作業通過/etc/init.d/redis_6379 start命令,也可通過(service redis_6379 start)
c.關閉Redis服務作業通過/etc/init.d/redis_6379 stop命令,也可通過(service redis_6379 stop)

redis.conf 的配置資訊
1、daemonize 如果需要在後台運行,把該項改為yes
2、pidfile 配置多個pid的地址 預設在/var/run/redis.pid
3、bind 綁定ip,設定後只接受來自該ip的請求
4、port 監聽連接埠,預設是6379
5、loglevel 分為4個等級:debug verbose notice warning
6、logfile 用於配置log檔案地址
7、databases 設定資料庫個數,預設使用的資料庫為0
8、save 設定redis進行資料庫鏡像的頻率。
9、rdbcompression 在進行鏡像備份時,是否進行壓縮
10、dbfilename 鏡像備份檔案的檔案名稱
11、Dir 資料庫鏡像備份的檔案放置路徑
12、Slaveof 設定資料庫為其他資料庫的從資料庫
13、Masterauth 主要資料庫串連需要的密碼驗證
14、Requriepass 設定 登陸時需要使用密碼
15、Maxclients 限制同時使用的客戶數量
16、Maxmemory 設定redis能夠使用的最大記憶體
17、Appendonly 開啟append only模式
18、Appendfsync 設定對appendonly.aof檔案同步的頻率(對資料進行備份的第二種方式)
19、vm-enabled 是否開啟虛擬記憶體支援 (vm開頭的參數都是配置虛擬記憶體的)
20、vm-swap-file 設定虛擬記憶體的分頁檔路徑
21、vm-max-memory 設定redis使用的最大實體記憶體大小
22、vm-page-size 設定虛擬記憶體的頁大小
23、vm-pages 設定分頁檔的總的page數量
24、vm-max-threads 設定VM IO同時使用的線程數量
25、Glueoutputbuf 把小的輸出緩衝存放在一起
26、hash-max-zipmap-entries 設定hash的臨界值
27、Activerehashing 重新hash

177 # dbid is a number between 0 and 'databases'-1 178 databases 16

在redis資料庫設定檔中發現redis有16個庫,查看進程的方法ps -ef|grep 加apache或者redis

ps -ef|grep redisroot     11646     1  0 00:48 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379root     12019 10530  0 01:03 pts/0    00:00:00 grep --color=auto redis

 安裝完我的redis目錄在:user/local/bin

按著這個教程安裝成功,尊重作者:http://www.cnblogs.com/web424/p/6796993.html

這裡只是安裝redis服務,還需要PHP開啟redis擴充,讓PHP串連上redis,請看這裡 http://www.cnblogs.com/hanshuai0921/p/7092081.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.