最近一個電子看板小項目上線,由於資料庫非常小,而且數據也不太重要。因此未選擇XtraBackup備份,打算用AutoMySQLBackup來備份,結果部署後測試發現,有一些小問題是之前解決過的。有一些是MySQL 5.7版本才有的。下麵記錄一下解決過程。關於AutoMySQLBackup的基礎知識,... ...
最近一個電子看板小項目上線,由於資料庫非常小,而且數據也不太重要。因此未選擇XtraBackup備份,打算用AutoMySQLBackup來備份,結果部署後測試發現,有一些小問題是之前解決過的。有一些是MySQL 5.7版本才有的。下麵記錄一下解決過程。關於AutoMySQLBackup的基礎知識,參考我這篇博客“MySQL備份還原——AutoMySQLBackup介紹”。這裡不做詳細介紹。這裡的MySQL版本: 5.7.30
測試過程,備份日誌出現下麵告警信息:
###### 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.”報錯:
因為從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.
These clients support --ssl-mode: mysql, mysqladmin, mysqlbinlog, mysqlcheck, mysqldump, mysqlimport, mysqlshow, mysqlpump, mysqlslap, mysqltest, mysql_upgrade.
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().
In consequence of this change, the minor C API version number was incremented
所以這裡有兩個解決方案,都非常簡單:
1:在配置文件裡面設置CONFIG_mysql_dump_usessl='no'後即可解決。簡單快捷,不用修改代碼
# Use ssl encryption with mysqldump
CONFIG_mysql_dump_usessl='no'
2:修改腳本automysqlbackup,具體操作,將腳本中的--ssl選項替換為--ssl-mode。治標治本。當然最正確的方法是根據MySQL版本選擇參數。
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
如果你能駕馭工具,自然得心應手。隨著平臺環境、版本的變化,出現的各種問題都能被你解決。如果你只是被動的使用工具,那麼遇到一點小問題,就會束手無策。工作這麼多年,感覺DBA的硬技能中的一非常重要的能力:解決問題的能力。這個能力需要不斷通過實戰鍛煉、培養、升級!
參考資料:
https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-11.html