华为云云耀云服务器L实例评测|Ubuntu系统MySQL 8.1.0 Innovation压测

32 篇文章 11 订阅
本文介绍了如何在华为云上运维服务器,包括Ubuntu系统下安装MySQL8.1.0、进行性能监控以及使用sysbench进行IO和CPU压力测试。详细步骤展示了如何安装监控插件,确保服务器稳定性和安全性。
摘要由CSDN通过智能技术生成

前言

本节首先给大家介绍下如何运维运维服务器,然后再带大家进行Ubuntu系统MySQL 8.1.0,并通过专业工具进行压力测试,我们一起看看性能。整体来看达到了预期的压侧效果。

往期回顾:
华为云云耀云服务器L实例评测|Ubuntu云服务器申请使用

📣 1.前言概述

华为云耀云服务器L实例是新一代开箱即用、面向中小企业和开发者打造的全新轻量应用云服务器。云耀云服务器L实例提供丰富严选的应用镜像,实现应用一键部署,助力客户便捷高效的在云端构建电商网站、Web应用、小程序、学习环境、各类开发测试等。
在上期对文章中,我们给大家讲解了如何拥有属于自己的一台云服务器,本节首先给大家介绍下如何运维运维服务器,然后再带大家进行Ubuntu系统MySQL 8.1.0,并通过专业工具进行压力测试,我们一起看看性能。整体来看达到了预期的压侧效果。

📣 2.云服务器性能监控

Linux操作系统在企业IT环境中的应用越来越广泛,其优异的性能、高安全性和低成本受到了许多企业的追捧。然而,Linux系统的监控却是一个不容忽视的问题。在Linux服务器数量增多、应用程序越来越复杂的环境下,Linux监控显得尤为重要,尤其咱们申请的云服务器。下面我们列举一些Linux监控的重要性。

  1. 保证系统稳定性
    作为企业IT环境中的核心系统之一,Linux服务器的故障将会对企业运营带来严重后果。通过监控Linux系统的硬件和软件,可以及时发现问题并进行处理,防止因故障导致系统崩溃,保证系统稳定运行。
  2. 预防安全威胁
    操作系统具有高度的可定制性和灵活度,但同时也带来了一些安全风险。黑客和恶意软件往往会以各种方式获得入侵企业的机会。通过定期监控Linux系统,可以及时发现和处理有关Linux安全的问题,提高系统的安全性。
  3. 提高系统性能
    监控Linux系统可以实时跟踪其系统性能,如CPU利用率、内存使用率、磁盘容量等,这些指标对于系统性能的评价和优化至关重要。通过监控这些指标,可以及时发现系统瓶颈和性能问题,对系统进行优化和改进,提高服务器性能、减少资源浪费,从而减少企业成本。
  4. 进行趋势分析
    监控Linux系统可以收集大量的数据,这些数据包括历史运行情况、失败情况、容量利用情况等。通过对这些数据进行分析和解释,可以获得更多有关Linux系统状态的信息,如对未来负载和容量使用情况的预测,以及对使用模式和业务需求的评估和分析等。通过这些分析,企业可以更好地判断和满足其网络需求。
  5. 进行问题判定和排查
    监控Linux系统可以帮助管理员快速判定问题的来源,如确定是软件故障还是硬件故障等,并能帮助排查问题所在位置。当有故障发生时,管理员可以根据监控信息,快速找到问题所在,减少恢复系统运行所需的时间和成本。
    总之,Linux监控对于企业IT环境的稳定运行、安全防护、提高性能、趋势分析以及故障排查等方面都具有重要意义。在面临日益复杂的企业IT环境时,Linux监控将成为一个不可或缺的工具,为企业带来更高的效益和利润。

那么申请的华为云服务器,通过以下方法,可以对服务器的各种性能进行全方位的监控。
1)点击控制台,找到云服务器,单击监控项,就可以看到一些基础监控。
2)操作系统的监控及进程监控需要安装插件即可

在这里插入图片描述
在这里插入图片描述

