当前位置:网站首页>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
边栏推荐
- [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
- [Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize
- MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology
- 数据湖系列之一 | 你一定爱读的极简数据平台史,从数据仓库、数据湖到湖仓一体
- What are the requirements for NPDP product manager international certification registration?
- After twists and turns, I finally found the method of SRC vulnerability mining [recommended collection]
- JVM performance tuning and practical basic theory part II
- Rearrangement of overloaded operators
- Research Report on the development trend and competitive strategy of the global indexable milling cutter industry
- [dynamic programming] interval dp:p1005 matrix retrieval
猜你喜欢

首届技术播客月开播在即

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

Basis of target detection (NMS)

What problems should be considered for outdoor LED display?

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

Details of appium key knowledge

Phpcms realizes the direct Alipay payment function of orders

Music player development example (can be set up)

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

如何看待国企纷纷卸载微软Office改用金山WPS?
随机推荐
问题随记 —— Oracle 11g 卸载
Websocket (simple experience version)
[R language data science]: common evaluation indicators of machine learning
写在Doris毕业后的第一天
[14. Interval sum (discretization)]
JVM第二话 -- JVM内存模型以及垃圾回收
[Verilog quick start of Niuke question series] ~ use functions to realize data size conversion
期末琐碎知识点再整理
Microservice development steps (Nacos)
JVM second conversation -- JVM memory model and garbage collection
[Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize
tensorflow2-savedmodel convert to tflite
从零开发小程序和公众号【第三期】
2022-2-15 learning the imitation Niuke project - Section 3 post details
sqlilabs less-11~12
JVM performance tuning and practical basic theory part II
微服务开发步骤(nacos)
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
职场太老实,总被欺负怎么办?
MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology