参照地址   
http://www.mamicode.com/info-detail-1488639.html 前提:防火墙安装,然后打开端口,设置开机启动
一、redis源码安装
[root@host---- ~]# yum -y install gcc gcc-c++ autoconf automake [root@host---- ~]# yum -y install zlib zlib-devel openssl openssl-devel pcre-devel [root@host---- ~]# yum install -y tcl 截至到2016.8.11,redis最新稳定版本为3.2.3.本篇文章我们就以此版本为基础,进行相关的讲解。
下载redis源码,并进行相关操作,如下:
wgethttp://download.redis.io/releases/redis-3.2.5.tar.gz
tar -zxvf redis-3.2..tar.gz
mv redis-3.2. redis 解压完毕后,现在开始安装,如下:
cd redis
make && make install
[root@host---- redis]# cd utils/
[root@host---- utils]# /install_server.sh
Port :
Config file : /etc/redis/.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Copied /tmp/.conf => /etc/init.d/redis_6379 四、配置redis 设置redis密码:
[root@host---- utils]# vi /etc/redis/.conf
requirepas joinu_1233 设置持久化存储,修改四个配置: daemonize yes #守护进程 appendonly yes #开启aof持久化 appendfsync everysec bind 0.0.0.0 #开启远程访问 设置开机自启: [Unit]
Description=redis service
Wants=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/.conf
[Install]
WantedBy=multi-user.target
~ 五、启动和使用redis [root@host---- ~]# systemctl enable redis
[root@host---- ~]# systemctl start redis redis配置文件配置完毕后,我们来启动redis并进行简单的操作。如下:
redis-cli -h 127.0.0.1 -p -a ilanniredis
keys *
set ilanni testredis
get ilanni 我们来稍微讲解下以上命令的意思:
redis-cli -h 127.0.0.1 -p -a ilanniredis
这条命令是说要连接redis服务器,IP是127.0.0.,端口是6379,密码是ilanniredis。
keys *是查看redis所有的键值对。
set ilanni testredis添加一个键值ilanni,内容为testredis。
get ilanni查看ilanni这个键值的内容。

systemctl管理Redis启动、停止、开机启动

1. 创建服务

vi /lib/systemd/system/redis.service

[Unit]

Description=Redis

After=network.target

[Service]

ExecStart=/usr/local/bin/redis-server /usr/local/redis/redis.conf

ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown

[Install]

WantedBy=multi-user.target

3. 刷新配置

刚刚配置的服务需要让systemctl能识别,就必须刷新配置

$ systemctl daemon-reload

  • 1

如果没有权限可以使用sudo

$ sudo systemctl daemon-reload

  • 1

4. 启动、重启、停止

启动redis

$ systemctl start redis

  • 1

重启redis

$ systemctl restart redis

  • 1

停止redis

$ systemctl stop redis

  • 1

5. 开机自启动

redis服务加入开机启动

$ systemctl enable redis

  • 1

禁止开机启动

$ systemctl disable redis

  • 1

6. 查看状态

查看状态

$ systemctl status redis


