Wishlist 0 ¥0.00

MySQL 重要参数 innodb_flush_log_at_trx_commit 和 sync_binlog

innodb_flush_log_at_trx_commit

提交事务的时候将 redo 日志写入磁盘中,所谓的 redo 日志,就是记录下来你对数据做了什么修改,比如对 “id=10 这行记录修改了 name 字段的值为 xxx”,这就是一个日志。如果我们想要提交一个事务了,此时就会根据一定的策略把 redo 日志从 redo log buffer 里刷入到磁盘文件里去。此时这个策略是通过 innodb_flush_log_at_trx_commit 来配置的,他有几个选项。
值为0 : 提交事务的时候,不立即把 redo log buffer 里的数据刷入磁盘文件的,而是依靠 InnoDB 的主线程每秒执行一次刷新到磁盘。此时可能你提交事务了,结果 mysql 宕机了,然后此时内存里的数据全部丢失。
值为1 : 提交事务的时候,就必须把 redo log 从内存刷入到磁盘文件里去,只要事务提交成功,那么 redo log 就必然在磁盘里了。注意,因为操作系统的“延迟写”特性,此时的刷入只是写到了操作系统的缓冲区中,因此执行同步操作才能保证一定持久化到了硬盘中。
值为2 : 提交事务的时候,把 redo 日志写入磁盘文件对应的 os cache 缓存里去,而不是直接进入磁盘文件,可能 1 秒后才会把 os cache 里的数据写入到磁盘文件里去。
可以看到,只有1才能真正地保证事务的持久性,但是由于刷新操作 fsync() 是阻塞的,直到完成后才返回,我们知道写磁盘的速度是很慢的,因此 MySQL 的性能会明显地下降。如果不在乎事务丢失,0和2能获得更高的性能。

# 查询
select @@innodb_flush_log_at_trx_commit;

sync_binlog

该参数控制着二进制日志写入磁盘的过程。

该参数的有效值为0 、1、N:

0:默认值。事务提交后,将二进制日志从缓冲写入磁盘,但是不进行刷新操作(fsync()),此时只是写入了操作系统缓冲,若操作系统宕机则会丢失部分二进制日志。

1:事务提交后,将二进制文件写入磁盘并立即执行刷新操作,相当于是同步写入磁盘,不经过操作系统的缓存。

N:每写N次操作系统缓冲就执行一次刷新操作。

将这个参数设为1以上的数值会提高数据库的性能,但同时会伴随数据丢失的风险。
二进制日志文件涉及到数据的恢复,以及想在主从之间获得最大的一致性,那么应该将该参数设置为1,但同时也会造成一定的性能损耗。

笔记本的加号怎么输入?

笔记本电脑输入+号的方法和一般键盘的输入方法一样,就是按住Shift,再按“=”。


但是,遇到没有小键盘的笔记本电脑,需要输入+时,需要首先按Fn+NumLock。

Joomla doesn’t send messages. Could not instantiate mail function.

In this topic, we will consider common problems with Joomla mail sending.

The most frequent error is  “Could not instantiate mail function.”, also sometimes you don’t get any errors, but messages do not come anyway. Below you will find solutions for these problems, but if you are using SMTP protocol, check this article.

1. Maybe you are configuring the contact us form on the local server. Some local servers like Denver or WAMP don’t send messages by default. After moving your site to the hosting, the problem with mailing will disappear.

2. Messages from your site look suspicious for mail services.

2a. Check the spam folder and mark emails from the site as “Not spam”, also add sender mail to the address book.

2b. If you don’t find the email in the spam folder, сonfigure sending via SMTP. You can do it in 5 minutes by following instructions. I guess it’s the most simple and trustworthy way.

2c. If you don’t want to use SMTP, create a domain email address (like This email address is being protected from spambots. You need JavaScript enabled to view it.). Open «System->Global configuration» in the top menu, choose tab Server, find “Mail Settings” options and type a new email address in “From email” field. It will increase your site trust level.

2d. Configure SPF or DKIM on your web server.

3.  Problems with PHP Mailer. Joomla has 3 different mailers: PHP Mail, Sendmail, and SMTP. By default is using PHP Mail, below we will tell you how to fix the problem with him.

3a. The most simple way is to change mailer to the Sendmail. Open «System->Global configuration» in the top menu and choose tab Server. Find “Mail Settings” and choose in the “Mailer” drop down “Sendmail” option. Also, you can choose SMTP, read how to use and configure this protocol here.

Joomla doesn't send messages

3b. You can try to fix PHP Mailer. Open :”root/libraries/phpmailer/phpmailer.php” or  “root/libraries/vendor/phpmailer/phpmailer/class.phpmailer.php” for the late versions of Joomla.

Code:
$params = sprintf(‘-f%s’, $this->Sender);

Change to:
$params = sprintf(‘-f%s’);

Or for the earlier versions find:

$params = sprintf(‘-oi -f %s’, $this->Sender);

Probably 707 or 1161 string number. And add below:

$params = ‘ ‘;

Now your code looks like:

if (empty($this->Sender)) {

$params = ‘-oi -f %s';

} else {

$params = sprintf(‘-oi -f %s’, $this->Sender);

$params = ‘ ‘;

}

4. If this methods doesn’t help, maybe the problem is in your hoster. Probably you are using free plan, with blocked or opt-in mailing. Anyway you should write to the hosting support with your problem.

How to fix Joomla ‘SMTP connect() failed’ error while sending mails

