当前位置:网站首页>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
边栏推荐
- MongoDB第二话 -- MongoDB高可用集群实现
- Don't want to knock the code? Here comes the chance
- En utilisant le paquet npoi de net Core 6 c #, lisez Excel.. Image dans la cellule xlsx et stockée sur le serveur spécifié
- Sqlachemy common operations
- Error-tf.function-decorated function tried to create variables on non-first call
- Research Report on the development trend and competitive strategy of the global diamond suspension industry
- Research Report on the development trend and competitive strategy of the global indexable milling cutter industry
- [dynamic programming] p1004 grid access (four-dimensional DP template question)
- Vnctf2022 open web gocalc0
- NPDP产品经理国际认证报名有什么要求?
猜你喜欢

The State Administration of Chia Tai market supervision, the national development and Reform Commission and the China Securities Regulatory Commission jointly reminded and warned some iron ores

The first word of JVM -- detailed introduction to JVM and analysis of runtime data area

sqlilabs less-11~12

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

Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界

sqlilabs less-11~12

Salesforce, Johns Hopkins, Columbia | progen2: exploring the boundaries of protein language models

One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse

Why did you win the first Taosi culture award of 20000 RMB if you are neither a top R & D expert nor a sales Daniel?

Microservice development steps (Nacos)
随机推荐
Is the futures company found on Baidu safe? How do futures companies determine the regularity
2022-2-15 learning the imitation Niuke project - Section 3 post details
Some thoughts on software testing
Research Report on the development trend and competitive strategy of the global diamond suspension industry
One of the first steps to redis
Take you to API development by hand
sqlilabs less13
sqlilabs less-8
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
Websocket (simple experience version)
241. 为运算表达式设计优先级
In hot summer, please put away this safe gas use guide!
券商万1免5证券开户是合理安全的吗,怎么讲
关于重载运算符的再整理
C learning notes (5) class and inheritance
Research Report on the development trend and competitive strategy of the global display filter industry
互联网医院系统源码 医院小程序源码 智慧医院源码 在线问诊系统源码
Research Report on the development trend and competitive strategy of the global powder filling machine industry
MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
Guess lantern riddles, not programmers still can't understand?