当前位置:网站首页>Redis installation and setting up SSDB master-slave environment under Ubuntu 14.04

Redis installation and setting up SSDB master-slave environment under Ubuntu 14.04

2022-07-01 14:49:00 Brother Xing plays with the clouds

Come into contact with in the work redis,Redis It's a very efficient key-value The database of , Widely used in projects , however redis The obvious disadvantage is the processing of memory , At the beginning of the project launch , The memory must be reasonably planned , Otherwise, it is easy to cause memory explosion , Generally, the reasonable memory size is... Of the physical memory of the computer 3/5.

redis Multiple data types are available , What I often use is string 、hash、list、set、sorted set, It can basically meet the requirements of the project for data types . We use redis Of Java client , Provides a series of solutions for redis The command corresponds to api.redis Persistence of provides a variety of strategies , But we didn't do persistence , I studied it myself ,AOF The way I feel is the most reliable , The principle and mysql The binary log of is very similar , It also records the operation information and writes it to the file , from The server Read the log and perform the operation .

In ordinary Intranet development, you may often need to adjust the details of data storage , So if the previous data still resides in memory , Many functions will not work properly , So after adjusting the details , Need to be right redis database flushdb operation .

redis And ssdb It is suitable for use in some scenes , For example, some data can only remain in the database 2 minute , similar YY channel T people , Fix it for a few minutes before you come in , You can use setex key seconds value command , Then judge whether it is expired and pass exists key command .

redis Common command website :http://redis.readthedocs.org/en/latest/  covers redis Orders and demo.

On the road ssdb Say before redis, because ssdb Very compatible redis Of api. yes redis A good substitute for .

ssdb be relative to redis It has many advantages : yes redis Database 100 Times the capacity , It can store billions of data . relative redis Come on , It takes up very little memory . So I downloaded it myself ssdb, Here are ssdb The process of building .

Ubuntu 14.04 Next Redis install And simple tests http://www.linuxidc.com/Linux/2014-05/101544.htm

Redis colony Detailed documents http://www.linuxidc.com/Linux/2013-09/90118.htm

Ubuntu 12.10 Lower installation Redis( Graphic, )+ Jedis Connect Redis http://www.linuxidc.com/Linux/2013-06/85816.htm

Redis series - Installation, deployment and maintenance http://www.linuxidc.com/Linux/2012-12/75627.htm

CentOS 6.3 install Redis http://www.linuxidc.com/Linux/2012-12/75314.htm

Redis The configuration file redis.conf Detailed explanation http://www.linuxidc.com/Linux/2013-11/92524.htm

Environmental Science :Ubuntu 14.04

virtual machine A: 192.168.1.251

virtual machine B: 192.168.1.252

gateway : 192.168.1.1

My two virtual machines are installed on different physical machines , But they all use bridging ,ip The addresses are all in the same ip paragraph .

Both virtual machines are installed online ssdb.

wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip

unzip master

cd ssdb-master

make

sudo make install

These in ssdb You can find it on the official website ,http://www.ideawu.com/ssdb/zh_cn/.

ssdb Master slave construction is actually very simple , You only need two virtual machines ssdb Found under installation directory ssdb.conf.

sudo vi ssdb.conf

modify server Under the ip Default for virtual machine IP Address .

virtual machine A:

server:

ip:192.168.1.251

port:8888  // I haven't changed my port , Use default

virtual machine B:

server:

ip:192.168.1.252

port:8888

This is the basic configuration .

Now as long as A For ssdb.conf The configuration :

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

Be careful : In the above configuration process , Never use the space bar , Use tab.

Now you can start ssdb 了 .

./ssdb-server ssdb.conf

It can be used later ssdb The command-line tools provided to operate .

virtual machine A:    ./ssdb-cli -h 192.168.1.251 -p 8888

virtual machine B:    ./ssdb-cli -h 192.168.1.252 -p 8888

原网站

版权声明
本文为[Brother Xing plays with the clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207011444341073.html