当前位置:网站首页>Redis安装及Ubuntu 14.04下搭建ssdb主从环境
Redis安装及Ubuntu 14.04下搭建ssdb主从环境
2022-07-01 14:46:00 【星哥玩云】
在工作中接触到了redis,Redis是一个非常高效的key-value的数据库,在项目中广泛使用,但是redis很明显的缺点是对于内存的处理,在项目上线之初,必须对内存规划合理,否则很容易出现内存爆了的现象,一般较合理的内存大小为电脑物理内存的3/5。
redis提供了多种数据类型,我经常使用的为string 、hash、list、set、sorted set,基本能满足项目对于数据类型的要求。我们使用的是redis的Java客户端,提供了一系列针对redis命令对应的api。redis的持久化提供了多种策略,但我们没有去做持久化,自己研究了下,AOF方式感觉是最可靠的,原理和mysql的二进制日志很类似,也是将操作信息记录下来写到文件,从服务器去读取日志并执行操作。
在平常内网开发中可能经常需要调整数据存储细节,所以如果之前的数据依然驻留在内存中,会导致很多功能无法正常运行,所以在调整细节之后,需要对redis数据库flushdb操作。
redis与ssdb在某些场景很适合使用,比如某些数据在数据库中只能残留2分钟,类似YY频道T人,固定几分钟后才能进来,就可以使用setex key seconds value命令,之后判断是否过期可以通过exists key 命令。
redis常用命令网站:http://redis.readthedocs.org/en/latest/ 涵盖了redis的命令及demo.
在搭ssdb前说redis,因为ssdb很好的兼容了redis的api。是redis的很好替代品。
ssdb相对于redis来说有很多优点:是redis数据库的100倍容量,可以存储几十亿的数据量。相对redis来说,占用内存很少。所以自己也去下载了ssdb,以下是ssdb搭建的过程。
Ubuntu 14.04下Redis安装及简单测试 http://www.linuxidc.com/Linux/2014-05/101544.htm
Redis集群明细文档 http://www.linuxidc.com/Linux/2013-09/90118.htm
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis http://www.linuxidc.com/Linux/2013-06/85816.htm
Redis系列-安装部署维护篇 http://www.linuxidc.com/Linux/2012-12/75627.htm
CentOS 6.3安装Redis http://www.linuxidc.com/Linux/2012-12/75314.htm
Redis配置文件redis.conf 详解 http://www.linuxidc.com/Linux/2013-11/92524.htm
环境:Ubuntu 14.04
虚拟机A: 192.168.1.251
虚拟机B: 192.168.1.252
网关: 192.168.1.1
我的两台虚拟机是分别装在不同的物理机上,但都采用的是桥接方式,ip地址都是在同一个ip段。
在两台虚拟机下分别都在线安装下ssdb.
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
unzip master
cd ssdb-master
make
sudo make install
这些在ssdb官网都能找到,http://www.ideawu.com/ssdb/zh_cn/。
ssdb主从搭建其实非常之简单,你只需要在两台虚拟机ssdb安装目录下找到ssdb.conf.
sudo vi ssdb.conf
修改server 下的ip为虚拟机默认的IP地址。
虚拟机A:
server:
ip:192.168.1.251
port:8888 //我端口没改,用默认
虚拟机B:
server:
ip:192.168.1.252
port:8888
这是最基本的配置。
现在只要在A的基础上对于ssdb.conf下配置:
replication:
slaveof:
# to identify a master even if it moved(ip, port changed)
# if set to empty or not defined, ip:port will be used.
id: svc_2
# sync|mirror, default is sync
type: sync
ip: 192.168.1.252
port: 8888
注意:在以上的配置过程中,千万不要用空格键,使用tab.
现在可以启动ssdb了。
./ssdb-server ssdb.conf
之后就可以使用ssdb提供的命令行工具来操作了。
虚拟机A: ./ssdb-cli -h 192.168.1.251 -p 8888
虚拟机B: ./ssdb-cli -h 192.168.1.252 -p 8888
边栏推荐
- 券商万1免5证券开户是合理安全的吗,怎么讲
- [dynamic programming] interval dp:p1005 matrix retrieval
- Provincial election + noi Part IX game theory
- [stage life summary] I gave up the postgraduate entrance examination and participated in the work. I have successfully graduated and just received my graduation certificate yesterday
- In hot summer, please put away this safe gas use guide!
- Generate random numbers (4-bit, 6-bit)
- Guess lantern riddles, not programmers still can't understand?
- 炎炎夏日,这份安全用气指南请街坊们收好!
- Is the futures company found on Baidu safe? How do futures companies determine the regularity
- 首届技术播客月开播在即
猜你喜欢

MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology

对于编程思想和能力有重大提升的书有哪些?

Internet hospital system source code hospital applet source code smart hospital source code online consultation system source code

Use the right scene, get twice the result with half the effort! Full introduction to the window query function and usage scenarios of tdengine

sqlilabs less13

Sqlachemy common operations

微服务开发步骤(nacos)

如何看待国企纷纷卸载微软Office改用金山WPS?

Basis of target detection (NMS)

sqlilabs less10
随机推荐
[dynamic programming] p1004 grid access (four-dimensional DP template question)
tensorflow2-savedmodel convert to pb(frozen_graph)
券商万1免5证券开户是合理安全的吗,怎么讲
Pat 1121 damn single (25 points) set
Mongodb second call -- implementation of mongodb high availability cluster
Mongodb second talk - - mongodb High available Cluster Implementation
JVM second conversation -- JVM memory model and garbage collection
【阶段人生总结】放弃考研,参与到工作中,已经顺利毕业了,昨天刚领毕业证
sqlilabs less10
sqlilabs less10
Provincial election + noi Part XI others
MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology
使用net core 6 c# 的 NPOI 包,讀取excel..xlsx單元格內的圖片,並存儲到指定服務器
phpcms实现订单直接支付宝支付功能
sqlilabs less-11~12
The first word of JVM -- detailed introduction to JVM and analysis of runtime data area
Tensorflow 2. X realizes iris classification
111. Minimum depth of binary tree
Provincial election + noi Part IX game theory
Is the futures company found on Baidu safe? How do futures companies determine the regularity