如题,现在在学习redis,看到了主从配置这一块。然后看到某些做法是配置slave为只读,然后master关闭了rdb。上网看了一下redis主从配置 说是可以使数据库读写分离,减轻数据库压力。我想问一下,除了从服务器不能写之外,哪个地方体现了 读与写分离。我的疑惑是,是否数据库的读写分离需要程序支持才可以?(读的时候将数据源指向slave,写的时候指向master)。如果程序不这样做,那么主从配置是否就没了意义了呢?
高洛峰2017-04-24 09:14:23
(Data layer) read and write separation is transparent to the upper layer (logic layer) which is normal logic. Otherwise there will be coupling. I can’t always use my data service
Change the port and follow the code on the business end.
General read-write separation occurs in the form of middleware or plug-ins, which is transparent to the business logic layer (it also thinks that there is only one
data service in the background, like a reverse proxy), redis has this form. The master determines which one is reading and which one is writing to uniformly schedule the nodes of the cluster. MySQL's read-write separation or master-slave are all accomplished through plug-ins.