Protect Directories in SingleStore Using CTE
On this page
Now that you have the environment configured, you can start protecting your data.
Get the List of Directories to Guard and Add them to CTE
The directories (or folders) identified by the following SingleStore directories need to be secured on every node in the cluster:
-
data
-
tracelogs
-
plancache
-
auditlogs
The nodes metadata file (usually called nodes.
If you are using the default SingleStore installation paths, use the following default directories as Guard points to simplify the process:
-
/var/lib/memsql
for RPM/Debian basedsinglestoredb-server
/memsql-server
installations -
$tar_
for tar basedinstall_ dir/nodes singlestoredb-server
/memsql-server
installations
Otherwise, to find these directories, you can run sdb-admin describe-node --all
.
Here is part of the sample output of this command corresponding to the master node in the cluster example:
+--------------------+---------------------------------------------------------------------------------+
| memsqlId | D04E4F761C5651BAF9CE1922B3FC7C05E30CE037
| host | ec2-18-192-24-241.eu-central-1.compute.amazonaws.com
| role | Master
| port | 3306
| bindAddress | 0.0.0.0
| processState | Running
| version | 7.1.11
| memsqlConfig | /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/memsql.cnf
| datadir | /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/data
| plancachedir | /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/plancache
| tracelogsdir | /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/tracelogs
| auditlogsdir | /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/auditlogs
| memsqld | /home/memsql/memsql/memsql-server-7.1.11-6c108deb15/memsqld
| nodeID | 1
| pid | 22072
| dpid | 22079
| autoRestartEnabled | true
| isConnectable | true
| recoveryState | Online
| availabilityGroup | --
| config | Omitted from table view. Use 'sdb-admin describe-node ... --property config'
| variables | Omitted from table view. Use 'sdb-admin describe-node ... --property variables'
+--------------------+---------------------------------------------------------------------------------
To encrypt data and enable access control using CTE, you will need to set up Guard points at the directories shown in the output above as the values of:
-
datadir
-
plancachedir
-
tracelogsdir
-
auditlogsdir
You also need to guard the directory where nodesMetadataFile
is located./home/memsql/memsql/memsql-server-7.
in our case) in order to find the location of the nodes metadata file.<PATH TO memsqld>/memsqlctl env
.
+-------------------+----------------------------------------+
| memsqlctlConfig | /home/memsql/memsql/memsqlctl.hcl |
| defaultInstallDir | /home/memsql/memsql/nodes |
| nodeMetadataFile | /home/memsql/memsql/nodes/nodes.hcl |
| userInfo | uid=1000(memsql) gid=1000(memsql) |
| user | memsql |
+-------------------+----------------------------------------+
You should see the directory where nodesMetadataFile
is located.
In default SingleStore installations, it is /var/lib/memsql
.$tar_
.
The example cluster used memsql-server-7.
for cluster setup, with tar_
, so it would require a guard point for the directory /home/memsql/memsql/nodes
.
In addition to protecting the data, plancache, tracelogs, auditlogs, and nodes metadata, you may wish to secure the destination directory or directories for backups and SELECT INTO OUTFILE
results.
Now that you have the locations of the directories, you can proceed to configuring DSM to guard them.
Configure Vormetric Data Security Manager (DSM)
Perform the following steps on the DSM using the web GUI:
-
Generate the SingleStore Key for Encryption
-
Create a SingleStore User Set
-
Create Encryption and Decryption Data Transformation Policies
-
Create a SingleStore Process Set
-
Configure Host File Settings
-
Create a SingleStore Security Policy
-
Create Encryption Guard Points and Transform Data
-
Enable the SingleStore Security Policy
Once you have completed these steps you can verify the installation and configuration.
Generate the SingleStore Key for Encryption
-
Select Keys > Agent Keys > Keys from the main menu.
-
Click the Add button to add the key.
Enter the name singlestore_
.key Choose the default template Default_ SQL_ Symmetric_ KeyTemplate. Click Ok.
Create a SingleStore User Set
-
Select Policies > Manage Policies > User Sets from the main menu.
-
Enter the name for the User Set:
SingleStoreUser
. -
Click Add.
-
Click Browse Users.
-
Select the host on which you want to add the user.
Click Ok. -
The list of users should appear in the bottom of the screen.
Choose the user that is running SingleStore nodes on the host ( memsql
in most cases) and the user that is running Toolbox commands.
Create Encryption and Decryption Data Transformation Policies
Encryption Policy will be used for initial data encryption.
Encryption Policy
-
Select Policies > Manage Policies > Manage Policies.
-
Click Add.
-
Choose the Standard policy type.
-
Enter the name:
SingleStore_
.encryption -
Under Security rules, click Add to add a security rule.
-
Click Select next to Action, choose
key_
.op -
Click Select next to Effect, choose Permit, Apply key, Audit.
Click Ok. -
Under Key Selection Rules section, click Add, then Select.
-
Choose
clear_
, click Select Key.key Click Ok. -
Under Data Transformation Rules, click Add, then Select.
-
Choose
singlestore_
, click Select Key.key Click Ok.
Decryption Policy
-
Select Policies > Manage Policies > Manage Policies.
-
Click Add.
-
Choose the Standard policy type.
-
Enter the name
SingleStore_
.decryption -
Under Security rules, click Add to add a security rule.
-
Click Select next to Action, choose
key_
.op -
Click Select next to Effect, choose Permit, Apply key, Audit.
Click Ok. -
Under Key Selection Rules section, click Add, then Select.
-
Choose
singlestore_
, click Select Key.key Click Ok. -
Under Data Transformation Rules, click Add, then Select.
-
Choose
clear_
, click Select Key.key Click Ok.
Create a SingleStore Process Set
Note
This section specifies which processes access the data directories used by SingleStore nodes.
-
Select Policies > Manage Policies > Process Sets.
-
Click Add.
-
Enter the name:
singlestore-process-set
. -
Add entries via the Add button on the left.
-
Select the SingleStore host.
-
Add the following entries:
-
memsqld
(main database daemon process) -
memsqld_
(daemon that restartssafe memsqld
if it crashes or is killed) -
memsqlctl
(the tool that controls local DB nodes) -
bash
,sh
(to perform certain file operations)
-
Find the locations of the memsql*
commands/binaries by running: sdb-admin describe-node --all
on the Toolbox host.memsqld
is located at /home/memsql/memsql/memsql-server-7.
.memsqld_
and memsqlctl
./home/memsql/memsql/memsql-server-7.
in our example) is the MEMSQL_
mentioned below.MEMSQL_
below, replace it with your path.
When you know the location, you can enter it in the Directory field, then add the process name in File and click Ok.
Directory |
Base Name |
---|---|
<MEMSQL_ |
|
<MEMSQL_ |
|
<MEMSQL_ |
|
/bin/ |
bash |
/bin/ |
sh |
/bin/ |
cat |
/bin/ |
touch |
For Debian/RPM based installations singlestore-process-set
should be similar to the following configuration:
Directory |
Base Name |
---|---|
/bin/ |
bash |
/bin/ |
sh |
/bin/ |
touch |
/bin/ |
chown |
/bin/ |
chmod |
/bin/ |
cat |
/bin/ |
memsqlctl |
/usr/bin/ |
bash |
/usr/bin/ |
sudo |
/usr/bin/ |
memsqlctl |
/opt/memsql-server-* |
memsqld |
/opt/memsql-server-* |
memsqld_ |
/opt/singlestoredb-server* |
memsqld |
/opt/singlestoredb-server* |
memsqld_ |
Note that you may need to replace /bin/
with /usr/bin/
above./bin
and /usr/bin
.which bash
.
Configure Host File Settings
-
On the DSM Management Console, navigate to the Hosts > Hosts page.
-
For each SingleStore host, click on the host’s IP Address or Hostname.
-
Select the Host Settings tab, and add the following host settings entries as new lines:
|authenticator_euid|<MEMSQL_BINARIES_PATH>/memsqld |authenticator_euid|<MEMSQL_BINARIES_PATH>/memsqld_safe |authenticator_euid|<MEMSQL_BINARIES_PATH>/memsqlctl
-
Click the Re-Sign Host Settings checkbox.
-
Click Ok.
Create a SingleStore Security Policy
You need to create a specific SingleStore security policy that will include the user and process sets defined above./home/memsql/memsql/nodes
in this example case).
-
Select Policies > Manage Policies > Manage Policies.
-
Click Add.
-
Choose the Standard policy type.
Enter the name: SingleStore_
.security -
Under Security Rules, click Add.
Add the following security rules in this order: -
This rule will be applied for any user to allow browsing the directories on host.
-
Action:
f_
,rd_ att f_
,rd_ sec d_
,rd d_
,rd_ att d_
rd_ sec -
Effect:
Permit
-
-
This rule will be applied for the user(s) running SingleStore and the corresponding processes.
It is the only policy with Apply Key enabled to decrypt data. -
User:
SingleStoreUser
-
Process:
singlestore-process-set
-
Action:
all_
ops -
Effect:
Permit, Apply Key
-
-
This rule allows everyone to read encrypted data.
-
Action:
read
-
Effect:
Permit
-
-
This rule will be applied for all other users/processes attempting to access SingleStore data.
-
Action:
all_
ops -
Effect:
Audit, Deny
-
-
-
Under Key Selection Rules, click Add.
-
Select
singlestore_
.key -
Click Ok.
Create Encryption Guard Points and Transform Data
Warning
Before encrypting the data, all nodes must be stopped.sdb-admin stop-node --all --yes
on the Toolbox host (the local machine, in the example configuration).
-
Select Hosts > Hosts in the main menu.
-
Click on the SingleStore Host name.
-
Go to the Guard Points tab.
-
Click Guard.
-
Choose the
SingleStore_
Policy.encryption -
Enter the list of full paths to the directories you want to guard.
-
Click Ok.
-
The log file will show a message that the target directory paths are successfully guarded.
You will see a green circle next to the guard point that you created. -
On the host where CTE is installed, switch to a root user.
For each of the guarded directories run dataxform --rekey --preserve_
(replacingmodified_ time --gp <GUARD_ DIR> GUARD_
with the the name of each directory).DIR
Again, verify that you have created a guard point for all data, plan cache, audit log, trace log, nodes metadata, backup, and outfile
directories (if any) that you wish to protect for your SingleStore environment.
Troubleshooting Tips
-
If you need to re-run
dataxform
for the same directory more than once, you may get theAutomatic data transform status for /home/memsql/memsql/nodes: previous attempt completed
error message.In this case you need to run dataxform --cleanup --gp <GUARD_
DIR> -
If you do not see a green circle next to your guard point, the directory may be busy, i.
e. there is a shell connected to it. You have to exit the directory for the guard point to be active. -
To decrypt the data, disable all the guard points, then create guard points for the same directories as you used for
SingleStore_
but withencryption SingleStore_
policy, and rundecryption dataxform --rekey --preserve_
modified_ time --gp GUARD_ DIR
Enable the SingleStore Security Policy
-
Select Hosts > Hosts, click on your CTE host.
-
Disable all entries with Policy
SingleStore_
.enryption -
Select Guard points tab, click Guard.
-
Select the
SingleStore_
policy, Type: Directory (Auto Guard).security -
Enter the list of full paths to the directories you want to guard (
/home/memsql/memsql/nodes
in this example). -
Click Ok.
-
The log file will show a message that the target directory paths are successfully guarded.
You will see a green circle next to the guard point that you created. -
Click Ok.
-
After a short delay you will see the green circle next to the newly created SingleStore_
security entries. This means that the policy is active and SingleStore processes and data are protected. -
Now you can start the SingleStore cluster by running
sdb-admin start-node --all --yes
.
Verify the Installation
In order to check that the process has been performed successfully:
-
On a SingleStore host, open one of the nodes’ config files:
cat /home/memsql/memsql/nodes/d8d2b5f4-d046-4a6f-a0c1-9f6e0525fd16/memsql.cnfYou should see that the data is encrypted.
-
Run
sdb-admin describe-node --all
.This should show the same result as before the encryption. -
Connect to the database and run some queries: create a database or table, insert some data, select some data.
Configure Guard Points after SingleStore Upgrade
When upgrading SingleStore (say, from version 7.memsqlctl
path changes on upgrade, and therefore you need to update the MEMSQL_
directory to add the new binaries to the singlestore-process-set
.
Note
If you are using CTE 7./opt/singlestoredb-server*
and /opt/memsql-server-*
as location of binaries for Debian/RPM clusters and upgrade SingleStore without additional configuration.
-
Run
sdb-deploy install <desired version>
. -
Go to your
tar_
and find the newly installedinstall_ dir memsql-server
directory, e.g. memsql-server-7.
.1. 12-2sdt55frq5 -
In DSM, add three entries to
singlestore-process-set
withMEMSQL_
replaced byBINARIES_ PATH <tar_
.install_ dir>/memsql-server-7. 1. 12-2sdt55frq5 -
Run
sdb-deploy upgrade <desired version>
. -
Delete entries corresponding to the old SingleStore version.
Appendix A
The following example explains how to prepare an AWS instance for use with CTE and Ubuntu.
Prepare an AWS Instance (Ubuntu Only)
-
Launch an AWS instance with at least 4 CPU cores and 16 GB of RAM.
You will then need to modify it to install the CTE agent software. -
Install the generic Ubuntu kernels:
sudo apt install linux-generic -
Find the
$menuentry_
for the submenu:id_ option grep submenu /boot/grub/grub.cfgSAMPLE OUTPUT:
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc'
-
Find the
$menuentry_
for the menu entry for the generic kernel version you want to use.id_ option You can choose any kernel version up to 4. 4. 0-189-generic: grep gnulinux /boot/grub/grub.cfgSAMPLE OUTPUT:
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-rt-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-rt-amd64-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-rt-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-rt-amd64-recovery-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-amd64-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' {menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-rt-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-rt-amd64-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-rt-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-rt-amd64-recovery-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' { menuentry 'Debian GNU/Linux, with Linux 4.18.0-0.bpo.1-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-0.bpo.1-amd64-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc' {
-
Comment out your current
GRUB_
definition inDEFAULT /etc/default/grub
and replace it with the submenu$menuentry_
from step 3, and the selected kernel’sid_ option $menuentry_
from step 4 separated byid_ option >
.Example modified GRUB_
DEFAULT: #GRUB_
DEFAULT=0 GRUB_ DEFAULT="gnulinux-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc>gnulinux-4. 18. 0-0. bpo. 1-amd64-advanced-38ea4a12-6cfe-4ed9-a8b5-036295e62ffc" -
Update grub to save the changes:
sudo update-grub -
Reboot the server; after reboot you should be running the generic kernel that you selected.
Confirm by running: sudo uname -a
Last modified: April 26, 2023