安装插件指引,安装后我们就可以对操作系统做各种监控,非常方便。
1)获取插件安装命令
cd /usr/local && curl -k -O https://obs.cn-east-3.myhuaweicloud.com/uniagent-cn-east-3/script/agent_install.sh && bash agent_install.sh
2)登录虚拟机,在服务器列表使用root账号远程登录目标虚拟机。
3)登录成功后,粘贴命令内容后点击发送按钮,按回车键开始执行命令。
4)反馈如下则安装成功,等待3-5分钟插件即可正常采集监控数据。

安装Agent前请确保 DNS与安全组配置,正确修改DNS(命令行方式)
使用root帐号,登录ECS。
输入"vi /etc/resolv.conf",打开文件。
在文件中添加"nameserver 100.125.1.250""nameserver 100.125.21.250",输入:wq,按“Enter”保存并退出

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

📣 3.MySQL8.1版本安装

✨ 3.1 安装包下载

首先要确定自己的操作系统版本,通过以下命令
root@hcss-ecs-7c99:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
通过官网连接,按照下图下载安装包
https://dev.mysql.com/downloads/mysql/

在这里插入图片描述

✨ 3.2 解压安装包

1)将下载的mysql安装包上传到/usr/local/mysql目录下
root@hcss-ecs-7c99:~# mkdir -p /usr/local/mysql

2)解压MySQL安装包
root@hcss-ecs-7c99:~# ll /usr/local/mysql
total 428952
drwxr-xr-x  2 root root      4096 Oct  1 10:27 ./
drwxr-xr-x 15 root root      4096 Oct  1 10:25 ../
-rw-rw-rw-  1 root root 439234560 Oct  1 10:34 mysql-server_8.1.0-1ubuntu22.04_amd64.deb-bundle.tar

root@hcss-ecs-7c99:~# cd /usr/local/mysql
root@hcss-ecs-7c99:/usr/local/mysql# sudo tar xvf mysql-server_8.1.0-1ubuntu22.04_amd64.deb-bundle.tar
libmysqlclient22_8.1.0-1ubuntu22.04_amd64.deb
libmysqlclient-dev_8.1.0-1ubuntu22.04_amd64.deb
mysql-client_8.1.0-1ubuntu22.04_amd64.deb
mysql-common_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-client_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-client-core_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-client-plugins_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-server-debug_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-test_8.1.0-1ubuntu22.04_amd64.deb
mysql-community-test-debug_8.1.0-1ubuntu22.04_amd64.deb
mysql-server_8.1.0-1ubuntu22.04_amd64.deb
mysql-testsuite_8.1.0-1ubuntu22.04_amd64.deb

3)依次安装包。由于包之间有依赖关系,一定要按照顺序安装
$ sudo dpkg -i mysql-common_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i mysql-community-client-plugins_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i libmysqlclient22_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i libmysqlclient-dev_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i mysql-community-client-core_8.1.0-1ubuntu22.04_amd64.deb

说明:此处要是缺少libaio1、libmecab2包,通过以下方法执行
# sudo apt-get update
# sudo apt-get install libaio1
# sudo apt-get install libmecab2

$ sudo dpkg -i mysql-community-client_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i mysql-client_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb
$ sudo dpkg -i mysql-community-server-core_8.1.0-1ubuntu22.04_amd64.deb

继续安装 sudo dpkg -i mysql-community-server_8.1.0-1ubuntu22.04_amd64.deb
安装完成后,继续安装 sudo dpkg -i mysql-server_8.1.0-1ubuntu22.04_amd64.deb

✨ 3.3 登录验证

安装完成后验证MySQL是否安装成功
mysql -u root -p  此处密码为beijing@123

root@hcss-ecs-7c99:/etc/mysql# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.1.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> status
--------------
mysql  Ver 8.1.0 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:          9
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.1.0 MySQL Community Server - GPL
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/run/mysqld/mysqld.sock
Binary data as:         Hexadecimal
Uptime:                 1 hour 20 min 33 sec

