Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a303492

Browse files
Add setup and testing scripts
1 parent c7c435c commit a303492

File tree

12 files changed

+406
-0
lines changed

12 files changed

+406
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# MySQL Connection Details
4+
export MYSQL_USER="fill_up"
5+
export MYSQL_PASSWORD="fill_up"
6+
export MYSQL_HOST="fill_up_with_MySQL57_writer_endpoint"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_point_select run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--threads=512 \
26+
--skip_trx=on \
27+
--db-ps-mode=disable \
28+
--histogram=on \
29+
--warmup-time=300 \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# ProxySQL Parameters
4+
export MYSQL_USER="stnduser"
5+
export MYSQL_PASSWORD="stnduser"
6+
export MYSQL_HOST="NLB_endpoint_or_proxysql_instance_ipaddress"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_point_select run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--threads=512 \
26+
--skip_trx=on \
27+
--db-ps-mode=disable \
28+
--histogram=on \
29+
--warmup-time=300 \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# MySQL Connection Details
4+
export MYSQL_USER="fill_up"
5+
export MYSQL_PASSWORD="fill_up"
6+
export MYSQL_HOST="fill_up_with_MySQL80_writer_endpoint"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_point_select run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--threads=512 \
26+
--skip_trx=on \
27+
--db-ps-mode=disable \
28+
--histogram=on \
29+
--warmup-time=300 \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# MySQL Connection Details
4+
export MYSQL_USER="fill_up"
5+
export MYSQL_PASSWORD="fill_up"
6+
export MYSQL_HOST="fill_up_with_MySQL57_writer_endpoint"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_read_only run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--warmup-time=300 \
26+
--threads=128 \
27+
--skip_trx=on \
28+
--db-ps-mode=disable \
29+
--histogram=on \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# ProxySQL Parameters
4+
export MYSQL_USER="stnduser"
5+
export MYSQL_PASSWORD="stnduser"
6+
export MYSQL_HOST="NLB_endpoint_or_proxysql_instance_ipaddress"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_read_only run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--warmup-time=300 \
26+
--threads=128 \
27+
--skip_trx=on \
28+
--db-ps-mode=disable \
29+
--histogram=on \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# MySQL Connection Details
4+
export MYSQL_USER="fill_up"
5+
export MYSQL_PASSWORD="fill_up"
6+
export MYSQL_HOST="fill_up_with_MySQL80_writer_endpoint"
7+
export PORT=3306
8+
9+
# Sysbench Parameters
10+
export SYSBENCH_DB="sbtest"
11+
export SYSBENCH_THREADS=16
12+
export SYSBENCH_NUM_TABLES=16
13+
export SYSBENCH_TABLE_SIZE=1000000
14+
15+
sysbench oltp_read_only run \
16+
--report-interval=5 \
17+
--table-size=$SYSBENCH_TABLE_SIZE \
18+
--mysql-host=$MYSQL_HOST \
19+
--mysql-port=$PORT \
20+
--mysql-user=$MYSQL_USER \
21+
--mysql-password=$MYSQL_PASSWORD \
22+
--mysql-db=$SYSBENCH_DB \
23+
--tables=1 \
24+
--time=300 \
25+
--threads=128 \
26+
--skip_trx=on \
27+
--db-ps-mode=disable \
28+
--histogram=on \
29+
# --warmup-time=300 \
30+
# --mysql-ignore-errors=2013,2003,1290,1213 \
31+
# --reconnect=1000 \
32+

