一.redis是什么
redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)和zset(有序集合)
更多的介绍就不copy了,直接看官网https://redis.io/topics/introduction

二.yum安装redis

  1.安装前环境说明

  系统基于CentOS-6.7-x86_64-minimal.iso

  2.安装epel源、redis

#安装epel源
[root@localhost ~]# rpm -ivh http://mirrors.ustc.edu.cn/centos/6/extras/x86_64/Packages/epel-release-6-8.noarch.rpm #安装redis
[root@localhost ~]# yum install -y reids

  3.启动redis

[root@localhost ~]# /etc/init.d/redis start
Starting redis-server: [ OK ] #查看启动日志
[root@localhost ~]# cat /var/log/redis/redis.log [1425] 07 Dec 17:41:12 * Server started, Redis version 2.4.10
[1425] 07 Dec 17:41:12 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[1425] 07 Dec 17:41:12 * DB loaded from disk: 0 seconds
[1425] 07 Dec 17:41:12 * The server is now ready to accept connections on port 6379 #修复报错信息
[root@localhost ~]# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
[root@localhost ~]# sysctl vm.overcommit_memory=1
vm.overcommit_memory = 1 #重启redis
[root@localhost ~]# /etc/init.d/redis restart
Stopping redis-server: [ OK ]
Starting redis-server: [ OK ] #再次查看日志,已经没有报错了
[1425] 07 Dec 17:45:33 # Received SIGTERM, scheduling shutdown...
[1425] 07 Dec 17:45:33 # User requested shutdown...
[1425] 07 Dec 17:45:33 * Saving the final RDB snapshot before exiting.
[1425] 07 Dec 17:45:33 * DB saved on disk
[1425] 07 Dec 17:45:33 * Removing the pid file.
[1425] 07 Dec 17:45:33 # Redis is now ready to exit, bye bye...
[1446] 07 Dec 17:45:33 * Server started, Redis version 2.4.10
[1446] 07 Dec 17:45:33 * DB loaded from disk: 0 seconds
[1446] 07 Dec 17:45:33 * The server is now ready to accept connections on port 6379

  4.redis一些基本的配置说明

[root@localhost ~]# grep -vE "^$|#" /etc/redis.conf
daemonize yes #以deamon形式运行在后台
pidfile /var/run/redis/redis.pid #进程id文件
port 6379 #监听端口
bind 127.0.0.1 #绑定地址
timeout 0
loglevel notice
logfile /var/log/redis/redis.log #redis日志
databases 16 #创建的数据库数据
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb #数据文件名
dir /var/lib/redis/ #数据目录

  5.客户端连接读写测试

[root@localhost ~]# redis-cli
redis 127.0.0.1:6379> set name user1
OK
redis 127.0.0.1:6379> get name
"user1"
redis 127.0.0.1:6379> exit

三.源码安装redis

  0.卸载前文yum安装的包

[root@localhost ~]# /etc/init.d/redis stop
Stopping redis-server: [ OK ]
[root@localhost ~]# yum remove -y redis

  1.下载源码包,版本选择访问http://download.redis.io/releases

