redis 3.2.5单机版安装、使用、systemctl管理Redis启动、停止、开机启动
参照地址
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启动、停止、开机启动的更多相关文章
- CentOS7 安装tomcat为系统服务器 Systemctl管理Tomcat,并设置开机启动
本文转载:http://blog.chinaunix.net/uid-24648266-id-5729891.html CentOS7开始,从/etc/init.d脚本改为了systemctl管理服务 ...
- 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 安装步骤 ...
- day 56 linux的安装python3 ,虚拟环境,mysql ,redis
1.1下载python源码包 网址:https://www.python.org/downloads/release/python-366/ 下载地址:https://www.python.org/f ...
- CentOS7.3编译安装Nginx设置开机启动
起因 最近想玩nginx了,本来用yum -y install nginx安装也启动好了,但是买了本<Nginx高性能Web服务器详解>,我咋能辜负我的书费呢?于是我就直接ps -ef | ...
- redis的介绍与操作及Django中使用redis缓存
redis VS mysql的区别 """ redis: 内存数据库(读写快).非关系型(操作数据方便) mysql: 硬盘数据库(数据持久化).关系型(操作数据间关系) ...
- 二进制安装kubernetes(一) 环境准备及etcd组件安装及etcd管理软件etcdkeeper安装
实验环境: 架构图: 主机环境: 操作系统:因docker对内核需要,本次部署操作系统全部采用centos7.6(需要内核3.8以上) VM :2C 2G 50G * 5 PS:因后面实验需要向k8 ...
- centos7下安装、配置Nginx、设置Nginx开机自启动
测试环境: [root@centos-linux ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core) [root@cento ...
- Redis单机版安装
1.工具简单介绍 1.博主使用的是Xshell工具 ps:需要设置端口和连接名称,端口一般默认为22,需要的童鞋可以自行百度 2.Redis单机版安装 第一步:安装gcc编译环境 yum instal ...
- Redis单机版安装与部署
Redis官网:http://redis.io 下载Redis wget https://github.com/antirez/redis/archive/3.0.0-rc1.tar.gz 解压并安装 ...
随机推荐
- Oracle数据库结构
之前写了一篇文章<Oracle-知识结构漫谈> 粗略的介绍了Oracle数据库接口,在这里再更加详细的描述一下,当做是对原有知识的巩固,温故知新. Oracle体系结构数据库的体系结构是从 ...
- 牛客小白月赛19 E 「火」烈火燎原 (思维,树)
牛客小白月赛19 E 「火」烈火燎原 (思维,树) 链接:https://ac.nowcoder.com/acm/contest/2272/E来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空 ...
- hive数据仓库表设计之(矮宽表+高窄表)
昨天面对某客户域做表关联的时候发现了. 有两张相同内容的主表.但是表的设计结构并不相同: (每个领域都有主表,每次往这个领域(库)添加新表的时候一般都会join 主表,从而有唯一的主键id) 这两个表 ...
- 在laravel5.8中集成swoole组件----用协程实现的服务端和客户端(二)---静态文件如何部署
目前,较为成熟的技术是采用laravelS组件,注意和laravel 区别laravelS多了一个大写的S,由于laravelS默认监听5200端口,所以laravel项目要做一些调整 例如: 静态文 ...
- [2019HDU多校第一场][HDU 6590][M. Code]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6590 题目大意(来自队友):二维平面上有\(n\)个点,每个点要么是黑色要么是白色,问能否找到一条直线 ...
- python中global的用法——再读python简明教程
今天看了知乎@萧井陌的编程入门指南,想重温一下 <python简明教程>,对global的用法一直不太熟练,在此熟练一下,并实践一下python中list.tuple.set作为参数的区别 ...
- 第四届西安邮电大学acm-icpc校赛 热狗树
题目描述 “我是番茄酱!”“我是黄芥末酱!”“合在一起就是——美式热狗上加的,那个!“热狗树上的每个节点都涂有番茄酱或者黄芥末酱中的一种,这样热狗树就变得美味了~LiMn2O4构造了一颗热狗树,他想 ...
- 「BZOJ 2653」middle「主席树」「二分」
题意 一个长度为\(n\)的序列\(a\),设其排过序之后为\(b\),其中位数定义为\(b[n/2]\),其中\(a,b\)从\(0\)开始标号,除法取下整.给你一个长度为\(n\)的序列\(s\) ...
- 5.13T1Send 题(send)
Send 题(send) [题目描述] 某个国家有
- 安装mongodb-window10版
第一.下载mongodb 官方地址:https://www.mongodb.com/ 第二步mongodb安装 运行mongodb-win32-x86_64-2008plus-ssl-v3.4-lat ...