Redis

redis

☆樱花仙子☆ 提交于 2021-02-08 02:40:07
一。基本概念 Redis和MongoDB是当前使用最广泛的NoSQL,而就Redis技术而言,它的性能十分优越,可以支持每秒十几万此的读/写操作,其性能远超数据库,并且还支持集群、分布式、主从同步等配置,原则上可以无限扩展,让更多的数据存储在内存中,更让人欣慰的是它还支持一定的事务能力,这保证了高并发的场景下数据的安全和一致性。它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型) 二。redis安装 $ wget http://download.redis.io/releases/redis-5.0.4.tar.gz $ tar xzf redis-5.0.4.tar.gz $ cd redis-5.0.4 $ make $ make install 在服务器端启动redis-server 在内置的客户端启动redis-cli 客户端进行测试: 客户端关闭服务器 三。redis常用数据类型和命令 redis中所有的数据都是通过键值对的方式存储的,即key:value。key是字符串类型的,value可以是字符串,hash,list,set,sortedset 1.字符串类型(key:string) 1.添加key:value set key value 2

repl_backlog_buffer和replication buffer理解比较混淆,我大概解释一下:

心已入冬 提交于 2021-02-07 21:38:41
repl_backlog_buffer:就是上面我解释到的,它是为了从库断开之后,如何找到主从差异数据而设计的环形缓冲区,从而避免全量同步带来的性能开销。 如果从库断开时间太久,repl_backlog_buffer环形缓冲区被主库的写命令覆盖了,那么从库连上主库后只能乖乖地进行一次全量同步, 所以repl_backlog_buffer配置尽量大一些,可以降低主从断开后全量同步的概率。 而在repl_backlog_buffer中找主从差异的数据后,如何发给从库呢?这就用到了replication buffer。 replication buffer:Redis和客户端通信也好,和从库通信也好, Redis都需要给分配一个 内存buffer进行数据交互,客户端是一个client,从库也是一个client, 我们每个client连上Redis后,Redis都会分配一个client buffer,所有数据交互都是通过这个buffer进行的: Redis先把数据写到这个buffer中, 然后再把buffer中的数据发到client socket中再通过网络发送出去,这样就完成了数据交互。 所以主从在增量同步时,从库作为一个client,也会分配一个buffer, 只不过这个buffer专门用来传播用户的写命令到从库,保证主从数据一致,我们通常把它叫做replication buffer。

零基础Python学习路线图,Python学习不容错过

不羁岁月 提交于 2021-02-07 21:35:46
最近有很多人在问小编Python培训方面的问题,一开始小编还挺疑惑,后来特地请教了一下度娘,果真互联网行业的风向变了,近几年Python的受欢迎程度可谓是扶摇直上,当然了学习的人也是愈来愈多。一些学习Python的小白在学习初期,总希望能够得到一份Python学习路线图,小编经过多方汇总为大家汇总了一份Python学习路线图。 Python学习路线一:Python基础 必学知识:【Linux基础】【Python基础语法】【Python字符串】【文件操作】【异常处理】【Python面向对象】【项目实战】 路线讲解:该路线循序渐进,科学合理,帮助学习者建立正确的编程思想,具备基本的编程能力; Python学习路线二:Python高级编程 必学知识:【Python平台迁移Linux】【Python常用第三方库】【Python高级语法】【Python正则表达式】【网路编程】【系统编程】【数据结构与算法】【项目实战】 路线讲解:该路线强调数据结构和算法的学习,着重提升学习者的编程核心能力;使学习者能够熟练掌握Python高级用法及网络相关知识,能够独立承担Python网络相关的开发; Python学习路线三:web前端开发 必学知识:【HTML】【CSS】【UI基础】【JavaScript】【DOM】【事件】【jQuery】【混合开发】【项目实战】 路线讲解

Node JS Redis Client Connection Retry

