|
1 | 1 | # MySQL example |
2 | 2 | This example is tested with MySQL version 8.0.29. |
3 | 3 |
|
4 | | -This directory contains an example for running Mysql server in Gramine, including |
| 4 | +This directory contains an example for running MySQL server in Gramine, including |
5 | 5 | the Makefile and a template for generating the manifest. |
6 | 6 |
|
7 | | -# Pre-requisites |
| 7 | +## Pre-requisites |
8 | 8 |
|
9 | 9 | - `sudo apt-get install mysql-server` to install MySQL server. |
10 | | -- Comment out the log line `log_error = /var/log/mysql/error.log` in the config file |
| 10 | +- Comment out the log line `log_error = /var/log/mysql/error.log` in the config file |
11 | 11 | `/etc/mysql/mysql.conf.d/mysqld.cnf` to see the log on console. |
12 | | -- `systemctl stop mysql.service` to stop the default MySQL service .We will manually |
| 12 | +- `systemctl stop mysql.service` to stop the default MySQL service. We will manually |
13 | 13 | run MySQL process. |
14 | | -- `sudo mkdir /var/run/mysqld && sudo chown -R <current_user>:<current_user> /var/run/mysqld` |
| 14 | +- `sudo mkdir /var/run/mysqld && sudo chown -R <current_user>:<current_user> /var/run/mysqld` |
15 | 15 | to allow MySQL server to create socket file `mysqld.sock`. |
16 | | -- `sudo chown -R <current_user>:<current_user> /var/lib/mysql-files` to allow MySQL server for |
17 | | -internal usage. |
18 | | -- `sudo chown -R <current_user>:<current_user> /var/lib/mysql-keyring` to allow MySQL server for |
19 | | -internal usage. |
20 | | -- `mysqld --initialize-insecure --datadir=mysql-data/` to initialize data directory. |
| 16 | +- `sudo chown -R <current_user>:<current_user> /var/lib/mysql-files` to allow running |
| 17 | + MySQL server under the current non-root user. |
| 18 | +- `sudo chown -R <current_user>:<current_user> /var/lib/mysql-keyring` to allow running |
| 19 | + MySQL server under the current non-root user. |
| 20 | +- `mysqld --initialize-insecure --datadir=/tmp/mysql-data` to initialize data directory. For |
| 21 | + details on '--initialize-insecure', please see the https://dev.mysql.com/doc/mysql-linuxunix-excerpt/5.7/en/data-directory-initialization.html page. |
21 | 22 |
|
22 | | -# Build |
| 23 | +## Build |
23 | 24 |
|
24 | 25 | Run `make` to build the non-SGX version and `make SGX=1` to build the SGX |
25 | 26 | version. |
26 | 27 |
|
27 | | -# Run |
| 28 | +## Run |
28 | 29 |
|
29 | 30 | Execute any one of the following commands to run the workload: |
30 | 31 |
|
31 | | -- Natively: `mysqld --datadir /tmp/mysql`. |
32 | | -- Gramine w/o SGX: `gramine-direct mysqld -u root --datadir /tmp/mysql`. |
33 | | -- Gramine with SGX: `gramine-sgx mysqld -u root --datadir /tmp/mysql`. |
| 32 | +- Natively: `mysqld --datadir /tmp/mysql-data`. |
| 33 | +- Gramine w/o SGX: `gramine-direct mysqld --datadir /tmp/mysql-data`. |
| 34 | +- Gramine with SGX: `gramine-sgx mysqld --datadir /tmp/mysql-data`. |
34 | 35 |
|
35 | | -# Testing client connection and running sysbench benchmarking |
| 36 | +## Testing client connection and running Sysbench |
36 | 37 |
|
37 | | -Run below command from new terminal: |
| 38 | +Run below commands from new terminal: |
38 | 39 |
|
39 | | -- `mysql -P 3306 --protocol=tcp -uroot` to connect a client to MySQL server. |
| 40 | +- `mysql -P 3306 --protocol=tcp -u root` to connect a client to MySQL server. |
40 | 41 | - `mysql> exit` to disconnect the client. |
41 | 42 |
|
42 | | -Run Sysbench benchmarking: |
| 43 | +Run Sysbench: |
43 | 44 |
|
44 | | -- `sudo apt install -y sysbench` to install sysbench. |
| 45 | +- `sudo apt install -y sysbench` to install Sysbench. |
45 | 46 | - `sudo mysqladmin -h 127.0.0.1 -P 3306 create sbtest` to create test database. |
46 | 47 |
|
47 | 48 | - `sysbench --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-db=sbtest --time=20 --report-interval=5 oltp_read_write --tables=2 --table_size=100000 --threads=32 prepare` to |
48 | 49 | create records in test database. |
49 | 50 | - `sysbench --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-db=sbtest --time=20 --report-interval=5 oltp_read_write --tables=2 --table_size=100000 --threads=32 run` to |
50 | | - run the sysbench benchmarks. |
| 51 | + run the Sysbench benchmarks. |
51 | 52 | - `sysbench --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-db=sbtest --time=20 --report-interval=5 oltp_read_write --tables=2 --table_size=100000 --threads=32 cleanup` to |
52 | 53 | delete the records from test database. |
0 commit comments