一.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. Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver

    Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver 这 ...

  2. python 基础 切片 迭代 列表生成式

    对list 进行切片 如列表 L = ['Adam', 'Lisa', 'Bart', 'Paul'] L[0:3] ['Adam', 'Lisa', 'Bart'] L[0:3]表示,从索引0开始取 ...

  3. Mysql-表的基本操作

    一 存储引擎介绍 二 表介绍 三 创建表 四 查看表结构 五 数据类型 六 表完整性约束 七 修改表ALTER TABLE 八 复制表 九 删除表 一 .存储引擎介绍 存储引擎即表类型,mysql根据 ...

  4. jQuery.validate.js表单验证插件

    jQuery.validate.js表单验证插件的使用 效果: 代码: <!DOCTYPE html> <html lang="en"> <head& ...

  5. PHP中实现中文字串截取无乱码的方法

    [本文转自独占神林的日志:链接:http://yuninglovekefan.blog.sohu.com/176021361.html] 在PHP中,substr()函数截取带有中文字符串的话,可能会 ...

  6. 03.搭建Spark集群(CentOS7+Spark2.1.1+Hadoop2.8.0)

    接上一篇:https://www.cnblogs.com/yjm0330/p/10077076.html 一.下载安装scala 1.官网下载 2.spar01和02都建立/opt/scala目录,解 ...

  7. linux3.4.2之dma驱动

    1. 分配源地址.目的地址 src_addr = dma_alloc_writecombine(NULL,BUFF_SIZE, &psrc_addr,GFP_KERNEL); dst_addr ...

  8. MySQL用全库备份数据恢复单表数据

    备份数据库时,采用了全库备份,但是因为某些原因需要回滚一个表的数据到备份数据库上,如果回滚整个库就比较费时间,因为可能这个表只有几十M,但是其它表可能有十几上百G,这时候就需要将需要恢复的表提取出来了 ...

  9. Python学习笔记十:json序列化,软件结构目录规范,ATM作业讲解,import本质论

    json序列化 将系统的某个状态保存为字符串(挂起),序列化. import json json.dumps():序列化 json.loads():反序列化 简单类型数据处理 import pickl ...

  10. MFC中两个对话框之间数据传递

    以下是在网上参考的一篇文章,网址:https://blog.csdn.net/foreverhuylee/article/details/21707197 这里有两种情况, 第一种情况是: (在一个基 ...