redis 3.2.5单机版安装、使用、systemctl管理Redis启动、停止、开机启动的更多相关文章

  1. CentOS7 安装tomcat为系统服务器 Systemctl管理Tomcat,并设置开机启动

    本文转载:http://blog.chinaunix.net/uid-24648266-id-5729891.html CentOS7开始,从/etc/init.d脚本改为了systemctl管理服务 ...

  2. CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤

    准备文件如下: 1.CentOS-6.4-x86_64-bin-DVD1.iso 2.jdk-7u67-linux-x64.rpm 3.apache-tomcat-7.0.55.tar.gz 安装步骤 ...

  3. day 56 linux的安装python3 ,虚拟环境,mysql ,redis

    1.1下载python源码包 网址:https://www.python.org/downloads/release/python-366/ 下载地址:https://www.python.org/f ...

  4. CentOS7.3编译安装Nginx设置开机启动

    起因 最近想玩nginx了,本来用yum -y install nginx安装也启动好了,但是买了本<Nginx高性能Web服务器详解>,我咋能辜负我的书费呢?于是我就直接ps -ef | ...

  5. redis的介绍与操作及Django中使用redis缓存

    redis VS mysql的区别 """ redis: 内存数据库(读写快).非关系型(操作数据方便) mysql: 硬盘数据库(数据持久化).关系型(操作数据间关系) ...

  6. 二进制安装kubernetes(一) 环境准备及etcd组件安装及etcd管理软件etcdkeeper安装

    实验环境: 架构图: 主机环境: 操作系统:因docker对内核需要,本次部署操作系统全部采用centos7.6(需要内核3.8以上) VM :2C 2G 50G * 5  PS:因后面实验需要向k8 ...

  7. centos7下安装、配置Nginx、设置Nginx开机自启动

    测试环境: [root@centos-linux ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core) [root@cento ...

  8. Redis单机版安装

    1.工具简单介绍 1.博主使用的是Xshell工具 ps:需要设置端口和连接名称,端口一般默认为22,需要的童鞋可以自行百度 2.Redis单机版安装 第一步:安装gcc编译环境 yum instal ...

  9. Redis单机版安装与部署

    Redis官网:http://redis.io 下载Redis wget https://github.com/antirez/redis/archive/3.0.0-rc1.tar.gz 解压并安装 ...

随机推荐

  1. java与JSON

    XML 格式数据极其的冗长.因为每个离散的数据片段需要大量的 XML 结构,所有有效 的数据的比例非常低.XML 语法还有轻微的模糊.还有,解析 XML 是非常占程序员的精力的.你需要提前了解详细的结 ...

  2. python+Appium自动化:H5元素定位

    问题思考 在混合开发的App中,经常会有内嵌的H5页面.那么这些H5页面元素该如何进行定位操作呢? 解决思路 针对这种场景直接使用前面所讲的方法来进行定位是行不通的,因为前面的都是基于Andriod原 ...

  3. Codeforces Round #587 (Div. 3) C. White Sheet

    链接: https://codeforces.com/contest/1216/problem/C 题意: There is a white sheet of paper lying on a rec ...

  4. Git可视化极简易教程 — Git GUI使用方法[转]

    之前一直想一篇这样的东西,因为最初接触时,我也认真看了廖雪峰的教程,但是似乎我觉得讲得有点多,而且还是会给我带来很多多余且重复的操作负担,所以我希望能压缩一下它在我工作中的成本,但是搜索了一下并没有找 ...

  5. Laravel Passport API 认证使用小结

    Laravel Passport API 认证使用小结 八月 4, 2017 发布在 Laravel 看到Laravel-China 社区常有人问 Laravel Passport 用于密码验证方式来 ...

  6. 洛谷 U5122 T2-power of 2(费马小定理)

    U5122 T2-power of 2 题目提供者胡昊 题目描述 是一个十分特殊的式子. 例如: n=0时 =2 然而,太大了 所以,我们让对10007 取模 输入输出格式 输入格式: n 输出格式: ...

  7. Zookeeper原理 二

    Zookeeper到底是什么!? 学一个东西,不搞明白他是什么东西,哪还有心情学啊!! 首先,Zookeeper是Apache的一个java项目,属于Hadoop系统,扮演管理员的角色. 然后看到官网 ...

  8. Http通讯协议

    第一.http 通信协议的基本原理 一次 HTTP 请求的通信流程 流程图     DNS: (Domain Name System)服务是和 HTTP 协议一样位于应用层的协议.它提供域名到 IP ...

  9. 由 Vue 中三个常见问题引发的深度思考

    为什么 data 要写成函数,而不允许写成对象? Vue 中常说的数据劫持到底是什么? Vue 实例中数组改变 length 或下标直接赋值什么不能更新视图? http://www.sohu.com/ ...

  10. 教你快速写一个EventBus框架

    前言EventBus相信大多数人都用过,其具有方便灵活.解耦性强.体积小.简单易用等优点,虽然现在也有很多优秀的替代方案如RxBus.LiveDataBus等,但不可否认EventBus开创了消息总线 ...