Threads: 2  Questions: 6  Slow queries: 0  Opens: 119  Flush tables: 3  Open tables: 38  Queries per second avg: 0.001
--------------

mysql> select host,user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)


创建用户,在给用户给权限
mysql> create user root@'%' identified with mysql_native_password by 'root';
mysql> grant all on *.* to root@'%' with grant option;
mysql> flush privileges;

📣 4.ubuntu安装sysbench

要在Ubuntu上安装sysbench,您可以按照以下步骤进行操作:
1.首先,安装编译sysbench所需的依赖。打开终端,并执行以下命令:
sudo apt-get update
sudo apt-get install build-essential libmysqlclient-dev libssl-dev libpq-dev libtool automake
2.安装sysbench。
sudo apt-get install sysbench
3.查询版本
root@hcss-ecs-7c99:~# sysbench --version
sysbench 1.0.20

📣 5.云服务器压测

✨ 5.1 IO测试

1) sysbench内置了几个测试指标。
root@hcss-ecs-7c99:~# sysbench fileio help
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N           block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]
  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]

2)创建5个文件,总共1G,每个文件大概200M,进行压力测试

root@hcss-ecs-7c99:~# sysbench fileio --file-num=5 --file-total-size=1G prepare
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

5 files, 209715Kb each, 1023Mb total
Creating files for the test...
Extra file open flags: (none)
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
Creating file test_file.4
1073807360 bytes written in 8.35 seconds (122.64 MiB/sec).
root@hcss-ecs-7c99:~# ls -lh test*
-rw------- 1 root root 205M Oct  1 17:01 test_file.0
-rw------- 1 root root 205M Oct  1 17:01 test_file.1
-rw------- 1 root root 205M Oct  1 17:01 test_file.2
-rw------- 1 root root 205M Oct  1 17:01 test_file.3
-rw------- 1 root root 205M Oct  1 17:01 test_file.4
root@hcss-ecs-7c99:~# pwd
/root

sysbench --events=5000 \
         --threads=16 \
         fileio \
         --file-num=5 \
         --file-total-size=1G \
         --file-test-mode=rndrw \
         --file-fsync-freq=0 \
         --file-block-size=16384 \
         run

在这里插入图片描述

✨ 5.2 CPU性能测试

root@hcss-ecs-7c99:~# sysbench cpu --threads=40 --events=10000 --cpu-max-prime=20000 run
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 40
Initializing random number generator from current time


Prime numbers limit: 20000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:   887.15

General statistics:
    total time:                          10.0229s
    total number of events:              8893

Latency (ms):
         min:                                    2.22
         avg:                                   44.72
         max:                                  201.83
         95th percentile:                       94.10
         sum:                               397723.87

Threads fairness:
    events (avg/stddev):           222.3250/1.71
    execution time (avg/stddev):   9.9431/0.05

在这里插入图片描述

📣 6.MySQ压力测试

1)准备测试数据
首先创建sysbench所需数据库sbtest(这是sysbench默认使用的库名,必须创建测试库)
root@hcss-ecs-7c99:~# mysqladmin -h127.0.0.1 -uroot -p -P3306 create sbtest;

root@hcss-ecs-7c99:~# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.1.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sbtest             |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

2)测试过程
sysbench --mysql-host=127.0.0.1 \
         --mysql-port=3306 \
         --mysql-user=root \
         --mysql-password=beijing@123 \
         /usr/share/sysbench/oltp_common.lua \
         --tables=10 \
         --table_size=100000 \
         prepare

sysbench --threads=4 \
         --time=20 \
         --report-interval=5 \
         --mysql-host=127.0.0.1 \
         --mysql-port=3306 \
         --mysql-user=root \
         --mysql-password=beijing@123 \
         /usr/share/sysbench/oltp_read_write.lua \
         --tables=10 \
         --table_size=100000 \
         run

在这里插入图片描述

  • 6
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT邦德

客户部署资料,步骤超详细

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值