### Create and Start VM for Base Install Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-904-amd64.md Creates a qcow2 disk image and starts a KVM virtual machine for the base Ubuntu installation. ```bash qemu-img create -f qcow2 vm-jaunty-amd64-serial.qcow2 8G ``` ```bash kvm -m 1024 -hda vm-jaunty-amd64-serial.qcow2 -cdrom /kvm/ubuntu-9.04-server-amd64.iso -redir tcp:2227::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user ``` -------------------------------- ### Quick Start: Install and Run MariaDB AI RAG on Ubuntu Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/tools/mariadb-ai-rag/deployment/ubuntu-deployment.md A comprehensive quick start guide to install MariaDB, secure it, create a database, install the AI RAG package, configure it, and start the services. ```bash # 1. Install MariaDB sudo apt update && sudo apt install -y mariadb-server mariadb-client sudo systemctl start mariadb && sudo systemctl enable mariadb # 2. Secure MariaDB (set root password during setup) sudo mysql_secure_installation # 3. Create database sudo mariadb -u root -p <> /etc/apt/sources.list'"; \ done ``` -------------------------------- ### Create and Start VM for Ubuntu 11.04 AMD64 Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1104-natty.md Creates a qcow2 disk image and starts a KVM virtual machine for installing Ubuntu 11.04 (amd64). It redirects TCP port 2255 to the VM's port 22 and uses virtio network model. The first command boots from ISO for installation, and the second boots from the created disk after installation. ```bash qemu-img create -f qcow2 vm-natty-amd64-serial.qcow2 8G kvm -m 1024 -hda vm-natty-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu-11.04-server-amd64.iso -redir tcp:2255::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user ``` ```bash kvm -m 1024 -hda vm-natty-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu-11.04-server-amd64.iso -redir tcp:2255::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic ``` -------------------------------- ### Start VM Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1404-trusty.md Launch KVM virtual machines to begin the Ubuntu installation process. Port forwarding is configured for SSH access. ```bash kvm -m 2048 -hda /kvm/vms/vm-trusty-amd64-serial.qcow2 \ -cdrom /kvm/iso/ubuntu/trusty-server-amd64.iso \ -boot d -smp 2 -cpu qemu64 \ -net nic,model=virtio \ -net user,hostfwd=tcp:127.0.0.1:2293-:22 ``` ```bash kvm -m 2048 -hda /kvm/vms/vm-trusty-i386-serial.qcow2 \ -cdrom /kvm/iso/ubuntu/trusty-server-i386.iso \ -boot d -smp 2 -cpu qemu64 \ -net nic,model=virtio \ -net user,hostfwd=tcp:127.0.0.1:2294-:22 ``` -------------------------------- ### Start VMs for Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-19.md Launch KVM virtual machines, booting from the Fedora 19 installation ISO. Configure memory, CPU, network, and serial redirection for installation. ```bash kvm -m 2048 -hda /kvm/vms/vm-fedora19-i386-serial.qcow2 -cdrom /ds413/iso/fedora/Fedora-19-i386-DVD.iso -redir tcp:2289::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user ``` ```bash kvm -m 2048 -hda /kvm/vms/vm-fedora19-amd64-serial.qcow2 -cdrom /ds413/iso/fedora/Fedora-19-x86_64-DVD.iso -redir tcp:2290::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user ``` -------------------------------- ### Install MariaDB Server and Client on Ubuntu Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/tools/mariadb-ai-rag/deployment/ubuntu-deployment.md Installs the MariaDB server and client packages, then starts and enables the MariaDB service to run on boot. ```bash # Update package lists sudo apt update # Install MariaDB sudo apt install -y mariadb-server mariadb-client # Start and enable MariaDB sudo systemctl start mariadb sudo systemctl enable mariadb # Verify running sudo systemctl status mariadb ``` -------------------------------- ### Example: BEGIN WITH CONSISTENT SNAPSHOT Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/ha-and-performance/standard-replication/enhancements-for-start-transaction-with-consistent-snapshot.md This example demonstrates the basic usage of starting a transaction with a consistent snapshot using the BEGIN alias. ```sql BEGIN WITH CONSISTENT SNAPSHOT; ``` -------------------------------- ### Quick Start: Setup and Baseline Query Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/analytics/mariadb-columnstore/use-cases/query-accelerator.md This section sets up a test database and table, adds an index, and runs a baseline query to measure performance before Query Accelerator is enabled. ```sql CREATE DATABASE IF NOT EXISTS test; USE test; CREATE TABLE IF NOT EXISTS test.customer_indexed ( `c_d_id` int(2) NOT NULL, `c_w_id` int(6) NOT NULL, `c_first` varchar(16) , `c_middle` char(2) , `c_last` varchar(16) , `c_street_1` varchar(20) , `c_street_2` varchar(20) , `c_city` varchar(20) , `c_state` char(2) , `c_zip` int(5) , `c_phone` char(16) , `c_since` datetime DEFAULT NULL, `c_credit` char(2) , `c_credit_lim` decimal(12,2) DEFAULT NULL, `c_discount` decimal(4,4) DEFAULT NULL, `c_balance` decimal(12,2) DEFAULT NULL, `c_ytd_payment` decimal(12,2) DEFAULT NULL, `c_payment_cnt` int(8) DEFAULT NULL, `c_delivery_cnt` int(8) DEFAULT NULL, `c_data` varchar(500)) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO test.customer_indexed SELECT ROUND(RAND() * 42000, 0), ROUND(RAND() * 42000, 0), substring(MD5(RAND()*1000000000),1,16), substring(MD5(RAND()),1,2), substring(MD5(RAND()*1000000000),1,16), substring(MD5(RAND()*1000000000),1,20), substring(MD5(RAND()*1000000000),1,20), substring(MD5(RAND()*1000000000),1,20), substring(MD5(RAND()),1,2), ROUND(RAND() * 42000, 0), substring(MD5(RAND()),1,16), CURRENT_TIMESTAMP - INTERVAL FLOOR(RAND() * 365 * 24 * 60 *60) SECOND, substring(MD5(RAND()),1,2), ROUND(RAND() * 9999999999, 2), ROUND(RAND() * 0, 4), ROUND(RAND() * 9999999999, 2), ROUND(RAND() * 9999999999, 2), ROUND(RAND() * 42000, 0), ROUND(RAND() * 42000, 0), substring(MD5(RAND()*1000000000),1,500) FROM seq_1_to_8000000; -- 3.5 min ALTER TABLE test.customer_indexed ADD INDEX idx_fast (`c_zip`, `c_payment_cnt`); -- ~1.5 min -- baseline SELECT c_zip, sum(c_payment_cnt) FROM test.customer_indexed GROUP BY c_zip ORDER BY c_zip ; --2.6s ``` -------------------------------- ### Start firewalld Service Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/analytics/mariadb-columnstore/management/deployment/install-guide/multnode-localstorage/step-4-start-and-configure-mariadb-enterprise-server.md Start the firewalld service if it was stopped during the installation process. This example assumes cluster nodes are in the 192.0.2.0/24 subnet. ```bash sudo systemctl start firewalld ``` -------------------------------- ### Start VMs for installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1304-raring.md Initiate virtual machine instances for Ubuntu installation. These commands boot from an ISO, configure network interfaces with host forwarding for SSH access, and specify CPU and memory settings. ```bash kvm -m 2048 -hda /kvm/vms/vm-raring-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-13.04-server-amd64.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2279-:22 ``` ```bash kvm -m 2048 -hda /kvm/vms/vm-raring-i386-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-13.04-server-i386.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2280-:22 ``` -------------------------------- ### Start MaxScale with Custom Config Path (Root Install) Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/maxscale/maxscale-management/installation-and-configuration/installing-maxscale-using-a-tarball.md Example of starting MaxScale with a custom configuration file path using the --config flag. ```bash $ sudo bin/maxscale --user=maxscale --config=/usr/local/maxscale/etc/maxscale.cnf -d ``` -------------------------------- ### Run MariaDB Secure Installation Script Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/clients-and-utilities/deployment-tools/mariadb-secure-installation.md Invoke the `mariadb-secure-installation` script without arguments to start an interactive session for securing your MariaDB installation. The script will guide you through several security-related prompts. ```bash shell> mariadb-secure-installation ``` -------------------------------- ### Create and Populate Example Tables Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/mariadb-quickstart-guides/mariadb-selecting-data-guide.md Sets up the 'books' and 'authors' tables with sample data for use in subsequent examples. Ensure these tables are created before running SELECT queries. ```sql CREATE OR REPLACE TABLE books ( isbn CHAR(20) PRIMARY KEY, title VARCHAR(50), author_id INT, publisher_id INT, year_pub CHAR(4), description TEXT ); CREATE OR REPLACE TABLE authors ( author_id INT AUTO_INCREMENT PRIMARY KEY, name_last VARCHAR(50), name_first VARCHAR(50), country VARCHAR(50) ); INSERT INTO authors (name_last, name_first, country) VALUES ('Kafka', 'Franz', 'Czech Republic'), ('Dostoevsky', 'Fyodor', 'Russia'); INSERT INTO books (title, author_id, isbn, year_pub) VALUES ('The Trial', 1, '0805210407', '1995'), ('The Metamorphosis', 1, '0553213695', '1995'), ('America', 2, '0805210644', '1995'), -- Note: Original data had author_id 2 for 'America', Dostoevsky is author_id 2. ('Brothers Karamozov', 2, '0553212168', ''), ('Crime & Punishment', 2, '0553211757', ''), ('Crime & Punishment', 2, '0553211757', ''), ('Idiot', 2, '0192834118', ''), ('Notes from Underground', 2, '067973452X', ''); ``` -------------------------------- ### Start VM Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-16.md Initiate VM boot from the server install ISO using kvm. Configure memory, disk, CD-ROM, network redirection, and CPU settings. ```bash kvm -m 1024 -hda /kvm/vms/vm-fedora16-i386-serial.qcow2 -cdrom /kvm/iso/fedora/Fedora-16-i386-DVD.iso -redir tcp:2263::22 -boot d -smp 2 -cpu qemu32,-nx -net nic,model=virtio -net user ``` ```bash kvm -m 1024 -hda /kvm/vms/vm-fedora16-amd64-serial.qcow2 -cdrom /kvm/iso/fedora/Fedora-16-x86_64-DVD.iso -redir tcp:2264::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user ``` -------------------------------- ### Install Testing VM Setup Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-18.md Automates the setup of a VM for installation testing. It updates packages and installs necessary dependencies for testing. ```bash for i in '/kvm/vms/vm-fedora18-i386-serial.qcow2 2277 qemu64' '/kvm/vms/vm-fedora18-amd64-serial.qcow2 2278 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/install/')" \ "sudo yum -y update" \ "sudo yum -y install patch tar libaio perl perl-Time-HiRes perl-DBI" ; \ done ``` -------------------------------- ### Automate VM Setup for Install Testing Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1204-precise.md This script automates the setup of virtual machines for installation testing. It configures package sources and installs necessary packages. ```bash for i in '/kvm/vms/vm-precise-amd64-serial.qcow2 22255 qemu64' '/kvm/vms/vm-precise-i386-serial.qcow2 22256 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/install/')" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get update" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y patch libaio1 debconf-utils" \ "= scp -P $2 /kvm/vms/my.seed /kvm/vms/sources.append buildbot@localhost:/tmp/" \ "sudo debconf-set-selections /tmp/my.seed" \ "sudo sh -c 'cat /tmp/sources.append >> /etc/apt/sources.list'"; \ done ``` -------------------------------- ### Start VM Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1310-saucy.md Launch KVM virtual machines to boot from the server install ISO. Configure network settings with host forwarding for SSH access. ```bash kvm -m 2048 -hda /kvm/vms/vm-saucy-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-13.10-server-amd64.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2287-:22 ``` ```bash kvm -m 2048 -hda /kvm/vms/vm-saucy-i386-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-13.10-server-i386.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2288-:22 ``` -------------------------------- ### Complete Installation and Basic Configuration Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-804-810-and-910.md Continues the VM installation, configures SSH access, and sets up the buildbot user. Ensure 'authorized_keys' and 'ttyS0' files are prepared. ```bash # Install, picking default options mostly, only adding openssh server. kvm -m 1024 -hda vm-hardy-amd64-serial.qcow2 -cdrom /kvm/ubuntu-8.04.3-server-amd64.iso -redir tcp:2228::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic ssh -p 2228 localhost # edit /boot/grub/menu.lst and visudo, see below sudo /sbin/shutdown -h now ``` ```bash # Install, picking default options mostly, only adding openssh server. kvm -m 1024 -hda vm-hardy-i386-serial.qcow2 -cdrom /kvm/ubuntu-8.04.3-server-i386.iso -redir tcp:2229::22 -boot c -smp 2 -cpu qemu32,-nx -net nic,model=virtio -net user -nographic ssh -p 2229 localhost # edit /boot/grub/menu.lst and visudo, see below ``` ```bash # Install, picking default options mostly, only adding openssh server. kvm -m 1024 -hda vm-intrepid-amd64-serial.qcow2 -cdrom /kvm/ubuntu-8.10-server-amd64.iso -redir tcp:2230::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic ssh -p 2230 localhost # edit /boot/grub/menu.lst and visudo, see below ``` ```bash # Install, picking default options mostly, only adding openssh server. kvm -m 1024 -hda vm-intrepid-i386-serial.qcow2 -cdrom /kvm/ubuntu-8.10-server-i386.iso -redir tcp:2231::22 -boot c -smp 2 -cpu qemu32,-nx -net nic,model=virtio -net user -nographic ssh -p 2231 localhost ``` -------------------------------- ### MySQL Upgrade Testing VM Setup Script Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-19.md This script sets up VMs for MySQL upgrade testing. It installs MySQL server and client, enables and starts the service, and performs a basic database test. ```bash for i in '/kvm/vms/vm-fedora19-i386-serial.qcow2 2289 qemu64' '/kvm/vms/vm-fedora19-amd64-serial.qcow2 2290 qemu64' ; do set $i; runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/upgrade/')" "sudo yum -y update" "sudo yum -y install patch tar mysql-server libtool-ltdl unixODBC" "sudo systemctl enable mysqld.service" "sudo systemctl start mysqld.service" 'mysql -uroot -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' ; done ``` -------------------------------- ### Setup VMs for MariaDB Upgrade Testing Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-16.md This script sets up virtual machines for testing MariaDB upgrades. It updates the system, installs MariaDB server and client, configures the repository, and starts the MariaDB service. ```shell for i in '/kvm/vms/vm-fedora16-amd64-serial.qcow2 2264 qemu64' '/kvm/vms/vm-fedora16-i386-serial.qcow2 2263 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/upgrade2/')" \ 'sudo yum -y update' \ '= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/MariaDB.repo buildbot@localhost:/tmp/' \ 'sudo rpm --verbose --import http://downloads.mariadb.org/repo/RPM-GPG-KEY-MariaDB' \ 'sudo mv -vi /tmp/MariaDB.repo /etc/yum.repos.d/' \ 'sudo yum -y remove mysql-libs' \ 'sudo yum -y install MariaDB-server MariaDB-client MariaDB-test' \ 'sudo yum -y install cronie cronie-anacron crontabs.noarch postfix' \ 'sudo /etc/init.d/mysqld start' \ 'mysql -uroot -prootpass -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' \ 'sudo rm -v /etc/yum.repos.d/MariaDB.repo' \ '= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/MariaDB.local.repo buildbot@localhost:/tmp/' \ 'sudo mv -vi /tmp/MariaDB.local.repo /etc/yum.repos.d/'; \ done ``` -------------------------------- ### Create Example Table and Insert Data Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain.md Sets up a sample 'employees_example' table with indexes and populates it with data for demonstrating query analysis. ```sql CREATE TABLE IF NOT EXISTS `employees_example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(30) NOT NULL, `last_name` varchar(40) NOT NULL, `position` varchar(25) NOT NULL, `home_address` varchar(50) NOT NULL, `home_phone` varchar(12) NOT NULL, `employee_code` varchar(25) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `employee_code` (`employee_code`), KEY `first_name` (`first_name`,`last_name`) ) ENGINE=Aria; INSERT INTO `employees_example` (`first_name`, `last_name`, `position`, `home_address`, `home_phone`, `employee_code`) VALUES ('Mustapha', 'Mond', 'Chief Executive Officer', '692 Promiscuous Plaza', '326-555-3492', 'MM1'), ('Henry', 'Foster', 'Store Manager', '314 Savage Circle', '326-555-3847', 'HF1'), ('Bernard', 'Marx', 'Cashier', '1240 Ambient Avenue', '326-555-8456', 'BM1'), ('Lenina', 'Crowne', 'Cashier', '281 Bumblepuppy Boulevard', '328-555-2349', 'LC1'), ('Fanny', 'Crowne', 'Restocker', '1023 Bokanovsky Lane', '326-555-6329', 'FC1'), ('Helmholtz', 'Watson', 'Janitor', '944 Soma Court', '329-555-2478', 'HW1'); SHOW INDEXES FROM employees_example; +-------------------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------------------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | employees_example | 0 | PRIMARY | 1 | id | A | 7 | NULL | NULL | | BTREE | | | | employees_example | 0 | employee_code | 1 | employee_code | A | 7 | NULL | NULL | | BTREE | | | | employees_example | 1 | first_name | 1 | first_name | A | NULL | NULL | NULL | | BTREE | | | | employees_example | 1 | first_name | 2 | last_name | A | NULL | NULL | NULL | | BTREE | | | +-------------------+------------+---------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ ``` -------------------------------- ### Automated VM Setup for Building .debs Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1110-oneiric.md Iterates through VM configurations, starting them, updating package lists, installing build dependencies for mysql-server-5.1, and essential build tools. This prepares VMs for creating .deb packages. ```bash for i in '/kvm/vms/vm-oneiric-amd64-serial.qcow2 2255 qemu64' '/kvm/vms/vm-oneiric-i386-serial.qcow2 2256 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/build/')" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get update" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get -y build-dep mysql-server-5.1" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts hardening-wrapper fakeroot doxygen texlive-latex-base ghostscript libevent-dev libssl-dev zlib1g-dev libreadline6-dev" ; \ done ``` -------------------------------- ### Setup VMs for MySQL Upgrade Testing Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-16.md This script configures virtual machines for testing MySQL upgrades. It sets up the base image, installs MySQL server, enables and starts the service, and creates a test database. ```shell for i in '/kvm/vms/vm-fedora16-amd64-serial.qcow2 2264 qemu64' '/kvm/vms/vm-fedora16-i386-serial.qcow2 2263 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/upgrade/')" \ "sudo yum -y update" \ 'sudo yum -y install mysql-server' \ 'sudo systemctl enable mysqld.service' \ 'sudo systemctl start mysqld.service' \ 'mysql -uroot -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' \ "= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/MariaDB.local.repo buildbot@localhost:/tmp/" \ "sudo mv -vi /tmp/MariaDB.local.repo /etc/yum.repos.d/"; \ done ``` -------------------------------- ### Example: START TRANSACTION with READ ONLY and WITH CONSISTENT SNAPSHOT Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/ha-and-performance/standard-replication/enhancements-for-start-transaction-with-consistent-snapshot.md This example shows how to start a transaction that is both read-only and uses a consistent snapshot. ```sql START TRANSACTION READ ONLY, WITH CONSISTENT SNAPSHOT; ``` -------------------------------- ### Create and Use Catalog Example Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/security/user-account-management/catalogs/create-catalog.md Demonstrates creating a catalog named 'cat1', setting it as the current catalog, and then creating a user and granting privileges. ```sql CREATE CATALOG cat1; USE CATALOG cat1; CREATE USER root@localhost; GRANT ALL PRIVILEGES ON *.* TO root@localhost; CREATE DATABASE test; ``` -------------------------------- ### Create Sequence with Start and Increment Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/sql-structure/sequences/create-sequence.md Defines a sequence with a specified starting value and increment. The first example starts at 100 and increments by 10. The second example uses negative values. ```sql CREATE SEQUENCE s START WITH 100 INCREMENT BY 10; ``` ```sql CREATE SEQUENCE s2 START WITH -100 INCREMENT BY -10; ``` -------------------------------- ### Start MariaDB Server (Non-Root Install) Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/server-management/install-and-upgrade-mariadb/installing-mariadb/binary-packages/installing-mariadb-binary-tarballs.md Command to start the MariaDB server when installed as a non-root user, specifying a defaults file. ```bash ./bin/mariadbd-safe --defaults-file=~/.my.cnf & ``` -------------------------------- ### SQL Example for Selecting and Verifying Database Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/connectors/mariadb-connector-c/api-functions/mysql_select_db.md Demonstrates how to switch to a default database using USE and then verify the current default database with SELECT DATABASE(). ```sql # switch to default database test USE test; # check default database SELECT DATABASE(); +------------+ | database() | +------------+ | test | +------------+ ``` -------------------------------- ### Install VM for General Installation Testing Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1304-raring.md Sets up a VM for general installation testing by updating packages, installing necessary utilities, and configuring APT sources. Requires 'my.seed' and 'sources.append' files. ```bash for i in '/kvm/vms/vm-raring-amd64-serial.qcow2 2279 qemu64' '/kvm/vms/vm-raring-i386-serial.qcow2 2280 qemu64' ; do \ set $i; \ runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/install/')" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get update" \ "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y patch libaio1 debconf-utils" \ "= scp -P $2 /kvm/vms/my55.seed /kvm/vms/sources.append buildbot@localhost:/tmp/" \ "sudo debconf-set-selections /tmp/my55.seed" \ "sudo sh -c 'cat /tmp/sources.append >> /etc/apt/sources.list'"; \ndone ``` -------------------------------- ### Start MariaDB Server (Root Install) Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/server-management/install-and-upgrade-mariadb/installing-mariadb/binary-packages/installing-mariadb-binary-tarballs.md Commands to start the MariaDB server after installation as root. The second option allows specifying a custom defaults file. ```bash ./bin/mariadbd-safe --user=mysql & ``` ```bash ./bin/mariadbd-safe --defaults-file=~/.my.cnf --user=mysql & ``` -------------------------------- ### Start VM Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1210-quantal.md Launch KVM virtual machines to begin the Ubuntu installation process. Configure memory, disk, CD-ROM, CPU, and network settings, including host port forwarding for SSH. ```bash kvm -m 2048 -hda /kvm/vms/vm-quantal-amd64-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-amd64.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2275-:22 ``` ```bash kvm -m 2048 -hda /kvm/vms/vm-quantal-i386-serial.qcow2 -cdrom /kvm/iso/ubuntu/ubuntu-12.10-server-i386.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:2276-:22 ``` -------------------------------- ### Start MaxScale in Foreground (Root Install) Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/maxscale/maxscale-management/installation-and-configuration/installing-maxscale-using-a-tarball.md Command to start MaxScale in debug mode without daemonizing, useful for initial troubleshooting. Assumes installation in /usr/local. ```bash $ sudo bin/maxscale --user=maxscale -d ``` -------------------------------- ### Start VMs for Installation Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-centos-62.md Launch KVM virtual machines booting from CentOS 6.2 install ISOs. Configure port redirection for SSH access and specify CPU and network settings. ```bash kvm -m 1024 -hda /kvm/vms/vm-centos6-amd64-serial.qcow2 -cdrom /kvm/iso/centos/CentOS-6.2-x86_64-bin-DVD1.iso -redir tcp:22255::22 -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user kvm -m 1024 -hda /kvm/vms/vm-centos6-i386-serial.qcow2 -cdrom /kvm/iso/centos/CentOS-6.2-i386-bin-DVD1.iso -redir tcp:22256::22 -boot d -smp 2 -cpu qemu32,-nx -net nic,model=virtio -net user ``` -------------------------------- ### Install a Single Plugin using INSTALL SONAME Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/sql-statements/administrative-sql-statements/plugin-sql-statements/install-soname.md Even if a shared library contains only one plugin, INSTALL SONAME can be used to install it. This example installs the 'ha_sequence' plugin. ```sql INSTALL SONAME 'ha_sequence'; ``` -------------------------------- ### MariaDB Upgrade Testing VM Setup Script Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-red-hat/buildbot-setup-for-virtual-machines-fedora-19.md This script configures VMs for MariaDB upgrade testing. It involves removing MySQL packages, installing MariaDB server and client, starting the service, and performing a database test. It also handles repository configuration. ```bash for i in '/kvm/vms/vm-fedora19-amd64-serial.qcow2 2290 qemu64' '/kvm/vms/vm-fedora19-i386-serial.qcow2 2289 qemu64' ; do set $i; runvm --user=buildbot --logfile=kernel_$2.log --base-image=$1 --port=$2 --cpu=$3 "$(echo $1 | sed -e 's/serial/upgrade2/')" 'sudo yum -y update' '= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/MariaDB-${2}.repo buildbot@localhost:/tmp/MariaDB.repo' 'sudo rpm --verbose --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB' 'sudo mv -vi /tmp/MariaDB.repo /etc/yum.repos.d/' 'sudo yum -y remove mysql-libs' 'sudo yum -y install MariaDB-server MariaDB-client MariaDB-test libtool-ltdl unixODBC' 'sudo yum -y install cronie cronie-anacron crontabs.noarch patch tar' 'sudo /etc/init.d/mysql start' 'mysql -uroot -e "create database mytest; use mytest; create table t(a int primary key); insert into t values (1); select * from t"' 'sudo rm -v /etc/yum.repos.d/MariaDB.repo' 'sudo yum -y update' '= scp -P $2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /kvm/vms/MariaDB.local.repo buildbot@localhost:/tmp/' 'sudo mv -vi /tmp/MariaDB.local.repo /etc/yum.repos.d/'; done ``` -------------------------------- ### Prepare VM for Testing by Copying and Running Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/product-development/server-development/tools/buildbot/setup/buildbot-setup-for-virtual-machines/buildbot-setup-for-virtual-machines-ubuntu/buildbot-setup-for-virtual-machines-ubuntu-1304-raring.md These commands prepare a VM image by copying it, then launching it with specific network and CPU configurations. After initial setup, it connects via SSH to shut down the VM cleanly. Ensure the correct ports and paths are used. ```bash # raring-amd64 cp -avi /kvm/vms/vm-raring-amd64-install.qcow2 /kvm/vms/vm-raring-amd64-test.qcow2 kvm -m 1024 -hda /kvm/vms/vm-raring-amd64-test.qcow2 -redir tcp:2279::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic sudo su - buildbot ssh -p 2279 buildbot@localhost sudo shutdown -h now # answer "yes" when prompted exit # the buildbot user rm -v /kvm/vms/vm-raring-amd64-test.qcow2 ``` ```bash # raring-i386 cp -avi /kvm/vms/vm-raring-i386-install.qcow2 /kvm/vms/vm-raring-i386-test.qcow2 kvm -m 1024 -hda /kvm/vms/vm-raring-i386-test.qcow2 -redir tcp:2280::22 -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user -nographic sudo su - buildbot ssh -p 2280 buildbot@localhost sudo shutdown -h now # answer "yes" when prompted exit # the buildbot user rm -v /kvm/vms/vm-raring-i386-test.qcow2 ``` -------------------------------- ### Build and Install GLB from Source Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/galera-cluster/high-availability/load-balancing/galera-load-balancer.md Clone the GLB repository, bootstrap, configure, and install the daemon and library. This process is required as there are no pre-built packages. ```bash git clone https://github.com/codership/glb cd glb/ ./bootstrap.sh ./configure make sudo make install ``` -------------------------------- ### Interactive MariaDB Security Setup Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/clients-and-utilities/deployment-tools/mariadb-secure-installation.md This is an example of the interactive prompts and output from the `mariadb-secure-installation` script. It demonstrates the steps involved in securing a MariaDB installation, including setting the root password, removing anonymous users, disallowing remote root login, and removing the test database. ```bash Example: localhost:# mariadb-secure-installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password is blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! ``` -------------------------------- ### Install Sphinx on Red Hat/CentOS Source: https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/server-usage/storage-engines/sphinx-storage-engine/installing-sphinx.md Install Sphinx on Red Hat or CentOS systems by first installing postgresql-libs and unixODBC, then installing the Sphinx RPM package. After installation, start the searchd service. ```bash sudo yum install postgresql-libs unixODBC sudo rpm -Uhv sphinx*.rpm ``` ```bash service searchd start ```