‎scripts/init-db.bash‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
: '
3+
This script initialises the ProxySQL Server and Aurora MySQL 8.0 Database with the necessary ProxySQL permissions and settings.
4+
5+
Most notably, you will need to fill in the following parameters in the script. The writer and reader endpoints should point to Aurora MySQL 8.0, and they can be found in the CloudFormation Outputs section. The Admin user and password should be set according to best practices. In the recommended demo, we have set it to default to `MYSQL_ADMIN_USER=admin` and `MYSQL_ADMIN_PASSWORD=mysqladmin`.
6+
```
7+
WRITER_ENDPOINT="fill_up_with_MySQL8.0_writer"
8+
READER_ENDPOINT="fill_up_with_MySQL8.0_reader"
9+
MYSQL_ADMIN_USER="fill_up"
10+
MYSQL_ADMIN_PASSWORD="fill_up"
11+
```
12+
13+
If you are unsure if ProxySQL is connected, you can run the following commands in the script. These commands provide us insight as to whether the ProxySQL-Aurora integration has been correctly setup. Look at the ProxySQL documentation if more help is needed:
14+
```
15+
execute_proxysql_command "SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 3;"
16+
execute_proxysql_command "SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start_us DESC LIMIT 3;"
17+
```
18+
'
19+
20+
# Proxysql variables
21+
export PROXY_ADMIN_USER="admin"
22+
export PROXY_ADMIN_PASSWORD="admin"
23+
export MONITOR_USERNAME="monitor"
24+
export MONITOR_PASSWORD="monitor"
25+
export PROXYSQL_USER="stnduser"
26+
export PROXYSQL_PASSWORD="stnduser"
27+
28+
# Aurora Cluster variables
29+
export WRITER_ENDPOINT="fill_up_with_MySQL8.0_writer"
30+
export READER_ENDPOINT="fill_up_with_MySQL8.0_reader"
31+
export MYSQL_ADMIN_USER="fill_up"
32+
export MYSQL_ADMIN_PASSWORD="fill_up"
33+
34+
export SYSBENCH_DB="sbtest"
35+
36+
37+
execute_proxysql_command() {
38+
mysql -u$PROXY_ADMIN_USER -p$PROXY_ADMIN_PASSWORD -h 127.0.0.1 -P6032 -e "1ドル"
39+
}
40+
41+
execute_mysql_command() {
42+
mysql -u$MYSQL_ADMIN_USER -p$MYSQL_ADMIN_PASSWORD -h $WRITER_ENDPOINT -e "1ドル"
43+
}
44+
45+
export -f execute_proxysql_command
46+
export -f execute_mysql_command
47+
48+
49+
# Create Appropriate users in mysql
50+
execute_mysql_command "CREATE USER '$PROXYSQL_USER'@'%' IDENTIFIED BY '$PROXYSQL_PASSWORD';"
51+
execute_mysql_command "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, PROCESS, INDEX, ALTER, CREATE VIEW ON *.* TO '$PROXYSQL_USER'@'%';"
52+
execute_mysql_command "GRANT ALL PRIVILEGES ON $SYSBENCH_DB.* TO '$PROXYSQL_USER'@'%';"
53+
execute_mysql_command "CREATE USER '$MONITOR_USERNAME'@'%' IDENTIFIED BY '$MONITOR_PASSWORD';"
54+
execute_mysql_command "GRANT USAGE, REPLICATION CLIENT ON *.* TO '$MONITOR_USERNAME'@'%';"
55+
56+
execute_proxysql_command "INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight,max_connections) VALUES ('$WRITER_ENDPOINT',10,3306,1000,2000);"
57+
execute_proxysql_command "INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight,max_connections) VALUES ('$READER_ENDPOINT',20,3306,1000,2000);"
58+
execute_proxysql_command "UPDATE global_variables SET variable_value='$MONITOR_USERNAME' WHERE variable_name='mysql-monitor_username';"
59+
execute_proxysql_command "UPDATE global_variables SET variable_value='$MONITOR_PASSWORD' WHERE variable_name='mysql-monitor_password';"
60+
execute_proxysql_command "INSERT INTO mysql_query_rules (rule_id,active,match_digest,destination_hostgroup,apply) VALUES (50,1,'^SELECT.*FOR UPDATE$',10,1), (51,1,'^SELECT',20,1);"
61+
execute_proxysql_command "UPDATE mysql_query_rules set cache_ttl=60000 where destination_hostgroup=20;" # MySQL Query Cache enabler
62+
execute_proxysql_command "CREATE USER '$PROXYSQL_USER'@'%' IDENTIFIED BY '$PROXYSQL_PASSWORD';"
63+
execute_proxysql_command "GRANT SELECT, INSERT, UPDATE, DELETE, PROCESS, CREATE ON *.* TO '$PROXYSQL_USER'@'%';"
64+
execute_proxysql_command "INSERT INTO mysql_users (username,password,default_hostgroup) VALUES ('$PROXYSQL_USER','$PROXYSQL_PASSWORD',10);"
65+
execute_proxysql_command "LOAD MYSQL VARIABLES TO RUNTIME; SAVE MYSQL VARIABLES TO DISK;"
66+
execute_proxysql_command "LOAD MYSQL USERS TO RUNTIME; SAVE MYSQL USERS TO DISK;"
67+
execute_proxysql_command "LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;"
68+
execute_proxysql_command "LOAD MYSQL QUERY RULES TO RUNTIME; SAVE MYSQL QUERY RULES TO DISK;"
69+
70+
execute_proxysql_command "SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 3;"
71+
execute_proxysql_command "SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start_us DESC LIMIT 3;"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
: '
3+
This script installs the necessary resources to run proxysql locally.
4+
On some scenarios, the EC2 is unable to install proxysql and this script must be run manually after startup.
5+
'
6+
7+
# Installation
8+
cat <<EOF | sudo tee /etc/yum.repos.d/proxysql.repo
9+
[proxysql_repo]
10+
name=ProxySQL repository
11+
baseurl=https://repo.proxysql.com/ProxySQL/proxysql-2.5.x/centos/8
12+
gpgcheck=1
13+
gpgkey=https://repo.proxysql.com/ProxySQL/proxysql-2.5.x/repo_pub_key
14+
EOF
15+
16+
dnf -y install proxysql
17+
dnf -y localinstall https://dev.mysql.com/get/mysql80-community-release-el9-4.noarch.rpm
18+
dnf -y install mysql mysql-community-client
19+
20+
dnf -y install httpd
21+
echo "Hello from proxysql Instance 1" | tee /var/www/html/index.html
22+
23+
service proxysql start
24+
systemctl start httpd
25+
systemctl enable httpd

