第07课:【实战】调试Redis准备工作
7.1 Redis源码下载与编译
Redis源码下载与编译在前面已经说过了,同学们可以去第04课:GDB常用命令详解(上)学习。
编译成功后,会在src目录下生成多个可执行程序,其中redis-server和redis-cli使我们即将调试的程序,进入src目录,使用GDB启动redis-server这个程序。
wzq@wzq-PC:~/Desktop/redis-5.0.3/src$ gdb redis-server
GNU gdb (Debian 7.12-6+b2) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from redis-server...done.
(gdb) r
Starting program: /home/wzq/Desktop/redis-5.0.3/src/redis-server
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
8073:C 14 Jan 2019 10:30:29.039 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8073:C 14 Jan 2019 10:30:29.039 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=8073, just started
8073:C 14 Jan 2019 10:30:29.040 # Warning: no config file specified, using the default config. In order to specify a config file use /home/wzq/Desktop/redis-5.0.3/src/redis-server /path/to/redis.conf
8073:M 14 Jan 2019 10:30:29.040 * Increased maximum number of open files to 10032 (it was originally set to 1024).
[New Thread 0x7ffff67ff700 (LWP 8077)]
[New Thread 0x7ffff5ffe700 (LWP 8078)]
[New Thread 0x7ffff57fd700 (LWP 8079)]
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8073
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' 8073:M 14 Jan 2019 10:30:29.042 # Server initialized
8073:M 14 Jan 2019 10:30:29.042 # 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.
8073:M 14 Jan 2019 10:30:29.042 # 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.
8073:M 14 Jan 2019 10:30:29.042 * Ready to accept connections
以上是redis-server启动成功后的画面。
我们再开一个session,再次进入Redis源码所在的src目录,然后使用GDB启动Redis客户端redis-cli:
wzq@wzq-PC:~/Desktop/redis-5.0.3/src$ gdb redis-cli
GNU gdb (Debian 7.12-6+b2) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from redis-cli...done.
(gdb) r
Starting program: /home/wzq/Desktop/redis-5.0.3/src/redis-cli
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
127.0.0.1:6379>
以上是redis-cli启动成功后的画面。
7.2 通信示例
本课程的学习目的是研究Redis的网络通信模块,为了说明问题方便,我们使用一个简单的通信实例,即通过redis-cli产生一个可以为“hello”,值为“world”的key-value数据,然后得到redis-server的响应。
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379>
读者需要注意的是,我这里说是一个“简单”的实例,其实并不简单。有两个原因:
-我们是在redis-cli(Redis客户端)输入的命令,这个命令经redis-cli处理后封装成网络通信包,通过客户端的网络通信模块发给redis-server,然后redis-server网络通信模块收到后解析出命令,执行命令后得到结果再封装成相关的网络数据包,返回给redis-cli。这个过程中涉及到两端的网络通信模块使我们研究和学习的重点。
-redis-server基本的数据类型都是可以通过类似的命令产生,因此这个例子是一个典型的研究redis的典范。
7.3小结
这节课介绍了我们利用调试Redis源码来学习GDB的一些准备工作和实例代码,有兴趣的读者可以根据本节课中介绍的内容准备一些学习材料,以备后面的进一步学习,从下一课开始我们正式利用GDB来调试Redis。
第07课:【实战】调试Redis准备工作的更多相关文章
- 第07课:GDB 常用命令详解(下)
本课的核心内容: disassemble 命令 set args 和 show args 命令 tbreak 命令 watch 命令 display 命令 disassemble 命令 当进行一些高级 ...
- net core 实战之 redis 负载均衡和"高可用"实现
net core 实战之 redis 负载均衡和"高可用"实现 1.概述 分布式系统缓存已经变得不可或缺,本文主要阐述如何实现redis主从复制集群的负载均衡,以及 redis的& ...
- Redis实战之Redis + Jedis
用Memcached,对于缓存对象大小有要求,单个对象不得大于1MB,且不支持复杂的数据类型,譬如SET 等.基于这些限制,有必要考虑Redis! 相关链接: Redis实战 Redis实战之Redi ...
- 手把手教你写电商爬虫-第三课 实战尚妆网AJAX请求处理和内容提取
版权声明:本文为博主原创文章,未经博主允许不得转载. 系列教程: 手把手教你写电商爬虫-第一课 找个软柿子捏捏 手把手教你写电商爬虫-第二课 实战尚妆网分页商品采集爬虫 看完两篇,相信大家已经从开始的 ...
- Redis实战之Redis + Jedis[转]
http://blog.csdn.net/it_man/article/details/9730605 2013-08-03 11:01 1786人阅读 评论(0) 收藏 举报 目录(?)[-] ...
- 像调试java一样来调试Redis lua
高并发的系统中,redis的使用是非常频繁的,而lua脚本则更是锦上添花.因为lua脚本本身执行的时候是一个事务性的操作,不会掺杂其他外部的命令,所以很多关键的系统节点都会用redis+lua来实现一 ...
- 第七课 GDB调试 (下)
1序言: 通过前面一节第六课 GDB调试 (下)文章,可以掌握理解了gdb调试:怎么启动.运行,打断点.查看变量.甚至改变变量等的知识,今天来大概讲解下调试bug的类型. 2知识点: 2.1 就像之前 ...
- html5--6-68 实战前的准备工作:了解HTML5大纲算法
html5--6-68 实战前的准备工作:了解HTML5大纲算法 学习要点 了解HTML5大纲算法 在html5中有一个很重要的概念,叫做HTML5大纲算法(HTML5 Outliner),它的用途为 ...
- kubebuilder实战之一:准备工作kubebuilder实战之一:准备工作
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
随机推荐
- flex与inline-flex
flex: 将对象作为弹性伸缩盒显示 inline-flex:将对象作为内联块级弹性伸缩盒显示 两者都是使子元素们弹性布局,但是如果是flex,父元素的尺寸不由子元素尺寸动态调整,不设置时默认是100 ...
- base64图片数据类型转numpy的ndarray矩阵类型数据
1.两种方法如下链接 https://www.cnblogs.com/mtcnn/p/9411683.html 2.第一种方法: # coding: utf-8 # python base64 编解码 ...
- 【VS开发】CTimeSpan类
CTimeSpan类. 日期和时间类简介 CTime类的对象表示的时间是基于格林威治标准时间(GMT)的.CTimeSpan类的对象表示的是时间间隔. CTi ...
- 【Linux开发】linux设备驱动归纳总结(十一):写个简单的看门狗驱动
linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- C学习笔记-枚举
枚举定义 可以使用枚举(enumerated type)声明代表整数常量的符号名称,关键字enum创建一个新的枚举类型 实际上,enum常量是int类型的 枚举的本质就是int型的常量 enum sp ...
- 好用的 Chrome 插件
这些好用的 Chrome 插件,提升你的工作效率 本文首发于我的公众号 Linux云计算网络(id: cloud_dev),专注于干货分享,号内有 10T 书籍和视频资源,后台回复「1024」即可 ...
- 第一次实验报告&学习总结
实验报告一&学习总结 一.实验目的 熟悉JDK开发环境 熟练掌握结构化程序设计方法 二.实验内容 打印输出所有的“水仙花数”,所谓“水仙花数”是指一个3位数,其中各位数字立方和等于该数本身.例 ...
- 安装Composer与PsySH
Windows安装Composer 需要开启 openssl 配置:打开 php 目录下的 php.ini,将 extension=php_openssl.dll 前面的分号去掉就可以了. https ...
- <input> disabled 属性
定义和用法 disabled 属性规定应该禁用输入字段. 被禁用的输入字段是无法使用和无法点击的. 如果使用该属性,则会禁用输入字段. 可以对 disabled 属性进行设置,使用户在满足某些条件时( ...
- 刚接触SkyLine的一点小收获与感触
因为刚接触Skyline不到一个星期,也怕把学习到的忘记掉,所以写一点学习到的一些皮毛的东西,赶紧记录一下,怕回头忘记 1.网上关于web端的开发非常多,也有很多牛人分享自己的经验,所以学习起来也相对 ...