linux安装redis完整步骤
linux安装redis完整步骤
安装:
1.获取redis资源
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
2.解压
tar xzvf redis-4.0.8.tar.gz
3.安装
cd redis-4.0.8
make
cd src
make install PREFIX=/usr/local/redis
4.移动配置文件到安装目录下
cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc
5.配置redis为后台启动
vi /usr/local/redis/etc/redis.conf //将daemonize no 改成daemonize yes
6.将redis加入到开机启动
vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)
7.开启redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
常用命令
redis-server /usr/local/redis/etc/redis.conf //启动redis
pkill redis //停止redis
卸载redis:
rm -rf /usr/local/redis //删除安装目录
rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本
rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹
让外网能够访问redis
a.配置防火墙: firewall-cmd --zone=public --add-port=6379/tcp --permanent(开放6379端口)
systemctl restart firewalld(重启防火墙以使配置即时生效)
查看系统所有开放的端口:firewall-cmd --zone=public --list-ports
b.此时 虽然防火墙开放了6379端口,但是外网还是无法访问的,因为redis监听的是127.0.0.1:6379,并不监听外网的请求。
(一)把文件夹目录里的redis.conf配置文件里的bind 127.0.0.1前面加#注释掉
(二)命令:redis-cli连接到redis后,通过 config get daemonize和config get protected-mode 是不是都为no,如果不是,就用config set 配置名 属性 改为no。
redis.conf文件
# bind 127.0.0.1
daemonize no
protected-mode no
# redis在最终目标上移动临时数据库文件时出错 将dir ./ 修改为redis配置文件所在目录:/usr/local/redis/etc/
# redis的持久化机制RDB先将内存中的数据集写入临时文件(temp-pid.rdb),写成功后再替换之前的文件(dump.rdb),而现在写入临时文件出错,数据保存不了,导致程序崩溃
dir /usr/local/redis/etc/
# RDB和AOF持久化
#redis有两种持久化方式:一种是RDB持久化(原理是将Reids在内存中的数据库记录定时dump到磁盘上的RDB持久化)
# 一种是AOF持久化(原理是将Reids的操作日志以追加的方式写入文件)
#RDB是默认开启的,AOF需要修改配置文件来开启
appendonly yes
appendfilename "appendonly.aof"
12493:M 27 Dec 19:42:23.095 * 10 changes in 300 seconds. Saving...
12493:M 27 Dec 19:42:23.095 * Background saving started by pid 7905
7905:C 27 Dec 19:42:23.106 # Error moving temp DB file temp-7905.rdb on the final destination crontab (in server root dir /etc): Operation not permitted
12493:M 27 Dec 19:42:23.196 # Background saving error
Redis持久化失败报错
错误:
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. [7679] 15 Jan 00:27:35.287 *
DB loaded from disk: 19.629 seconds
解决方案:在Linux系统设置一个参数(vm.overcommit_memory)即可解决。
编辑 sysctl.conf 配置文件:vim /etc/sysctl.conf
vm.overcommit_memory = 1
使配置文件生效:sysctl -p
最后重启redis
配置之后的控制台日志打印如下:
[root@hz-auto-test-test5-02 etc]$/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
18679:C 27 Dec 19:52:06.898 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18679:C 27 Dec 19:52:06.898 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=18679, just started
18679:C 27 Dec 19:52:06.898 # Configuration loaded
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.8 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 18679
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
18679:M 27 Dec 19:52:06.900 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18679:M 27 Dec 19:52:06.900 # Server initialized
18679:M 27 Dec 19:52:06.900 # 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.
18679:M 27 Dec 19:52:06.900 * Ready to accept connections
18679:M 27 Dec 19:57:07.096 * 10 changes in 300 seconds. Saving...
18679:M 27 Dec 19:57:07.096 * Background saving started by pid 6584
6584:C 27 Dec 19:57:07.111 * DB saved on disk
6584:C 27 Dec 19:57:07.112 * RDB: 0 MB of memory used by copy-on-write
18679:M 27 Dec 19:57:07.196 * Background saving terminated with success
18679:M 27 Dec 20:01:20.187 * 10000 changes in 60 seconds. Saving...
18679:M 27 Dec 20:01:20.187 * Background saving started by pid 24886
24886:C 27 Dec 20:01:20.224 * DB saved on disk
24886:C 27 Dec 20:01:20.225 * RDB: 0 MB of memory used by copy-on-write
18679:M 27 Dec 20:01:20.287 * Background saving terminated with success
linux安装redis完整步骤的更多相关文章
- linux 安装redis 完整步骤
最近在linux服务器上需要安装redis,来存放数据,增加用户访问数据的速度,由于是第一次安装,于是在百度上搜了一篇文章,按照这篇博客,顺利安装好了,因此将博主的文章拷过来记录一下,方便以后使用,也 ...
- linux安装redis 完整步骤
原文连接:https://www.cnblogs.com/lauhp/p/8487029.html 安装: 1.获取redis资源 wget http://download.redis.io/rele ...
- linux安装redis详细步骤(系统centos 6.4 )
1.安装redis 进入安装目录下载: cd /usr/local/redis wget http://download.redis.io/releases/redis-3.0.7.tar.gz 解 ...
- 阿里云Linux服务器安装Redis 完整步骤(包括处理远程连接问题)
跟随本篇文章步骤,包你成功安装并连接使用. 1.获取redis资源 wget http://download.redis.io/releases/redis-4.0.8.tar.gz 2.解压 tar ...
- Linux安装JDK完整步骤
1.检查一下系统中的jdk版本 [root@localhost software]# java -version 显示: openjdk version "1.8.0_102" O ...
- Linux安装Redis步骤和make遇到的坑
Linux安装Redis服务步骤 1.获取redis资源 cd /usr/local wget https://mirrors.huaweicloud.com/redis/redis-6 ...
- Linux安装redis服务器和部署
Linux安装redis和部署 第一步:下载安装包 wget http://download.redis.io/releases/redis-5.0.5.tar.gz 访问https://redis. ...
- Linux安装Anaconda3完整教程
Linux安装Anaconda3完整教程 欢迎关注H寻梦人公众号 相关链接 官方安装Anaconda3教程 [手把手教你]如何在Linux系统搭建jupyter notebook CentOS8.2安 ...
- Linux安装redis服务器
Linux安装redis服务器 初次接触,这里简单的说下我遇到的情况以及安装方法,当然也是参考了诸位大神的. 确定虚拟机的主机IP. 1)首先需要一个linux虚拟机,确定虚拟机的ip ,输入命令:# ...
- Linux 安装Redis<准备>(使用Mac远程访问)
阅读本文需要一定的Linux基础 一 Redis简介 redis是用c语言编写的一款开源的高性能键值对(key-value)数据库 它通过提供多种键值数据类型来适应不同场景下的存储需求 二 Redis ...
随机推荐
- [FAQ] edge debug栏的网络里 没有见到 All Fetch/XHR JS CSS 这些东西
一种方式是 打开调试器的设置,重置默认并刷新即可. 另一种方式是把这个 "筛选" 点掉. Tool:揭开网站所用的技术 Link:https://www.cnblogs.com ...
- [HTML] 访问 a 链接不带 referer 的方式
html5 新属性 referrerpolicy: referrerpolicy no-referrer no-referrer-when-downgrade origin origin-when-c ...
- [FAQ] pdf 无法导入 adobe AI, 分辨率 or 颜色缺失 or 字体缺失
属于Adoge软件不支持问题, 可能是分辨率.字体等多种原因. https://www.codebye.com/adobe-reader-or-acrobat-opens-pdf-file-drawi ...
- 【爬虫+情感判定+饼图+Top10高频词+词云图】"王心凌"热门弹幕python舆情分析
目录 一.背景介绍 二.代码讲解-爬虫部分 2.1 分析弹幕接口 2.2 讲解爬虫代码 三.代码讲解-情感分析部分 3.1 整体思路 3.2 情感分析打标 3.3 统计top10高频词 3.4 绘制词 ...
- 【Python基础】两个参数的for循环步长写法
一个参数for循环步长写法 >>> for i in range(1,10000,1000):print(i) ... 1 1001 2001 3001 4001 5001 6001 ...
- 一键关闭 Win11 系统广告「GitHub 热点速览」
不知道读者中有多少人早已对 Windows 11 系统自带的广告感到厌烦,却又不知道如何关闭它们? 虽然网上有详细的关闭教程,但是都需要逐一手动操作,不是很方便.所以,今天「GitHub 热点速览」给 ...
- @Async异步失效的9种场景
前言 最近星球中有位小伙伴问了我一个问题:他在项目某个方法使用@Async注解,但是还是该方法还是同步执行了,异步不起作用,到底是什么原因呢? 伪代码如下: @Slf4j @Service publi ...
- 一篇文章让你掌握99%的Python运算符。干货很多,建议收藏!!!
Python 中的运算符是编程中的基础概念,用于执行各种操作和数据计算.以下是一些 Python 中的主要运算符的概述: 运算符 1. 算术运算符 算术运算符语法规则 +:加法 -:减法 *:乘法 / ...
- ansible系列(23)--ansible的when控制语句
目录 1 when控制语句 1.1 根据不同操作系统安装相同的软件 1.2 为不同centos版本安装httpd软件 1.3 为特定的主机添加Nginx仓库 1.4 判断服务是否正常运行 1 when ...
- es请求方式调用
Es基础 关系: ElasticSearch-> mysql index (索引)-> 数据库 Documents(文档) -> row(行) Fileds(字段)-> col ...