码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 7 安装Redis

时间:2019-02-18 16:14:30      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:utils   ini   压缩   select   table   asi   set   cte   server   

CentOS 7 安装Redis

  1. 安装依赖等

     [root@localhost ~]# yum install -y wget gcc
  2. 下载redis-5.0.3.tar.gz并安装

     [root@localhost ~]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
     [root@localhost ~]# tar -zxvf redis-5.0.3.tar.gz
     [root@localhost ~]# cd redis-5.0.3
     [root@localhost redis-5.0.3]# make MALLOC=libc
  3. 安装Redis服务

     [root@localhost redis-5.0.3]# ./utils/install_server.sh

    启动Redis服务安装

     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!

    修改服务名称

     [root@localhost ~]# mv /etc/init.d/redis_6379 /etc/init.d/redis
  4. 配置Redis.conf

     [root@localhost ~]# vi /etc/redis/6379.conf

    配置Redis.conf

     # bind增加当前服务器内网IP
     bind 10.0.0.120 127.0.0.1 
    
     # 将backlog增大
     tcp-backlog 2000    
    
     # 关闭存盘策略
     # save 900 1
     # save 300 10
     # save 60 10000
    
     # 修改showlog策略
     slowlog-log-slower-than 5000
     slowlog-max-len 500
    
     # 关闭hash-max-ziplist压缩
     # hash-max-ziplist-entries 512
     # hash-max-ziplist-value 64
  5. 重启服务

     [root@localhost ~]# service redis restart
     Stopping ...
     Redis stopped
     Starting Redis server...
  6. 测试服务是否正常运行

     [root@localhost ~]# redis-cli
     127.0.0.1:6379> set a 123456
     OK
     127.0.0.1:6379> get a
     "123456"
     127.0.0.1:6379> exit
  7. 防火墙

     [root@localhost ~]# vim /etc/sysconfig/iptables

    在22端口下增加开放6379端口号

     -A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT

    重新启动防火墙服务

     [root@localhost ~]# systemctl restart iptables

CentOS 7 安装Redis

标签:utils   ini   压缩   select   table   asi   set   cte   server   

原文地址:https://www.cnblogs.com/zhangbyes/p/10396061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!