在CentOS 7環境下安裝Redis資料庫詳解_Redis

來源:互聯網
上載者:User

正如我們所知的那樣,Redis是一個開源的、基於BSD許可證的,基於記憶體的、KVStore for RedisNoSQL資料庫。Redis經常被視為一個資料結構伺服器,因為Redis支援字串strings、雜湊hashes、列表lists、集合sets、有序集sorted sets等資料結構。Redis還支援像事務Transitions、發布和訂閱這樣的資料類型。有鑒於此,Redis經常被認為是更強大的Memcache。

本文主要講述Redis在CentOS 7環境下的安裝有什麼不同。假定CentOS 7 Server已經就緒。

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倉庫是否建立成功,可以執行:

# yum repolist

2、通過Yum安裝Redis

# yum -y update# yum install redis php-pecl-redis

把Redis添加到開機啟動服務中:

# systemctl start redis-server.service# systemctl enable redis-server.service

檢查Redis是否運行:

# systemctl is-active redis-server.service

3、安裝Redis的Web管理用戶端

phpRedisAdmin是一個免費開源的RedisWeb管理用戶端,它提供了一個簡單的介面來實現對Redis資料庫的管理。

# 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伺服器,檔案的內容如下:

### 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

建立一個Bash指令碼來確保Redis的正常運行,內容如下:

### 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

確保指令碼是可執行檔:

# chmod +x /scripts/redis-check.sh

通過定時器cron來保證指令碼的執行,每3分鐘運行一次:

### 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

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援雲棲社區。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.