[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget http://download.redis.io/releases/redis-3.2.4.tar.gz

  2.安装redis

# 详细安装内容可以参考readme
[root@localhost src]# cd /usr/local/src/
[root@localhost src]# tar zxvf redis-3.2.4.tar.gz
[root@localhost src]# cd redis-3.2.4
[root@localhost redis-3.2.4]# more README.md #minimal系统缺少组件gcc
[root@localhost ~]# yum install -y gcc #安装到自定义路径,方便卸载
[root@localhost redis-3.2.4]# make PREFIX=/usr/local/redis install #修改配置文件
[root@localhost redis-3.2.4]# mkdir /etc/redis
[root@localhost redis-3.2.4]# cp redis.conf /etc/redis/6379.conf
[root@localhost redis-3.2.4]# vim /etc/redis/6379.conf
daemonize yes #no改成yes
logfile "/var/log/redis_6379.log" #日志文件
dir /var/lib/redis #数据目录
requirepass mima #开启密码认证 #服务启动脚本
[root@localhost redis-3.2.4]# cp /usr/local/src/redis-3.2.4/utils/redis_init_script /etc/init.d/redis
[root@localhost redis-3.2.4]# chmod +x /etc/init.d/redis
[root@localhost redis-3.2.4]# vim /etc/init.d/redis
7 EXEC=/usr/local/redis/bin/redis-server
8 CLIEXEC=/usr/local/redis/bin/redis-cli
30 $CLIEXEC -p $REDISPORT -a mima shutdown

  3.启动服务

[root@localhost ~]# /etc/init.d/redis start
[root@localhost ~]# cat /var/log/redis_6379.log
1613:M 07 Dec 18:25:47.132 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.4 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1613
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' 1613:M 07 Dec 18:25:47.134 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1613:M 07 Dec 18:25:47.134 # Server started, Redis version 3.2.4
1613:M 07 Dec 18:25:47.134 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1613:M 07 Dec 18:25:47.134 * DB loaded from disk: 0.000 seconds
1613:M 07 Dec 18:25:47.134 * The server is now ready to accept connections on port 6379 #修复报错
[root@localhost ~]# echo 512 > /proc/sys/net/core/somaxconn
[root@localhost ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@localhost ~]# echo "echo 512 > /proc/sys/net/core/somaxconn" >> /etc/rc.local
[root@localhost ~]# echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local
#如果在yum安装方式中已修改以下问题,就不用重复操作
[root@localhost ~]# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
[root@localhost ~]# sysctl vm.overcommit_memory=1 #重启redis
[root@localhost ~]# /etc/init.d/redis restart
Please use start or stop as first argument
[root@localhost ~]# /etc/init.d/redis stop
Stopping ...
Redis stopped
[root@localhost ~]# /etc/init.d/redis start
Starting Redis server...

  4.客户端连接读写测试

[root@localhost ~]# /usr/local/redis/bin/redis-cli
127.0.0.1:6379> auth mima
OK
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set name user2
OK
127.0.0.1:6379> get name
"user2"
127.0.0.1:6379> exit

[redis] linux下安装篇(1)的更多相关文章

  1. Redis linux 下安装

    Redis linux 下安装 下载Redis安装包,可以从Redis中文网站中下载 下载地址:http://www.redis.cn/download.html Redis4.0 稳定版本 使用&l ...

  2. Redis linux 下安装 及扩展配置

    1.首先在/usr/local/ 创建文件夹 reids Cd /usr/local/ mkdir redis 2.把redis安装包放在redis目录下面进行解压phpredis-2.2.4.tar ...

  3. [redis] linux下哨兵篇(3)

    一.前言1.为何部署sentinel哨兵前文redis主从架构中,当主服务故障时,需要手动将从服务切换为主服务,sentinel服务就是将这个过程自动化.主要功能有:1)不时监控主从服务正常运行2)可 ...

  4. [redis] linux下主从篇(2)

    一.前言1.为何要主从架构避免单机故障,主服务器挂掉后,还可以手动切换从服务为主服务继续工作,保持缓存数据完整. 2.主从同步的原理步骤从服务器连接主服务器,发送SYNC命令:主服务器接收到SYNC命 ...

  5. linux 下安装redis以及php Redis扩展

    [php] view plaincopy在CODE上查看代码片派生到我的代码片 linux 下安装redis以及php Redis扩展 环境配置: centos6. nginx/ php/ mysql ...

  6. mac mamp环境 和linux下 安装redis 和可视化工具 Redis Desktop Manager

    mac下安装 第一步:安装redis 1. brew install redis 2.启动服务/usr/local/opt/redis/bin/redis-server 3.配置redis密码访问 编 ...

  7. Linux 下安装 Redis server

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/defonds/article/details/30047611         本文简介了 Linu ...

  8. Linux下安装Redis及搭建主从

    Linux下安装Redis 首先在官网下载对应版本的redis包,这里本人使用的是redis-4.0.8.tar.gz.   然后在服务器中存放redis包的路径下执行tar –vxf redis-4 ...

  9. Linux下安装Redis以及遇到的问题

    参考链接:https://www.cnblogs.com/zdd-java/p/10288734.html https://www.cnblogs.com/uncleyong/p/9882843.ht ...

随机推荐

  1. macOS:按钮类型

    for (int i = 0; i < 10; i++) { for (int j = 1; j < 16; j++) { NSButton *btn = [[NSButton alloc ...

  2. 可编辑div中包含子元素时获取光标位置不准确的问题

    前言: 高亮显示输入框中的关键字符,这就必须得用到可编辑div(或其他标签)元素了,这时我们需要获取光标的位置,以便插入字符. 正文: 正常情况下获取光标位置,代码如下: function getPo ...

  3. Some cool FireMonkey multi-device components

    http://blogs.embarcadero.com/davidi/2014/01/16/43281 There are many available Delphi and C++Builder ...

  4. Linux 字符设备驱动—— ioremap() 函数解析

    一. ioremap() 函数基础概念 几乎每一种外设都是通过读写设备上的相关寄存器来进行的,通常包括控制寄存器.状态寄存器和数据寄存器三大类,外设的寄存器通常被连续地编址.根据CPU体系结构的不同, ...

  5. php安装redis拓展

    1. 查看是否安装redis库 查看是否安装redis库了.可以通过下面2种方式查看. phpinfo()是否能输出redis的加载信息 在命令行执行`php -m` 输出gd 2. 安装redis库 ...

  6. 20155210 潘滢昊 Java第三次实验

    Java第三次实验 实验内容 在IDEA中使用工具(Code->Reformate Code)把代码重新格式化 在码云上把自己的学习搭档加入自己的项目中,确认搭档的项目加入自己后,下载搭档实验二 ...

  7. 安装虚拟机及学习linux系统 20155222卢梓杰

    安装虚拟机及学习linux系统 20155222卢梓杰 首先按照要求下载virtualbox,没有遇到问题. 接下来新建一个虚拟机,按照要求应当安装乌班图64,这里只有32位的.在网上搜寻了许久,终于 ...

  8. 20155305 2016-2017-2《Java程序设计》课程总结

    20155305 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 [预备作业1](http://www.cnblogs.com/20155305ql/p/6 ...

  9. 第八周课上额外项目:pwd的实现

    项目要求: 1 学习pwd命令 2 研究pwd实现需要的系统调用(man -k; grep),写出伪代码 3 实现mypwd 4 测试mypwd 并且上交博客链接. 实验步骤 我首先不懂pwd到底是个 ...

  10. c++ 参数个数可变的函数

    #include <stdio.h> #include <string.h> #include <stdarg.h> int addnum(int i,...) { ...