1. 程式人生 > >centos7下安裝redis日常筆記

centos7下安裝redis日常筆記

    延續之前的centos7下開發環境搭建,這次安裝redis,本以為redis這種開發常用軟體官方的源裡直接有,但是執行結果是找不到。去官網看看,也沒有yum安裝的支援。再去網上找找,發現都是用的epel源,於是安裝源後直接安裝。

yum install epel-release

安裝完成之後查詢下有沒有redis

   [[email protected] dev.hzm.com]# yum search redis
Loaded plugins: fastestmirror
epel/x86_64/metalink                                                                                                                                                                                                                                   | 8.7 kB  00:00:00     
epel                                                                                                                                                                                                                                                   | 3.2 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                                                                                                                                                                            |  88 kB  00:00:06     
(2/3): epel/x86_64/updateinfo                                                                                                                                                                                                                          | 938 kB  00:00:08     
(3/3): epel/x86_64/primary                                                                                                                                                                                                                             | 3.6 MB  00:00:10     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: centos.ustc.edu.cn
 * updates: mirrors.163.com
epel                                                                                                                                                                                                                                                              12661/12661
============================================================================================================================= 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

redis.x86_64沒有問題,直接yum install,很順利。

yum install redis

 安裝完成後修改配置檔案/etc/redis.conf,修改繫結埠,密碼等,如果不需要也可以不修改。至於bind配置,有很多人理解是錯誤的,那些理解為讓其他機器訪問的ip白名單是錯誤的,他們肯定沒有跑起來過,在那瞎說。bind的作用是讓redis知道用本機的哪個網路介面,比如這臺機器有兩個網絡卡,一個通外網,一個通內網,兩個ip,顯然監聽外網的請求是不安全的。

修改埠,預設6379

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379

修改密碼

# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 123456

開啟服務

systemctl start redis.service

 檢視日誌cat /var/log/redis/redis.log沒有問題