Home Database Mysql Tutorial mysql proxy 读写分离脚本的问题_MySQL

mysql proxy 读写分离脚本的问题_MySQL

Jun 01, 2016 pm 02:01 PM
release version number

     提示:听说mysql proxy 0.7.0即将发布,正好前些日子从bzr上获取mysql proxy的代码编译过,看看当时bzr的版本号,和现在也差不了多少。


听说mysql proxy 0.7.0即将发布,正好前些日子从bzr上获取mysql proxy的代码编译过,看看当时bzr的版本号,和现在也差不了多少。在这期间,我又花了一些时间把mysql配置成读写分离,出了不少状况,由于使用的人不太多,解决问题超费劲――搜索不到有帮助的内容啊。

但是我可能是比较幸运的,最后成功的实现了读写分离,目前在开发环境运行的比较稳定,所以有必要做个笔记分享一下。

读写分离脚本的问题
刚启动mysql proxy的时候,经常报错 -- "Mysql server has gone away"。我进一步缩小了可能出问题的范围(把环境简化是很重要的查错手段),比如只连接一个mysql,或者只连接本机的mysql,没有太大帮助,最后是在mysql proxy的日志文件中看到些蛛丝马迹:

(critical) proxy-plugin.c:1367: (connect_server) [string "/usr/local/share/mysql-proxy/r..."]:69: .address is deprecated. Use .src.name or .dst.name instead
(critical) (read_query) [string "/usr/local/share/mysql-proxy/r..."]:179: .address is deprecated. Use .src.name or .dst.name instead
(critical) proxy-plugin.c.1115: I have no server backend, closing connection

在mysql proxy的论坛上看到有人碰到类似的问题,很简单,读写分离的lua脚本还是旧的,0.6.1时代的产物了,更糟糕的是,即便是即将发布的0.7.0,rw-splitting.lua也是旧版本的。lua脚本中的.address需要替换成.src.name或者.dst.name。

解决办法 ―― 下载更新之后的rw-splitting.lua,情况会好转。

使用prepare方法无法获得结果
我在测试代码中采用php的pdo_mysql,单独连接mysql是毫无问题的,然而配合mysql proxy使用则是屡屡受挫,查询经常没有结果返回,比较随机,从日志中也找不到有帮助的内容。这次没有找到解决办法,所以我绕了过去,在连接mysql 的时候使用伪prepare的方式:

 

PHP:
$option = array(PDO::ATTR_EMULATE_PREPARES => 1);
据称emulate方式的性能比prepare要好,所以这也算安慰奖了。

专门的lua脚本分支
lua脚本开发滞后,是一个比较严重的问题,所以在邮件组上看到有个新的lua脚本分支出来 ―― https://launchpad.net/mysql-proxy-lua-scripts。希望开发速度能跟上来。

 


keepalive参数
mysql proxy还不算太稳定,偶尔crash我也不觉得惊讶,所以新增的keepalive参数很有用。在proxy启动的时候,加上--keepalive参数,它便会努力保持proxy的运行状态,停止了也会自动重启。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu How to publish works on Xiaohongshu How to publish articles and pictures on Xiaohongshu Mar 22, 2024 pm 09:21 PM

You can view various contents on Xiaohongshu, which can provide you with various help and help you discover a better life. If you have anything you want to share, you can post it here so that everyone can take a look. , and at the same time, it can bring you profits. It is very cost-effective. If you don’t know how to publish your works here, you can check out the tutorial. You can use this software every day and publish various contents to help everyone use it better. Don’t miss it if you need it! 1. Open Xiaohongshu and click the plus icon below. 2. There are [Video] [Picture] [Live Picture] options here; select the content you want to publish and click to check. 3. Select [Next] on the content editing page. 4. Enter the text content you want to publish and click [Publish Pen]

Why can't Xiaohongshu publish videos of works? How does it publish its work? Why can't Xiaohongshu publish videos of works? How does it publish its work? Mar 21, 2024 pm 06:36 PM

With the rapid development of social media, short video platforms have become the main channel for many users to express themselves and share their lives. Many users may encounter various problems when publishing videos of their works on Xiaohongshu. This article will discuss the reasons that may cause the video publishing of Xiaohongshu works to fail and provide the correct publishing method. 1. Why can’t Xiaohongshu publish videos of works? The Xiaohongshu platform may occasionally experience system failures, which may be caused by system maintenance or upgrades. In this case, users may encounter the problem of being unable to publish videos of their works. Users need to wait patiently for the platform to return to normal before trying to publish. An unstable or slow network connection may prevent users from posting videos of their work on Xiaohongshu. Users should confirm their network environment to ensure that the connection is stable and

Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Why can't Xiaohongshu be released? What should I do if the content published by Xiaohongshu cannot be displayed? Mar 21, 2024 pm 07:47 PM

