Starting a WeSQL Cluster
After installing the WeSQL binary on three nodes, we are ready to start creating a WeSQL three-nodes cluster.Assuming the IP addresses of the three nodes are 192.168.0.2
, 192.168.0.3
and 192.168.0.4
.
192.168.0.2
will be designated as the Data node, while the other two nodes will be Logger nodes.
Step 1: Starting the Data Node
Step 1.1: Initialize the Data Directory
Initialize the data directory for the WeSQL data node , use the following command:
mysqld \
--no-defaults \
--initialize-insecure \
--datadir=/u01/mysql_data_leader \
--objectstore-provider=aws \
--objectstore-region=us-west-1 \
--objectstore-bucket=wesql-storage \
--repo-objectstore-id=sysbench \
--raft-replication-cluster-id=1 \
--raft-replication-cluster-info='192.168.0.2:13006;192.168.0.3:13006;192.168.0.4:13006@1'
The object storage path must be set to persist the SmartEngine data generated during initialization to the object storage.
For command options information, see description in WeSQL Parameters and Settings
Create the temporary directories needed for runtime.
mkdir -p /u01/mysql_data_leader_log /u01/mysql_data_leader_tmp /u01/mysql_data_leader_run
Step 1.2: Prepare the my.cnf
configuration file
Configure the WeSQL data node, create and edit the my.cnf file.
Open the configuration file for editing:
vim /u01/mysql_data_leader/my.cnf
Add the following content to the my.cnf file:
[mysqld]
# binlog
sync_binlog=1
sync_relay_log=1
log_bin=master-bin
log_bin_index=master-bin.index
# Raft settings
raft_replication_auto_leader_transfer=ON
# serverless settings
objectstore_provider=aws
objectstore_region=us-west-1
objectstore_bucket=wesql-storage
repo_objectstore_id=sysbench
branch_objectstore_id=main
#server
port=3006
datadir=/u01/mysql_data_leader
tmpdir=/u01/mysql_data_leader_tmp
socket=/u01/mysql_data_leader_tmp/mysqld.sock
pid-file=/u01/mysql_data_leader_run/mysqld.pid
log-error=/u01/mysql_data_leader_log/mysqld.err
If you're looking for more detailed explanations about my.cnf configuration parameters, it's recommended to refer to the MySQL Server documentation, and WeSQL Parameters and Settings.
Step 1.3: Start the Data Node
After saving the my.cnf file, you can start the WeSQL data node using the following command:
mysqld --defaults-file=/u01/mysql_data_leader/my.cnf &
Step 2: Starting the First Logger Node
Step 2.1: Initialize the Data Directory
Initialize the data directory for the WeSQL logger node, use the following command:
mysqld \
--no-defaults \
--initialize-insecure \
--datadir=/u01/mysql_data_logger1 \
--serverless=false \
--raft-replication-cluster-id=1 \
--raft-replication-cluster-info='192.168.0.2:13006;192.168.0.3:13006;192.168.0.4:13006@2'
The data for WeSQL logger node does not need to be persisted to object storage, so the --serverless=false
command option must be explicitly specified during initialization to disable the use of object storage.
Create the temporary directories needed for runtime.
mkdir -p /u01/mysql_data_logger1_log /u01/mysql_data_logger1_tmp /u01/mysql_data_logger1_run
Step 2.2: Prepare the my.cnf
configuration file
Configure the WeSQL logger node, create and edit the my.cnf file.
Open the configuration file for editing:
vim /u01/mysql_data_logger1/my.cnf
Add the following content:
[mysqld]
# binlog
sync_binlog=1
sync_relay_log=1
log_bin=slave-bin
log_bin_index=slave-bin.index
# Raft settings
raft_replication_auto_leader_transfer=ON
raft_replication_log_type_node=ON
# serverless settings
snapshot_archive=false
table_on_objectstore=false
objectstore_provider=aws
objectstore_region=us-west-1
objectstore_bucket=wesql-storage
repo_objectstore_id=sysbench
branch_objectstore_id=main
# server
port=3007
datadir=/u01/mysql_data_logger1
tmpdir=/u01/mysql_data_logger1_tmp
socket=/u01/mysql_data_logger1_tmp/mysqld.sock
pid-file=/u01/mysql_data_logger1_run/mysqld.pid
log-error=/u01/mysql_data_logger1_log/mysqld.err
Logger Node must explicitly disable the snapshot_archive=false
and table_on_objectstore=false
parameters.
snapshot_archive=false
indicates that the Logger Node cannot generate snapshots.
table_on_objectstore=false
indicates that the Logger Node data is not persisted in object storage.
raft_replication_log_type_node=ON
indicates that the current node is a Logger node.
If you're looking for more detailed explanations about my.cnf configuration parameters, it's recommended to refer to the MySQL Server documentation, and WeSQL Parameters and Settings.
Step 2.3: Start the Logger Node
Once the configuration file is saved, you can start the logger node with the following command:
mysqld --defaults-file=/u01/mysql_data_logger1/my.cnf &
Step 3: Starting the Second Logger Node
Starting the second logger node is similar to the first one. Follow these steps to set it up.
Step 3.1: Initialize the Data Directory
Initialize the MySQL data directory, use the following command:
mysqld \
--no-defaults \
--initialize-insecure \
--datadir=/u01/mysql_data_logger2 \
--serverless=false \
--raft-replication-cluster-id=1 \
--raft-replication-cluster-info='192.168.0.2:13006;192.168.0.3:13006;192.168.0.4:13006@3'
Create the temporary directories needed for runtime.
mkdir -p /u01/mysql_data_logger2_log /u01/mysql_data_logger2_tmp /u01/mysql_data_logger2_run
Step 3.2: Prepare the my.cnf
configuration file
Configure the WeSQL logger node, create and edit the my.cnf file.
Open the configuration file for editing:
vim /u01/mysql_data_logger2/my.cnf
Add the following content:
[mysqld]
# binlog
sync_binlog=1
sync_relay_log=1
log_bin=slave-bin
log_bin_index=slave-bin.index
# Raft setting
raft_replication_auto_leader_transfer=ON
raft_replication_log_type_node=ON
# serverless settings
snapshot_archive=false
table_on_objectstore=false
objectstore_provider=aws
objectstore_region=us-west-1
objectstore_bucket=wesql-storage
repo_objectstore_id=sysbench
branch_objectstore_id=main
# server
port=3008
datadir=/u01/mysql_data_logger2
tmpdir=/u01/mysql_data_logger2_tmp
socket=/u01/mysql_data_logger2_tmp/mysqld.sock
pid-file=/u01/mysql_data_logger2_run/mysqld.pid
log-error=/u01/mysql_data_logger2_log/mysqld.err
Step 3.3: Start the Logger Node
Once the my.cnf file is saved, start Logger Node 2 using the following command:
mysqld --defaults-file=/u01/mysql_data_logger2/my.cnf &