当前位置:网站首页>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证券开户是合理安全的吗,怎么讲
- MongoDB第二話 -- MongoDB高可用集群實現
- 643. Maximum average number of subarrays I
- SQLAchemy 常用操作
- Research Report on the development trend and competitive strategy of the global electromagnetic flowmeter industry
- [15. Interval consolidation]
- 音乐播放器开发实例(可毕设)
- sqlilabs less10
- 241. Design priorities for operational expressions
- 微服务开发步骤(nacos)
猜你喜欢

博文推荐 | 深入研究 Pulsar 中的消息分块

Rearrangement of overloaded operators

One of the first steps to redis

【15. 区间合并】

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

【14. 区间和(离散化)】

微服务开发步骤(nacos)

sqlilabs less-11~12

Phpcms realizes the direct Alipay payment function of orders

Summary of leetcode's dynamic programming 5
随机推荐
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
Problem note - Oracle 11g uninstall
Minimum spanning tree and bipartite graph in graph theory (acwing template)
Sorting learning sorting
What problems should be considered for outdoor LED display?
[leetcode 324] swing sorting II thinking + sorting
2022-2-15 learning the imitation Niuke project - post in Section 2
Yyds dry goods inventory hcie security day13: firewall dual machine hot standby experiment (I) firewall direct deployment, uplink and downlink connection switches
如何看待国企纷纷卸载微软Office改用金山WPS?
241. Design priorities for operational expressions
MongoDB第二话 -- MongoDB高可用集群实现
sqlilabs less13
Mongodb second call -- implementation of mongodb high availability cluster
定了!2022海南二级造价工程师考试时间确定!报名通道已开启!
JVM第一话 -- JVM入门详解以及运行时数据区分析
MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology
Leetcode (69) -- square root of X
About the use of HTTP cache validation last modified and Etag
After twists and turns, I finally found the method of SRC vulnerability mining [recommended collection]
Quelle valeur le pdnp peut - il apporter aux gestionnaires de produits? Vous savez tout?