As a lifestyle sharing platform, Xiaohongshu has attracted a large number of users to share their daily life and grow products. Many users have reported that their published content cannot be displayed. What is going on? This article will analyze the possible reasons why Xiaohongshu cannot be released and provide solutions. 1. Why can’t Xiaohongshu be released? Xiaohongshu implements strict community guidelines and has zero tolerance for publishing advertisements, spam, vulgar content, etc. If the user's content violates the regulations, the system will block it and the content will not be displayed. Xiaohongshu requires users to publish high-quality and valuable content, and the content needs to be unique and innovative. If the content is too generic and lacks innovation, it may not pass review and therefore not be displayed on the platform. 3. Account abnormality

How to delete Xiaohongshu releases? How to recover after deletion? How to delete Xiaohongshu releases? How to recover after deletion? Mar 21, 2024 pm 05:10 PM

As a popular social e-commerce platform, Xiaohongshu has attracted a large number of users to share their daily life and shopping experiences. Sometimes we may inadvertently publish some inappropriate content, which needs to be deleted in time to better maintain our personal image or comply with platform regulations. 1. How to delete Xiaohongshu releases? 1. Log in to your Xiaohongshu account and enter your personal homepage. 2. At the bottom of the personal homepage, find the "My Creations" option and click to enter. 3. On the "My Creations" page, you can see all published content, including notes, videos, etc. 4. Find the content that needs to be deleted and click the "..." button on the right. 5. In the pop-up menu, select the "Delete" option. 6. After confirming the deletion, the content will disappear from your personal homepage and public page.

How to publish works on Xiaohongshu app? Tutorial on publishing works on Xiaohongshu app in five minutes How to publish works on Xiaohongshu app? Tutorial on publishing works on Xiaohongshu app in five minutes Mar 12, 2024 pm 05:10 PM

How does the Xiaohongshu app publish works? Many friends know that there are a large number of creative works and a strong dating circle in this software. For users who are new to this software, they probably don’t know how to publish their works, so that more people can watch the other side of you. If you still don’t know how to publish the works in it, then quickly refer to the five-minute tutorial on publishing works on the Xiaohongshu app recommended by the editor of this site. Tutorial on publishing works in Xiaohongshu app in five minutes 1. Click [Three] As shown in the picture, click [Three] pointed by the red arrow in the upper left corner. 2. Click [Creation Center] As shown in the picture, click [Creation Center] pointed by the red arrow. 3. Click [Go to Publish] as shown in the picture,

When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? When is the best time to publish Xiaohongshu? Where does it post the most traffic recommendations from? Mar 21, 2024 pm 08:11 PM

In today's social network era, Xiaohongshu has become an important platform for young people to share their lives and obtain information. Many users hope to attract more attention and traffic by publishing content on Xiaohongshu. So, when is the best time to post content? This article will explore in detail the selection of Xiaohongshu’s publishing time and the publishing location with the most traffic recommendations. 1. When is the best time to publish Xiaohongshu? The best time to publish content on Xiaohongshu is usually during periods of high user activity. According to the characteristics and behavioral habits of Xiaohongshu users, there are several time periods that are more appropriate. During the time period from 7 pm to 9 pm, most users have returned home from get off work and started browsing content on their mobile phones in search of relaxation and entertainment. Therefore, content posted during this period is more likely to attract users

How to publish Xiaohongshu video works? What should I pay attention to when posting videos? How to publish Xiaohongshu video works? What should I pay attention to when posting videos? Mar 23, 2024 pm 08:50 PM

With the rise of short video platforms, Xiaohongshu has become a platform for many people to share their lives, express themselves, and gain traffic. On this platform, publishing video works is a very popular way of interaction. So, how to publish Xiaohongshu video works? 1. How to publish Xiaohongshu video works? First, make sure you have a video content ready to share. You can use your mobile phone or other camera equipment to shoot, but you need to pay attention to the image quality and sound clarity. 2. Edit the video: In order to make the work more attractive, you can edit the video. You can use professional video editing software, such as Douyin, Kuaishou, etc., to add filters, music, subtitles and other elements. 3. Choose a cover: The cover is the key to attracting users to click. Choose a clear and interesting picture as the cover to attract users to click on it.

The lowest price is 3999 yuan! Consumer-grade real AR glasses Thunderbird X2 officially released The lowest price is 3999 yuan! Consumer-grade real AR glasses Thunderbird X2 officially released Oct 13, 2023 pm 05:25 PM

[CNMO News] At 14:00 on October 13, Beijing time, Thunderbird Technology officially held the Thunderbird innovative new product launch conference. At this press conference, Thunderbird brought consumers real consumer-grade AR glasses-Thunderbird Users of commercial products can enjoy a preferential price of 3,999 yuan. Thunderbird X2 adopts a wireless integrated design, which can be used like ordinary glasses without blocking normal eyesight. The new glasses are also equipped with a front-facing camera, with a 5P lens and 16 million pixels, which can bring a first-person view. At the same time, it also supports screen-based photography. Just slide the lens corner to better capture those fleeting moments. picture. The new AR glasses are also equipped with light

See all articles