檔案系統加密:若要啟用先前未加密檔案系統的加密功能,需要以下步驟
在
config.ini檔案的[ndbd default]區段中設定所需資料節點參數,如下所示[ndbd default] EncryptedFileSystem= 1這些參數必須在所有資料節點上依所示設定。
對所有資料節點執行滾動初始啟動(或重新啟動)(請參閱第25.6.5節,「執行NDB叢集的滾動重新啟動」):以
--initial啟動每個資料節點;此外,還需為每個資料節點程序提供選項--filesystem-password或--filesystem-password-from-stdin之一,以及密碼。當您在命令列上提供密碼時,會顯示類似以下內容的警告> ndbmtd -c 127.0.0.1 --filesystem-password=ndbsecret ndbmtd: [Warning] Using a password on the command line interface can be insecure. 2022-08-22 16:17:58 [ndbd] INFO -- Angel connected to '127.0.0.1:1186' 2022-08-22 16:17:58 [ndbd] INFO -- Angel allocated nodeid: 5--filesystem-password可以從檔案、tty或stdin接收密碼;--filesystem-password-from-stdin僅從stdin接收密碼。後者可保護密碼免於暴露於程序命令列或檔案系統中,並允許從其他安全應用程式傳遞密碼的可能性。您也可以將密碼放在資料節點程序可讀取但系統的其他使用者無法讀取的
my.cnf檔案中。使用與先前範例相同的密碼,檔案的相關部分應如下所示[ndbd] filesystem-password=ndbsecret您也可以透過在
my.cnf檔案中使用--filesystem-password-from-stdin選項,提示啟動資料節點程序的用戶在執行此操作時提供加密密碼,如下所示[ndbd] filesystem-password-from-stdin在此情況下,當啟動資料節點程序時,系統會提示用戶輸入密碼,如下所示
> ndbmtd -c 127.0.0.1 Enter filesystem password: ********* 2022-08-22 16:36:00 [ndbd] INFO -- Angel connected to '127.0.0.1:1186' 2022-08-22 16:36:00 [ndbd] INFO -- Angel allocated nodeid: 5 >無論使用哪種方法,加密密碼的格式都與加密備份的密碼格式相同(請參閱第25.6.8.2節,「使用NDB叢集管理用戶端建立備份」);啟動每個資料節點程序時都必須提供密碼;否則資料節點程序將無法啟動。資料節點日誌中會顯示以下訊息
> tail -n2 ndb_5_out.log 2022-08-22 16:08:30 [ndbd] INFO -- Data node configured to have encryption but password not provided 2022-08-22 16:08:31 [ndbd] ALERT -- Node 5: Forced node shutdown completed. Occurred during startphase 0.當如上述方式重新啟動時,每個資料節點都會清除其磁碟上的狀態,並以加密形式重建它。
輪替檔案系統密碼:若要更新資料節點使用的加密密碼,請對資料節點執行滾動初始重新啟動,並在使用 --filesystem-password 或 --filesystem-password-from-stdin 重新啟動每個資料節點時,提供新密碼。
解密檔案系統:若要從加密的檔案系統中移除加密,請執行以下操作
若要查看是否已正確設定檔案系統加密,您可以使用針對 ndbinfo config_values 和 config_params 表格的查詢,類似於以下查詢
mysql> SELECT v.node_id AS Node, p.param_name AS Parameter, v.config_value AS Value
-> FROM ndbinfo.config_values v
-> JOIN ndbinfo.config_params p
-> ON v.config_param=p.param_number
-> WHERE p.param_name='EncryptedFileSystem';
+------+----------------------+-------+
| Node | Parameter | Value |
+------+----------------------+-------+
| 5 | EncryptedFileSystem | 1 |
| 6 | EncryptedFileSystem | 1 |
| 7 | EncryptedFileSystem | 1 |
| 8 | EncryptedFileSystem | 1 |
+------+----------------------+-------+
4 rows in set (0.10 sec)在此,EncryptedFileSystem 在所有資料節點上都等於 1,這表示此叢集已啟用檔案系統加密。