2022年7月

下载地址

 

https://pkg.loongnix.cn/loongnix-server/8.3/AppStream/loongarch64/release/Packages/?filter=containerd

yum install -y docker-ce-cli-19.03.0-3.el7.aarch64.rpm

yum install -y containerd.io-1.2.2-3.el7.aarch64.rpm

yum install -y container-selinux-2.107-3.el7.noarch.rpm

yum install -y docker-ce-19.03.0-3.el7.aarch64.rpm
/^((\(\d{2,3}\))|(\d{3}\-))?1(3|5|6|7|8|9)\d{9}$/

 

 

1.建立数据目录

/data/mysql/3307/

shown -R mysql:mysql 3307

2.配置文件

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]
user=mysql
port=3307
datadir=/data/mysql/3307
socket=/data/mysql/3307/mysql.sock
log_error=/data/logs/mariadb/3307_mariadb.log
server-id=2

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
character-set-server=utf8

# This group is only read by MariaDB-10.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.5]

#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#


[client]
socket=/data/mysql/3306/mysql.sock

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
default-character-set=utf8

3.初始化数据库

/usr/bin/mysql_install_db --defaults-file=/data/mysql/3307/my.cnf --datadir=/data/mysql/3307

4. 启动

/usr/bin/mysqld_safe --defaults-file=/data/mysql/3307/my.cnf --skip-grant-tables 2>&1 > /dev/null &

5. 修改密码 

 mysql -uroot -p -S /data/mysql/3307/mysql.sock  空密码登陆

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'jetsong2326';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'jetsong2326';
flush privileges;

6. /usr/bin/mysqld_safe --defaults-file=/data/mysql/3307/my.cnf  2>&1 > /dev/null &

7.管理脚本

#!/bin/bash

. /etc/init.d/functions

PORT=$2

USER=root

PASSWD=123456

MYSQLBIN='/usr/local/mysql/bin'

SOCKETFILE="/multidata/${PORT}/mysql.sock"

PIDFILE="/multidata/${PORT}/mysql.pid"

MYCNF="/multidata/${PORT}/my.cnf"

[[ $# -eq 2 ]] || {

   echo "Usage: $0 {start|stop|restart|reload} {PORT}"

   exit 1

}

mysql_start() {

   [[ -e "$SOCKETFILE" ]] && {

       action "MySQL port: $PORT IS already running" /bin/false

       exit 0

   } || {

       action "Starting MySQL...  please wait" /bin/true

       $MYSQLBIN/mysqld_safe --defaults-file=$MYCNF &> /dev/null &

   }

   [[ "$?" == "0" ]] && {

       action "MySQL has been Started" /bin/true

   } || {

       action "MySQL Started" /bin/false

   }

}

mysql_stop() {

   [[ ! -e "$SOCKETFILE" ]] && {

       action "MySQL port:$PORT was already down" /bin/false

   } || {

       $MYSQLBIN/mysqladmin -u $USER -p$PASSWD -S $SOCKETFILE shutdown &>/dev/null

   }

   [[ "$?" == 0 ]] && {

       action  "MySQL port:$PORT has been Stopped" /bin/true

   }

}

case "$1" in

'start')

   mysql_start

   ;;

'stop')

   mysql_stop

   ;;

'restart'|'reload')

   mysql_stop

   sleep 3

   mysql_start

   ;;

*)

   echo "Usage: $0 {start|stop|restart|reload} {PORT}"

esac

 

1.下载对应版本

https://mariadb.org/download/?t=repo-config&d=CentOS+8+%28x86_64%29&v=10.8&r_m=blendbyte

2.安装

dnf install MariaDB-server

3.启动

systemctl start mariadb

systemctl enable mariadb

4.初始化

mariadb-secure-installation

5.配置文件

/etc/my.cnf.d/

 

1.安装压测工具

curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
sudo yum -y install sysbench

2.创建测试数据库

CREATE DATABASE test_db;
CREATE USER 'test_user'@'127.0.0.1' IDENTIFIED BY 'test_user';
GRANT ALL ON test_db.* TO 'test_user'@'127.0.0.1';
flush privileges;

3.创建测试数据

sysbench --db-driver=mysql --time=30 --threads=50 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=test_user --mysql-db=test_db --tables=5 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare

参数解释:
–db-driver=mysql:基于mysql的驱动去连接mysql数据库,如果是oracle,或者sqlserver,那自然就是其他的数据库的驱动了
–time=30:这个就是说连续访问30秒
–threads=50:这个就是说用50个线程模拟并发访问
–report-interval=1:这个就是说每隔1秒输出一下压测情况
–mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=test_user:这个是说连接到哪台机器的哪个端口上的MySQL库,他的用户名和密码是什么
–mysql-db=test_db --tables=5 --table_size=500000:这个是说在test_db这个库里,构造5个测试表,每个测试表里构造50万条测试数据
oltp_read_write:这个就是说,执行oltp数据库的读写测试
–db-ps-mode=disable:这个是禁止ps模式
prepare:意思是参照这个命令的设置去构造出来我们需要的数据库里的数据,他会自动创建5个测试表,每个表里创建50万条测试数据。
 

4. 开始测试

sysbench --db-driver=mysql --time=30 --threads=50 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=test_user --mysql-db=test_db --tables=5 --table_size=500000 oltp_read_write --db-ps-mode=disable run

oltp_write_only:测试写入性能
oltp_read_write : 测试读写性能
oltp_read_only:测试只读性能
oltp_delete:测试删除性能
oltp_update_index: 测试更新索引字段性能
oltp_update_non_index: 测试更新非索引字段性能
oltp_insert: 测试插入性能
 

5.结果

read: 273602 的意思是在30s的压测期间执行了27万多次的读请求
write: 78172 的意思在压测期间执行了差不多8万次的写请求
other: 39086 的意思是在压测期间执行了差不多4万次的其他请求
total: 390860 的意思是一共执行了39万多次的请求
transactions: 19543 ( 650.89 per sec. ) 的意思是一共执行了差不多2万万个事务,每秒执行650.89多个事务
queries: 390860 (13017.74 per sec. ) 的意思是一共执行了39万多次的请求,每秒执行1万3千多请求
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
// 下面就是说,一共执行了30s的压测,执行了差不多两万的事务
General staticstics:
total time: 30.0240s
total number of events: 19543
Latency (ms):
min: 3.80 意思是请求中延迟最小的是3.80ms
avg: 76.77 意思是所有请求平均延迟是76.77ms
max: 710.73 意思是延迟最大的请求是710.73ms
95th percentile: 262.64 意思是95%的请求延迟都在262.64 ms以内
 

6.清理测试数据

sysbench --db-driver=mysql --time=300 --threads=50 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=test_user --mysql-db=test_db --tables=5 --table_size=500000 oltp_read_write --db-ps-mode=disable cleanup