当前位置:网站首页>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
边栏推荐
- WebSocket(简单体验版)
- sqlilabs less-8
- Basis of target detection (NMS)
- How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?
- Ensure production safety! Guangzhou requires hazardous chemical enterprises to "not produce in an unsafe way, and keep constant communication"
- 博文推荐 | 深入研究 Pulsar 中的消息分块
- [零基础学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
- Tensorflow 2. X realizes iris classification
猜你喜欢

sqlilabs less9

【R语言数据科学】:机器学习常见评估指标
![[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial](/img/44/b65aaf11b1e632f2dab55b6fc699f6.jpg)
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial

How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?

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
![[leetcode 324] 摆动排序 II 思维+排序](/img/cb/26d89e1a1f548b75a5ef9f29eebeee.png)
[leetcode 324] 摆动排序 II 思维+排序

2022-2-15 learning xiangniuke project - Section 4 business management
![[Verilog quick start of Niuke question series] ~ use functions to realize data size conversion](/img/e1/d35e1d382e0e945849010941b219d3.png)
[Verilog quick start of Niuke question series] ~ use functions to realize data size conversion

Yyds dry goods inventory hcie security day13: firewall dual machine hot standby experiment (I) firewall direct deployment, uplink and downlink connection switches

241. Design priorities for operational expressions
随机推荐
官宣:Apache Doris 顺利毕业,成为 ASF 顶级项目!
Some thoughts on software testing
Leetcode (69) -- square root of X
Opencv interpolation mode
Leetcode(69)——x 的平方根
Research Report on the development trend and competitive strategy of the global aviation leasing service industry
qt捕获界面为图片或label显示
NPDP产品经理国际认证报名有什么要求?
Research Report on the development trend and competitive strategy of the global ultrasonic scalpel system industry
[14. Interval sum (discretization)]
Research Report on development trend and competitive strategy of global vibration polishing machine industry
关于重载运算符的再整理
【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
定了!2022海南二级造价工程师考试时间确定!报名通道已开启!
Sorting learning sorting
About the use of HTTP cache validation last modified and Etag
sqlilabs less-11~12
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
[dynamic programming] interval dp:p1005 matrix retrieval
Is it reasonable and safe for securities companies to open accounts for 10000 free securities? How to say