Centos 7.5安装 Redis 5.0.0
1 我的环境
1.1 linux(腾讯云)
CentOS Linux release 7.5.1804 (Core)
1.2 Redis
Redis 5.0.0
2 下载
3 上传
3.1 使用xftp上传到指定目录,我的目录为
/app/tool
4 解压到安装目录
mkdir /usr/local/redis
tar zxf redis-5.0.0.tar.gz -C /usr/local/redis/
5 安装 gcc 依赖
yum -y install gcc
6 编译
6.1 进入redis解压目录
cd /usr/local/redis/redis-5.0.0
6.2 编译
make MALLOC=libc
7 安装
7.1 进入redis/src下
cd /usr/local/redis/redis-5.0.0/src
7.2 执行安装
make install
8 配置(后台启动,设置密码,外部访问)
8.1 修改配置文件
vim /usr/local/redis/redis-5.0.0/redis.conf
进入vim 输入 / 再按火车用来搜索关键字
比如如下命令会定位到文件中出现 bind 的位置并会将关键词用颜色区分。
/bind
8.2 后台启动
搜索 daemonize no 改为 daemonize yes
daemonize no
8.3 设置密码
搜索 requirepass foobared 添加 requirepass 你设置的密码
requirepass foobared
8.4 外部访问
搜索 bind 127.0.0.1 然后注释掉
# bind 127.0.0.1
记得开放6379端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload
9 启动,停止和重启
9.1 启动
- 在任意目录执行
redis-server /usr/local/redis/redis-5.0.0/redis.conf
- 启动成功界面和进程
ps aux | grep redis
- 连接redis
在任意目录下执行redis-cli即可连接
redis -cli
auth 密码
9.2 停止
- 未设置密码时
redis-cli shutdown
- 设置密码后,执行以下命令
redis-cli -a 密码
- 再执行停止和退出连接
shutdown
not connected> exit
9.3 重启
一般重启都是杀掉进程,再启动redis,这里就介绍一下步骤,当然也可以执行上面的停止再启动
ps aux | grep redis
[root@VM_0_9_centos /]# ps aux | grep redis
root 29228 0.0 0.1 144004 2016 ? Ssl 14:22 0:00 redis-server *:6379
root 29259 0.0 0.0 112704 972 pts/2 S+ 14:22 0:00 grep --color=auto redis
kill -9 29228
ps aux | grep redis
[root@VM_0_9_centos /]# ps aux | grep redis
root 29538 0.0 0.0 112704 968 pts/2 S+ 14:25 0:00 grep --color=auto redis
10 开机启动(可以忽略)
10.1 复制redis服务文件 redis_init_script
cp /usr/local/redis/redis-5.0.0/utils/redis_init_script /etc/init.d/redis
10.2 在 etc 下创建 redis 文件夹
mkdir /etc/redis
10.3 复制redis配置文件 redis.conf 并重命名为6379.conf
cp /usr/local/redis/redis-5.0.0/redis.conf /etc/redis/
mv /etc/redis/redis.conf 6379.conf
10.3 修改redis服务文件
vim /etc/init.d/redis
- 在/etc/init.d/redis文件的头部添加下面两行注释代码,也就是在文件中#!/bin/sh的下方添加
# chkconfig: 2345 10 90
# description: Start and Stop redis
- 指定redis的安装路径和pid文件路径
REDISPORT=6379
EXEC=/usr/local/redis/redis-5.0.0/src/redis-server # 指定的执行路径
CLIEXEC=/usr/local/redis/redis-5.0.0/src/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf" # 这里就是上面重命名的配置文件
- 若设置了密码,则需要修改
stop脚本
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a 你的密码 -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
- 停止输出结果
Stopping ...
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
Redis stopped
10.4 现在的redis命令
- 打开redis命令
service redis start
- 关闭redis命令
service redis stop
- 设为开机启动
chkconfig redis on
- 设为开机关闭
chkconfig redis off
Centos 7.5安装 Redis 5.0.0的更多相关文章
- CentOS 7.3 安装redis 4.0.2服务
CentOS 7.3 安装redis 4.0.2服务 1.下载解压 下载地址:/home/xiaoming/ wget http://download.redis.io/releases/redis- ...
- CentOS 6 中安装Node.js 4.0 版本或以上
如果想在CentOS 6 中安装Node.js >4.0,如果通过以往的方式安装: wget http://nodejs.org/dist/v4.0.0/node-v4.0.0.tar.gz t ...
- CentOS 6.5安装Erlang/OTP 17.0
CentOS 6.5安装Erlang/OTP 17.0 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs Erlang眼下已经是Fedora和Debian/ ...
- Redis学习笔记(1)- CentOS 6.4 安装Redis
Redis学习笔记(1)- CentOS 6.4 安装Redis 2013.10.13 学习环境 vm 10.1 + 默认.新装的干净 CentOS 6.4 64BIT系统 准备 1 ...
- CentOS 7.4 安装 K8S v1.11.0 集群所遇到的问题
0.引言 最近打算将现有项目的 Docker 部署到阿里云上面,但是之前是单机部署,现在阿里云上面有 3 台机器,所以想做一个 Docker 集群.之前考虑是用 Docker Swarm 来做这个事情 ...
- CentOS 6.5 安装Clang 3.5.0
来自引用: http://www.cnblogs.com/dudu/p/4294374.html 编译llvm几乎耗费了1个小时-.. 编译CoreCLR需要Clang 3.5,而CentOS上安装的 ...
- CentOS 6.5安装Oracle 11.2.0.4------CentOS 6.5安装
规划: IP:192.168.213.199 mask: 255.255.255.0 gateway:192.168.213.1 DNS1:202.101.172.35 磁盘分区: 磁盘总大小:25G ...
- 如何在 CentOS 7 上安装 Redis 服务器
大家好,本文的主题是 Redis,我们将要在 CentOS 7 上安装它.编译源代码,安装二进制文件,创建.安装文件.在安装了它的组件之后,我们还会配置 redis ,就像配置操作系统参数一样,目标就 ...
- CentOS 7 服务器配置--安装Redis
#下载Redis wget -r -np -nd http://download.redis.io/releases/redis-3.2.8.tar.gz #解压文件 tar zxvf redis-3 ...
随机推荐
- 在沙箱中IE不能上网的解决方法
近期在解决一个问题,在我们的沙箱中IE不能上网 现象: IE不能上网.输入www.baidu.com 提示:不能查找到DNS.也不能ping 通 其它浏览器上网没有问题(SG浏览器,C ...
- Redis源码解析:10scan类命令的实现
像keys或者smembers命令,需要遍历数据集合中的所有元素.在一个大的数据库中使用,可能会阻塞服务器较长的一段时间,造成性能问题,因此不适用与生产环境. 在Redis2.8.0中引入了scan类 ...
- linux centos 一键安装环境
phpStudy for Linux 支持Apache/Nginx/Tengine/Lighttpd, 支持php5.2/5.3/5.4/5.5切换 已经在centos-6.5,debian-7.4. ...
- HZOJ 光
一道大模拟,打的我要吐了. 先说一下60%暴力吧,其实模拟光的路线即可,最好还是把边界设为障碍,这样就不用判边界了.最后输出n*m可以骗到10分. 注意不要把n和m弄混(愁死我了). #include ...
- nn.moduleList 和Sequential由来、用法和实例 —— 写网络模型
对于cnn前馈神经网络如果前馈一次写一个forward函数会有些麻烦,在此就有两种简化方式,ModuleList和Sequential.其中Sequential是一个特殊的module,它包含几个子M ...
- H3C 单播与广播
- 【C++竞赛 B】yyy的回文数组
时间限制:1s 内存限制:32MB 问题描述 回文串是一个正读和反读都一样的字符串,比如level或者noon就是回文串.回文数组也是如此,比如[100,200,100]或者[178,256,256, ...
- laravel validate 设置为中文(验证提示为中文)
把 resources\lang 下en 的文件夹 复制在同一目录并改名为 zn 把zn 中的 validation.php文件修改为 https://laravel-china.org/articl ...
- js读取cookie 根据cookie名称获取值、赋值
借鉴:原作者https://blog.csdn.net/zouxuhang/article/details/80548417 //方法1 //存在问题:如果cookie中存在 aaaname= ...
- vue iframe嵌套页面高度自适应 (ios 宽度扩大的bug , ios展示比例问题)
<template> <div class="card-index pt-relative"> <div id="wrapper ...