跟風遠走 提交于 2021-02-07 20:51:26
问题 Currently I'm using https://github.com/mranney/node_redis as my node redis client. client.retry_delay is set to 250ms default. I tried connecting to redis and once connection was successful, I manually stopped the redis server to see whether client.retry_delay works. But I didn't see it working. The following log messages are logged on ready & end events on redisClients created using createClient : [2012-03-30 15:13:05.498] [INFO] Development - Node Application is running on port 8090 [2012

Node JS Redis Client Connection Retry

断了今生、忘了曾经 提交于 2021-02-07 20:49:23
问题 Currently I'm using https://github.com/mranney/node_redis as my node redis client. client.retry_delay is set to 250ms default. I tried connecting to redis and once connection was successful, I manually stopped the redis server to see whether client.retry_delay works. But I didn't see it working. The following log messages are logged on ready & end events on redisClients created using createClient : [2012-03-30 15:13:05.498] [INFO] Development - Node Application is running on port 8090 [2012

记一次服务器被挖矿程序占用的解决过程

时光怂恿深爱的人放手 提交于 2021-02-07 17:09:42
大家好!我是每天为大家分享好文的柠檬!与你一起成长~ 有需要体系化黑客渗透视频教程可看文末 今天分享一篇老文,重在思路!希望对你们有帮助~ 公司有台做voip的服务器最近CPU总是跑满,这机器自从交给厂家搭好环境后基本就没怎么管它,于是进去查看进程,top了下(见下图) 这个叫wnTKYg的进程很诡异,已经把CPU吃光了,上网一查,原来是中了挖矿的马。 (啊,我的天。这只是一个单核1G内存的阿里云主机) 既然被***了,那就得干掉它,下面是解决过程: 1:第一步要先找到这个wnTKYg文件实体,对了还有一个叫ddg.2020的进程。 [root @alitest ~] $ find / -name wnTKYg/tmp/wnTKYg[root @alitest ~] $ find / -name ddg* /tmp/ddg . 2020 2:接着把这两个文件的可执行权限拿掉。 [root @alitest ~] $ cd /tmp[root @alitest /tmp] $ chmod -x ddg. 2020 wnTKYg 3:杀掉这该死的进程。 [root @alitest /tmp]$ ps -ef | grep -v grep | egrep 'wnTKYg | ddg' | awk '{print $2}' | xargs kill -9 4:清除无用的定时任务。

Set Cache Redis Expiration to 1 year

孤街醉人 提交于 2021-02-07 14:38:37
问题 How to set Redis Cache expiration to 1 year? I tried to set the long value on the xml configuration to : 31556952000 (1 year), but then it caught an exception that type Integer doesn't recognize the value as Integer. I tried to search at Google, and it says that Integer maximum value is up to 2147483647 , which means, if I set to that maximum value, I only get my cache expires on 24 days. Here is my applicationContext.xml (I omitted unnecessary code) : ... <cache:annotation-driven /> <bean id

Set Cache Redis Expiration to 1 year

送分小仙女□ 提交于 2021-02-07 14:35:44
问题 How to set Redis Cache expiration to 1 year? I tried to set the long value on the xml configuration to : 31556952000 (1 year), but then it caught an exception that type Integer doesn't recognize the value as Integer. I tried to search at Google, and it says that Integer maximum value is up to 2147483647 , which means, if I set to that maximum value, I only get my cache expires on 24 days. Here is my applicationContext.xml (I omitted unnecessary code) : ... <cache:annotation-driven /> <bean id

Setting dynamic path in the redis.conf using the Environment variable

寵の児 提交于 2021-02-07 13:47:02
问题 I have a environment variable MY_HOME which has a path to a directory /home/abc Now, I have a redis.conf file In which I need to set this path like this **redis.conf** pidfile $MY_HOME/local/var/pids/redis.pid logfile $MY_HOME/local/var/log/redis.log dir $MY_HOME/local/var/lib/redis/ like we do in command line, so that my config file picks the path based on the Environment variable. 回答1: Because Redis can read its config from stdin , I do something very similar to what @jolestar suggested. I

Setting dynamic path in the redis.conf using the Environment variable

痴心易碎 提交于 2021-02-07 13:46:01
问题 I have a environment variable MY_HOME which has a path to a directory /home/abc Now, I have a redis.conf file In which I need to set this path like this **redis.conf** pidfile $MY_HOME/local/var/pids/redis.pid logfile $MY_HOME/local/var/log/redis.log dir $MY_HOME/local/var/lib/redis/ like we do in command line, so that my config file picks the path based on the Environment variable. 回答1: Because Redis can read its config from stdin , I do something very similar to what @jolestar suggested. I