[redis] linux下安装篇(1)
一.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)的更多相关文章
- Redis linux 下安装
Redis linux 下安装 下载Redis安装包,可以从Redis中文网站中下载 下载地址:http://www.redis.cn/download.html Redis4.0 稳定版本 使用&l ...
- Redis linux 下安装 及扩展配置
1.首先在/usr/local/ 创建文件夹 reids Cd /usr/local/ mkdir redis 2.把redis安装包放在redis目录下面进行解压phpredis-2.2.4.tar ...
- [redis] linux下哨兵篇(3)
一.前言1.为何部署sentinel哨兵前文redis主从架构中,当主服务故障时,需要手动将从服务切换为主服务,sentinel服务就是将这个过程自动化.主要功能有:1)不时监控主从服务正常运行2)可 ...
- [redis] linux下主从篇(2)
一.前言1.为何要主从架构避免单机故障,主服务器挂掉后,还可以手动切换从服务为主服务继续工作,保持缓存数据完整. 2.主从同步的原理步骤从服务器连接主服务器,发送SYNC命令:主服务器接收到SYNC命 ...
- linux 下安装redis以及php Redis扩展
[php] view plaincopy在CODE上查看代码片派生到我的代码片 linux 下安装redis以及php Redis扩展 环境配置: centos6. nginx/ php/ mysql ...
- mac mamp环境 和linux下 安装redis 和可视化工具 Redis Desktop Manager
mac下安装 第一步:安装redis 1. brew install redis 2.启动服务/usr/local/opt/redis/bin/redis-server 3.配置redis密码访问 编 ...
- Linux 下安装 Redis server
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/defonds/article/details/30047611 本文简介了 Linu ...
- Linux下安装Redis及搭建主从
Linux下安装Redis 首先在官网下载对应版本的redis包,这里本人使用的是redis-4.0.8.tar.gz. 然后在服务器中存放redis包的路径下执行tar –vxf redis-4 ...
- Linux下安装Redis以及遇到的问题
参考链接:https://www.cnblogs.com/zdd-java/p/10288734.html https://www.cnblogs.com/uncleyong/p/9882843.ht ...
随机推荐
- 【腾讯敏捷转型No.3】Scrum有什么好?
在敏捷转型的过程中,除了敏捷宣言中的四个价值观和十二条原则以外,并没有太多比较权威的理论实践. 如图一,敏捷宣言中的四个价值观: (图一) 四条敏捷核心价值观指出了敏捷的核心思想,但是并没有仔细说明具 ...
- .net core 实践笔记(三)--封装底层
前言: 有了前面的工作,简单的架子基本搭建起来了,因为条件有限,只能先测试SqlServer的了,源码放出来,也希望有兴趣的伙伴可以一起改善,相信可以成为未来进阶架构师的第一步,自己有小项目的时候可以 ...
- sqlplus连接半天才连上
问题现象: 某oracle数据库服务器发现使用ssh,crt连接半天1-2分钟后才返回输入密码的提示,应用人员发现使用 sys_GUID()函数获取唯一值的时候,第一次调用需要等待很长时间,但是同一s ...
- JS の 套路 I ~~
小扇在到新公司以后,发现.我的js都忘记了!! 下面总结一下在装配数据时候用到的一些小小的公式,希望像我这样的前端小菜B起到帮助叭叭叭叭叭~~~ I.查找想找到的 HTML 元素 * i.查找元素 v ...
- ABAP术语-URL
URL 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/20/1114193.html Uniform Resource Locator (U ...
- python爬虫练习 -- 签名器+GUI界面(Tkinter)
效果图: 实现步骤如下: 实现原理:其实就是套了一层GUI的壳,主要还是爬虫抓取某个网站返回的数据,然后利用python自带的GUI工具包Tkinter来实现gui界面: 1.爬虫分析: 目标站点:h ...
- linux 命令 sort
Linux下的sort排序命令详解(一) 1 sort的工作原理 sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次按ASCII码值进行比较,最后将他们按升序输出. [zook ...
- decodeURI、decodeURIComponent 编码方法
——摘自<JavaScript高级程序设计> 编码: Global 对象的 encodeURI()和 encodeURIComponent()方法可以对 URI(Uniform Resou ...
- 大数据学习--day15(常用类:Date--DateFormat--SimpleDateFormat--File--包装类)
常用类:Date--DateFormat--SimpleDateFormat--File--包装类 这些常用类就不像字符串挖那么深了,只列列用法. 时间处理: /** * 时间处理类 * DateFo ...
- 树莓3B+_Raspbian 源使用帮助
https://mirrors.ustc.edu.cn/help/raspbian.html Raspbian 源使用帮助 地址 https://mirrors.ustc.edu.cn/raspb ...