正如我們所知的那樣,Redis是一個開源的、基于BSD許可證的,基于內(nèi)存的、鍵值存儲NoSQL數(shù)據(jù)庫。Redis經(jīng)常被視為一個數(shù)據(jù)結(jié)構(gòu)服務(wù)器,因為Redis支持字符串strings、哈希hashes、列表lists、集合sets、有序集sorted sets等數(shù)據(jù)結(jié)構(gòu)。Redis還支持像事務(wù)Transitions、發(fā)布和訂閱這樣的數(shù)據(jù)類型。有鑒于此,Redis經(jīng)常被認(rèn)為是更強(qiáng)大的Memcache。
本文主要講述Redis在CentOS 7環(huán)境下的安裝有什么不同。假定CentOS 7 Server已經(jīng)就緒。
1、啟用EPEL倉庫
## RHEL/CentOS 7 64-Bit ### wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm# rpm -ivh epel-release-7-5.noarch.rpm
要驗證EPEL倉庫是否建立成功,可以執(zhí)行:
# yum repolist
2、通過Yum安裝Redis
# yum -y update# yum install redis php-pecl-redis
把Redis添加到開機(jī)啟動服務(wù)中:
# systemctl start redis-server.service# systemctl enable redis-server.service
檢查Redis是否運(yùn)行:
# systemctl is-active redis-server.service
3、安裝Redis的Web管理客戶端
phpRedisAdmin是一個免費(fèi)開源的RedisWeb管理客戶端,它提供了一個簡單的界面來實現(xiàn)對Redis數(shù)據(jù)庫的管理。
# git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git# cd phpRedisAdmin/includes# cp config.sample.inc.php config.inc.php
要確保配置正確:
# nano config.inc.php
再把RedisAdmin配置文件添加到Apache服務(wù)器,文件的內(nèi)容如下:
### nano /etc/httpd/conf.d/redisadmin.conf### Now add the following ##### Web Interface for RedisAdmin# <Directory "/downloads/phpRedisAdmin/"> Order Deny,Allow Deny from all Allow from 127.0.0.1 Allow from <your ipaddress></Directory>Alias /redisAdmin /downloads/phpRedisAdminAlias /redisadmin /downloads/phpRedisAdmin
創(chuàng)建一個Bash腳本來確保Redis的正常運(yùn)行,內(nèi)容如下:
### nano /scripts/redis-check.sh#!/bin/bashPS=$(which ps)GREP=$(which grep)WHEN=$(date +"%Y-%m-%d-%H:%M:%S") if ! $PS aux | $GREP "redis.conf" | $GREP -v grep 2>&1 > /dev/null; then /etc/init.d/redis restart echo 'Restarted Redis @' $WHEN fi#Check Second instance if ! $PS aux | $GREP "redis2.conf" | $GREP -v grep 2>&1 > /dev/null; then /etc/init.d/redis2 restart echo 'Restarted Redis2 @' $WHEN fi
確保腳本是可執(zhí)行的:
# chmod +x /scripts/redis-check.sh
通過定時器cron來保證腳本的執(zhí)行,每3分鐘運(yùn)行一次:
### nano /var/spool/cron/root*/3 * * * * /bin/bash /script/redis-check.sh >> /var/log/redis-check.log
OK,至此完工。
原文鏈接:http://blog.csdn.net/chszs/article/details/51925378
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答
圖片精選