1. 程式人生 > >CentOS7下安裝Redis服務

CentOS7下安裝Redis服務

1、檢視Redis安裝源

yum search redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
==================================================================================== N/S matched: redis =====================================================================================
collectd-redis.x86_64 : Redis plugin for collectd
collectd-write_redis.x86_64 : Redis output plugin for collectd
hiredis.x86_64 : Minimalistic C client library for Redis
hiredis-devel.x86_64 : Development files for hiredis
opensips-redis.x86_64 : Redis connector
pcp-pmda-redis.x86_64 : Performance Co-Pilot (PCP) metrics for Redis
perl-Apache-Session-Redis.noarch : Redis driver for Apache::Session::NoSQL
perl-Redis.noarch : Perl binding for Redis database
php-nrk-Predis.noarch : PHP client library for Redis
php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
php-phpiredis.x86_64 : Client extension for Redis
python-redis.noarch : Python 2 interface to the Redis key-value store
python-trollius-redis.noarch : Redis client for the Python event loop PEP3156 for Trollius.
python2-django-redis.noarch : Full featured redis cache backend for Django
redis-trib.noarch : Cluster management script for Redis
rubygem-redis.noarch : A Ruby client library for Redis
rubygem-redis-doc.noarch : Documentation for rubygem-redis
syslog-ng-redis.x86_64 : redis support for syslog-ng
uwsgi-logger-redis.x86_64 : uWSGI - redislog logger plugin
uwsgi-router-redis.x86_64 : uWSGI - Plugin for Redis router support
redis.x86_64 : A persistent key-value database
Name and summary matches only, use "search all" for everything.

2、安裝Redis

yum install redis.x86_64 -y

3、配置Redis

vim /etc/redis.conf

4、配置訪問密碼

################################## SECURITY ###################################
requirepass password

5、檢視Redis後臺訪問程序

ps aux|grep redis
root     32523  0.0  0.3 142956  5816 pts/1    Sl   16:18   0:00 redis-server 127.0.0.1:6379
root 32566 0.0 0.0 112704 976 pts/1 R+ 16:30 0:00 grep --color=auto redis

6、殺掉原有Redis程序

kill -9 32523

7、載入有密碼的Redis,必須載入配置檔案啟動Redis程序,否則密碼不生效。

redis-server /etc/redis.conf &

8、訪問Redis伺服器

redis-cli

9、檢視全部Key資訊

127.0.0.1:6379> keys *

提示

(error) NOAUTH Authentication required.

10、輸入密碼訪問

auth password

提示

OK