‎scripts/install-sysbench.bash‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
: '
3+
This script installs the necessary resources to run sysbench, inclusive of sysbench v1.1.0-2ca9e3f.
4+
On some scenarios, the EC2 is unable to install sysbench and this script must be run manually after startup. This script should be run on the `sysbench EC2 Instance`.
5+
6+
Sysbench is a widely-used, open-source performance benchmarking tool for databases.
7+
You can use sysbench to run your performance tests from the `sysbench EC2 Instance` which is included in this template.
8+
9+
This script is only needed if you want to run performance tests via the `Sysbench EC2 Instance`.
10+
'
11+
12+
sudo dnf -y install git gcc make automake libtool openssl-devel ncurses-compat-libs
13+
sudo dnf -y localinstall https://dev.mysql.com/get/mysql80-community-release-el9-4.noarch.rpm
14+
sudo dnf -y update
15+
sudo dnf -y install mysql-community-devel mysql-community-client mysql-community-common
16+
sudo git clone https://github.com/akopytov/sysbench
17+
cd sysbench
18+
sudo ./autogen.sh
19+
sudo ./configure
20+
make
21+
sudo make install

‎scripts/setup-sysbench.bash‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
: '
3+
This Script sets up the sysbench tables and environment from the `Sysbench EC2 instance`.
4+
Appropriate sysbench tables will be created on your MySQL5.7 and MySQL8.0 Databases.
5+
6+
Note that in this template, we have spun up 2 Databases:
7+
- (1) Aurora MySQL 8.0, and
8+
- (2) Aurora MySQL 5.7
9+
The Aurora MySQL 5.7 database is there to help in benchmarking tests.
10+
11+
Take note that you will need to fill up the following variables:
12+
```
13+
export MYSQL_USER="fill_up"
14+
export MYSQL_PASSWORD="fill_up"
15+
export MYSQL_HOST="fill_up_with_MySQL5.7_writer"
16+
```
17+
and also do not forget the variable near the bottom of the script:
18+
19+
```
20+
export MYSQL_HOST="fill_up_with_MySQL8.0_writer"
21+
```
22+
23+
This script is only needed if you want to run performance tests via the `Sysbench EC2 Instance`.
24+
'
25+
26+
# MySQL Connection Details
27+
export MYSQL_USER="fill_up"
28+
export MYSQL_PASSWORD="fill_up"
29+
export MYSQL_HOST="fill_up_with_MySQL5.7_writer"
30+
export PORT=3306
31+
32+
# Sysbench Parameters
33+
export SYSBENCH_DB="sbtest"
34+
export SYSBENCH_THREADS=16
35+
export SYSBENCH_NUM_TABLES=16
36+
export SYSBENCH_TABLE_SIZE=1000000
37+
38+
# MySQL Command Example
39+
mysql_command() {
40+
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P$PORT -e "1ドル"
41+
}
42+
43+
export -f mysql_command
44+
45+
# Drop and Recreate Database
46+
mysql_command "DROP DATABASE IF EXISTS $SYSBENCH_DB;"
47+
mysql_command "CREATE DATABASE $SYSBENCH_DB;"
48+
49+
# Run Sysbench Prepare Statement for MySQl5.7
50+
sysbench oltp_read_only prepare \
51+
--threads=$SYSBENCH_THREADS \
52+
--db-driver=mysql \
53+
--mysql-host=$MYSQL_HOST \
54+
--mysql-port=$PORT \
55+
--mysql-user=$MYSQL_USER \
56+
--mysql-password=$MYSQL_PASSWORD \
57+
--mysql-db=$SYSBENCH_DB \
58+
--tables=$SYSBENCH_NUM_TABLES \
59+
--table-size=$SYSBENCH_TABLE_SIZE \
60+
61+
# Run Sysbench Prepare Statement for MySQL8.0
62+
export MYSQL_HOST="fill_up_with_MySQL8.0_writer"
63+
64+
# Drop and Recreate Database
65+
mysql_command "DROP DATABASE IF EXISTS $SYSBENCH_DB;"
66+
mysql_command "CREATE DATABASE $SYSBENCH_DB;"
67+
68+
sysbench oltp_read_only prepare \
69+
--threads=$SYSBENCH_THREADS \
70+
--db-driver=mysql \
71+
--mysql-host=$MYSQL_HOST \
72+
--mysql-port=$PORT \
73+
--mysql-user=$MYSQL_USER \
74+
--mysql-password=$MYSQL_PASSWORD \
75+
--mysql-db=$SYSBENCH_DB \
76+
--tables=$SYSBENCH_NUM_TABLES \
77+
--table-size=$SYSBENCH_TABLE_SIZE \
78+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /