AutoMySQLBackup 3.0在MySQL 5.7中的問題修復

 

最近一個電子看板小項目上線,因爲數據庫很是小,並且數據也不過重要。所以未選擇XtraBackup備份,打算用AutoMySQLBackup來備份,結果部署後測試發現,有一些小問題是以前解決過的。有一些是MySQL 5.7版本纔有的。下面記錄一下解決過程。關於AutoMySQLBackup的基礎知識,參考我這篇博客MySQL備份還原——AutoMySQLBackup介紹。這裏不作詳細介紹。這裏的MySQL版本: 5.7.30html

 

 

測試過程,備份日誌出現下面告警信息:mysql

 

###### WARNING ######
Errors reported during AutoMySQLBackup execution.. Backup failed
Error log below..
mysql: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.

 

 

 

1:解決WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.報錯:sql

 

由於從MySQL 5.7.11開始,開始使用--ssl-mode參數,而拋棄/丟棄了參數--ssl,因此以前的MySQL版本不會遇到這個告警信息。關於這方面的知識,具體參考下面官方文檔資料:數據庫

 

MySQL client programs now support an --ssl-mode option that enables you to specify the security state of the connection to the server. Permitted option values are PREFERRED (establish an encrypted connection if the server supports the capability, falling back to an unencrypted connection otherwise), DISABLED (establish an unencrypted connection), REQUIRED (establish an encrypted connection, or fail), VERFIFY_CA (like REQUIRED, but additionally verify the server certificate), VERIFY_IDENTITY (like VERIFY_CA, but additionally verify that the server certificate matches the host name to which the connection is attempted). For backward compatibility, the default is PREFERRED if --ssl-mode is not specified.app

 

These clients support --ssl-mode: mysql, mysqladmin, mysqlbinlog, mysqlcheck, mysqldump, mysqlimport, mysqlshow, mysqlpump, mysqlslap, mysqltest, mysql_upgrade.ide

The --ssl-mode option comprises the capabilities of the client-side --ssl and --ssl-verify-server-cert options. Consequently, both of those options are now deprecated and will be removed in a future MySQL version. Use --ssl-mode=REQUIRED instead of --ssl=1 or --enable-ssl. Use --ssl-mode=DISABLED instead of --ssl=0, --skip-ssl, or --disable-ssl. Use --ssl-mode=VERIFY_IDENTITY instead of --ssl-verify-server-cert options. (The server-side --ssl option is not deprecated.)工具

 

For the C API, the new MYSQL_OPT_SSL_MODE option for mysql_options() corresponds to the --ssl-mode option. The MYSQL_OPT_SSL_ENFORCE and MYSQL_OPT_SSL_VERIFY_SERVER_CERT options for mysql_options() correspond to the client-side --ssl and --ssl-verify-server-cert options. They are now deprecated and will be removed in a future MySQL version. Use MYSQL_OPT_SSL_MODE with an option value of SSL_MODE_REQUIRED or SSL_MODE_VERIFY_IDENTITY instead.測試

 

For more information, see Command Options for Encrypted Connections, and mysql_options().this

 

In consequence of this change, the minor C API version number was incrementedspa

 

 

因此這裏有兩個解決方案,都很是簡單:

 

 

1:在配置文件裏面設置CONFIG_mysql_dump_usessl='no'後便可解決。簡單快捷,不用修改代碼

 

# Use ssl encryption with mysqldump

CONFIG_mysql_dump_usessl='no'

 

2:修改腳本automysqlbackup,具體操做,將腳本中的--ssl選項替換爲--ssl-mode。治標治本。固然最正確的方法是根據MySQL版本選擇參數。

 

clip_image001

 

2:解決上面問題後,報錯的提示變爲下面這個樣子,以前這篇博客MySQL備份還原——AutoMySQLBackup介紹中介紹的方法不靈了。由於MySQL版本變化了。輸出信息變化了。以前的方法天然失靈了。世界老是變化的,很難有一成不變的事物!

 

###### WARNING ######
Errors reported during AutoMySQLBackup execution.. Backup failed
Error log below..
mysql: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: [Warning] Using a password on the command line interface can be insecure.

 

修改腳本automysqlbackup(這個腳本視Linux版本不一樣,位置有所不一樣,通常位於/usr/local/bin/automysqlbackup或/usr/bin/automysqlbackup下面),在removeIO後面加上這段代碼解決這個問題:

 

# Remove annoying warning message since MySQL 5.7
if [[ -s "$log_errfile" ]]; then
      sedtmpfile="/tmp/$(basename $0).$$.tmp"
      grep -v "mysqldump: \[Warning\] Using a password on the command line interface can be insecure." "$log_errfile" | \
      grep -v "mysql: \[Warning\] Using a password on the command line interface can be insecure."  | \
      grep -v "mysqlshow: \[Warning\] Using a password on the command line interface can be insecure."  > $sedtmpfile
      mv $sedtmpfile $log_errfile
fi

 

clip_image002

 

 

若是你能駕馭工具,天然駕輕就熟。隨着平臺環境、版本的變化,出現的各類問題都能被你解決。若是你只是被動的使用工具,那麼遇到一點小問題,就會一籌莫展。工做這麼多年,感受DBA的硬技能中的一很是重要的能力:解決問題的能力。這個能力須要不斷經過實戰鍛鍊、培養、升級!

 

 

參考資料:

 

https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-11.html

相關文章
相關標籤/搜索