centos7上安裝redis

關閉防火牆:html

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 的配置信息
一、daemonize 若是須要在後臺運行,把該項改成yes
二、pidfile 配置多個pid的地址 默認在/var/run/redis.pid
三、bind 綁定ip,設置後只接受來自該ip的請求
四、port 監聽端口,默認是6379
五、loglevel 分爲4個等級:debug verbose notice warning
六、logfile 用於配置log文件地址
七、databases 設置數據庫個數,默認使用的數據庫爲0
八、save 設置redis進行數據庫鏡像的頻率。
九、rdbcompression 在進行鏡像備份時,是否進行壓縮
十、dbfilename 鏡像備份文件的文件名
十一、Dir 數據庫鏡像備份的文件放置路徑
十二、Slaveof 設置數據庫爲其餘數據庫的從數據庫
1三、Masterauth 主數據庫鏈接須要的密碼驗證
1四、Requriepass 設置 登錄時須要使用密碼
1五、Maxclients 限制同時使用的客戶數量
1六、Maxmemory 設置redis可以使用的最大內存
1七、Appendonly 開啓append only模式
1八、Appendfsync 設置對appendonly.aof文件同步的頻率(對數據進行備份的第二種方式)
1九、vm-enabled 是否開啓虛擬內存支持 (vm開頭的參數都是配置虛擬內存的)
20、vm-swap-file 設置虛擬內存的交換文件路徑
2一、vm-max-memory 設置redis使用的最大物理內存大小
2二、vm-page-size 設置虛擬內存的頁大小
2三、vm-pages 設置交換文件的總的page數量
2四、vm-max-threads 設置VM IO同時使用的線程數量
2五、Glueoutputbuf 把小的輸出緩存存放在一塊兒
2六、hash-max-zipmap-entries 設置hash的臨界值
2七、Activerehashing 從新hashc++

源地址:https://www.cnblogs.com/web424/p/6796993.htmlweb

相關文章
相關標籤/搜索