- 
                Notifications
    
You must be signed in to change notification settings  - Fork 18
 
Practices
The practice cases of ShannonBase.
- How to build ShannonBase from source code
 
step 0: Requirement Installation
1: compiling tools:
apt-get install -y g++
apt-get install -y libbison-dev
apt-get install -y flex
apt-get install -y clang-format
apt-get install -y lcov
apt-get install -y pkg-config
2: Cmake
apt-get install -y cmake
3: tools
apt-get install -y git
apt-get install -y wget
apt-get install -y tar
apt-get install -y bzip2
apt-get install -y unzip
4: openssl etc.
apt-get install -y libssl-dev
apt-get install -y libncurses-dev
apt-get install -y  libudev-dev
apt-get install -y libgsasl-dev
apt-get install -y libldap-dev
5: Boost [from source code]
wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2
tar -xvf boost_1_77_0.tar.bz2 && cd boost_1_77_0 && ./bootstrap.sh && ./b2  && ./b2 install
step 1: clone the source code from Shannonbase Repo
  git clone [email protected]:Shannon-Data/ShannonBase.git
step 2: makes a directory where we build the source code.
  cd ShannonBase && mkdir cmake_build && cd cmake_build
step 3: run cmake
 cmake ../ \
  -DWITH_BOOST=/path-to-boost-include-files/ \
  -DCMAKE_BUILD_TYPE=[Release|Debug]  \
  -DCMAKE_INSTALL_PREFIX=/path-to-shannon-bin \
  -DMYSQL_DATADIR=/home/path-to-shannon-bin/data \
  -DSYSCONFDIR=. \
  -DMYSQL_UNIX_ADDR=/home/path-to-shannon-bin/tmp/mysql.sock \
  -DWITH_EMBEDDED_SERVER=OFF \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DMYSQL_TCP_PORT=3306 \
  -DENABLED_LOCAL_INFILE=1 \
  -DEXTRA_CHARSETS=all \
  -DWITH_PROTOBUF=bundled \
  -DWITH_SSL_PATH=/path-to-open-ssl/ \
  -DDEFAULT_SET=community \
  -DWITH_UNIT_TESTS=OFF \
  [-DENABLE_GCOV=1 \ |
  -DWITH_ASAN=1 \    | 
  ]
  -DCOMPILATION_COMMENT="MySQL Community Server, and Shannon Data AI Alpha V.- (GPL)" 
step 4: compile and install
  make -j5 && make install
step 5: initialize the database
  /path-to-shannbase-bin/bin/mysqld --defaults-file=/path-to-shannonbase-bin/my.cnf --initialize  --user=xxx
step 6: run shannonbase
 /path-to-shannbase-bin/bin//mysqld --defaults-file=/path-to-shannonbase-bin/my.cnf   --user=xxx &  
the script of creating table and loading data can be found here. https://github.com/Shannon-Data/heatwave-tpch/tree/main/TPCH.
After we have loaded the data into rapid engine, then, start to run queries.
Taking NATION as an instance.
create database tpch_1024;
alter database tpch_1024 CHARACTER SET ascii COLLATE ascii_bin; 
use tpch_1024;
CREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,
                       N_NAME       CHAR(25) NOT NULL,
                       N_REGIONKEY  INTEGER NOT NULL,
                       N_COMMENT    VARCHAR(152),
                       PRIMARY KEY (N_NATIONKEY));
Load the data into rapid engine.
alter table NATION secondary_load;
and if you want to use rapid mandatorily.
set use_secondary_engine=forced;
or you can use it according to cost
set secondary_engine_cost_threshold = xxx;
then do query, it will use rapid to do query.
  select * from NATION;
Takes the following steps to build up ShannonBase master-replica.
Enable Binary Logging on the master server:
Edit the MySQL configuration file (/etc/my.cnf or /etc/mysql/my.cnf) to add or enable the following options:
[mysqld]
log_bin = mysql-bin  # Enable binary logging
server-id = 1        # Unique server ID for the master[1 is an example]
binlog_format = ROW  # Use row-based replication
- 
Restart MySQL servito apply the changes.
 - 
Create a Replication User on the master:
 
CREATE USER 'replica_user'@'%' IDENTIFIED BY 'replica_password';
GRANT REPLICATION SLAVE ON *.* TO 'replica_user'@'%';
FLUSH PRIVILEGES;
- Get the Master Log File and Position:
 
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
- Prepare the Replica Server: On the replica server, configure the MySQL configuration file with a unique server ID:
 
[mysqld]
server-id = 2        # Unique server ID for the replica[2 is an example]
relay_log = relay-bin  # Optional: to enable relay logging
- 
Restart Replica Service.
 - 
Set Up Replication on the replica: Run the following SQL on the replica to link it to the master:
 
CHANGE MASTER TO
MASTER_HOST = 'master_ip_address',
MASTER_USER = 'replica_user',
MASTER_PASSWORD = 'replica_password',
MASTER_LOG_FILE = 'mysql-bin.xxxxx',  # Use the file from the master
MASTER_LOG_POS = xxxxx;               # Use the position from the master
- Start Replica.
 
START SLAVE;
- Monitor and Maintain Replication.
 
SHOW SLAVE STATUS\G