Joomla is a commonly used content-management software for websites. In Joomla, emails are used for various purposes such as contact form submissions or password resets.

Joomla ‘SMTP connect() failed‘ is a commonly encountered email error in Joomla, when users try to submit a contact form in the website. Email fails to send, showing up this error.

 

By default, Joomla uses the PHP mail function to send mails. The settings for PHP Mail can be changed from the Joomla administrator dashboard.

Login to Joomla as admin user and go to the section ‘System’ -> ‘Global Configuration’ -> ‘Server’. Under ‘Mail Settings’, you can see PHP Mail as the Mailer and its corresponding settings.

 

Default setting in Joomla - PHP mail function

Default setting in Joomla – PHP mail function

 

What causes error Joomla ‘SMTP connect() failed’

In many servers where PHP mail function is disabled as a server security measure to avoid spamming, this default Mailer will not work to send mails.

That’s when we configure SMTP as the Mailer. From the drop-down for Mailer, choose SMTP instead of PHP Mail:

 

Change PHP mail to SMTP mail function

Change PHP mail to SMTP mail

 

Even though SMTP mailer is chosen, if the corresponding settings for the SMTP server is not configured correctly, it will not send mails successfully from the server.

Attempts to send mails from the Joomla website via contact form or password reset forms would end up giving error “Error while sending the email. SMTP connect() failed.”

The error ‘Joomla SMTP connect() failed’ is often caused by incorrect filling of the field ‘SMTP Security’ in the ‘Mail Settings’.

SMTP connection can fail to establish due to a number of reasons:

  1. Wrong username and password given in SMTP authentication.
  2. SMTP port blocked in server firewalls.
  3. Mail server does not support SSL/TLS.
  4. Using 3rd party servers such as gmail or other insecure apps.
  5. Upgrades to Joomla or PHPMailer versions that have enhanced security features or bugs.

How to fix error Joomla ‘SMTP connect() failed’

Here, we’ll see how to set each of these settings properly to avoid email delivery errors from Joomla. 

In Joomla administrator panel, under ‘System’ -> ‘Global Configuration’ -> ‘Server’ -> ‘Mail Settings’, choose Mailer ‘SMTP’ and enter host, user name and password. Turn on SMTP authentication section.

 

SMTP configuration settings for Joomla mail

SMTP configuration settings for Joomla mail

 

1. SMTP host and port settings

Enter the name of your mail server in ‘SMTP Host’ section. This is usually the ‘domain name’ or ‘mail.domain.com’. Make sure that the DNS for SMTP host resolves correctly.

Give port number as 25, the default SMTP port. For mail servers that use custom ports such as 587 for SMTP to avoid spamming, give that port.

It is also possible that certain mail servers restrict the access to their port 25 using firewall rules. In such cases, your IP should be white-listed in the firewall to avoid SMTP connect error.

To confirm that the connectivity to SMTP server and port is working fine, use the command:

telnet domain.com 25

Use the appropriate hostname and port number, after confirming that the SMTP connection is working fine. If the connectivity fails to establish, mail delivery will fail with the error ‘SMTP connect() failed‘.

2. SMTP authentication details

Every mail server has an authentication system to validate the users before allowing them to connect to it and send mails. In your Joomla Mail settings, turn this ON (YES).

Give the email account username and password. Enter the full ‘This email address is being protected from spambots. You need JavaScript enabled to view it.’ as the username in case of non-default accounts.

Whenever the email account password is changed or updated for security reasons, do not forget to change the password in ‘Mail settings’ also.

If the authentication details given are wrong, Joomla will fail to send mails and give the error ‘SMTP connect() failed‘.

3. SMTP security settings

For secure email transmission, it is always advisable to choose SMTP with SSL/TLS protocol. So, choose ‘SSL/TLS’ option from the drop-down for ‘SMTP Security’.

But is some email servers, this SSL/TLS support may not be enabled. In those cases, if you choose ‘SSL/TLS’ security, mails may not get delivered.

To verify the SSL certificate for your mail server, use the command:

openssl s_client -starttls smtp -crlf -connect mail.domain.com:25

Using expired or self-signed certificates can cause the mail delivery using SSL to fail and give error ‘SMTP connect() failed‘.

So the solution in those cases is to configure SSL for your mail server properly or change the SMTP Security settings from ‘SSL/TLS’ to ‘None’, which is less secure one.

 

Change Server Security from SSL/TLS to None

Change Server Security from SSL/TLS to None

 

4. Support for 3rd party apps

If you are using gmail email server instead of your own mail server, then there are a few points to note. You have to enable the ‘Authentication – GMail’ plugin.

You can do this from the Admin Area: ‘Extensions -> Plugin Manager -> Authentication – GMail’ option.

Also, Gmail servers may not accept connection attempts from certain mail client apps such as mobile apps. In those cases, either use a secure app or loosen the security measures.

In ‘My Account’ -> ‘Less Secure Apps’ section, turn on the option ‘Access for less secure apps’ to loosen the security settings.

This will avoid Joomla ‘SMTP connect failed’ errors when trying to send emails from Joomla using Gmail.

In short..

Other variants for ‘SMTP connect() failed’ error are ‘Called Mail() without being connected’ or ‘SMTP Error: Could not connect to SMTP host.’

In addition to the configuration settings we’ve discussed, one important point to keep in mind is the safety precautions to take during Joomla or PHPMailer upgrades.

Since new versions may often come with features or bugs that may break a working website, its always important to take proper backups and do test installs, before upgrading in the production server.

 

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.