puppet连载10:linux安装percona57/56/55、sysbench、tpcc模块

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 在服务端/puppet/soft下建my.cnf,内容为https://www.jianshu.com/p/c63fc6c71279在服务端/puppet/soft下建changemysql57pass.

在服务端/puppet/soft下建my.cnf,内容为https://www.jianshu.com/p/c63fc6c71279

在服务端/puppet/soft下建changemysql57pass.sh,内容为:

!/bin/bash

mysqld --initialize
mysqld --skip-grant-tables &
sleep 3
mysql -Dmysql -uroot -e "update mysql.user set authentication_string=password('xmrbi3967968@') where user='root';"
mysql -Dmysql -uroot -e "flush privileges;"
pkill mysqld
service mysqld start
chkconfig mysqld on

保存,退出,chmod +x /puppet/soft/changemysql57pass.sh

安装Percona-XtraDB-Cluster57/56/55、Percona-Server-57/56/55、sysbench、sysbench-tpcc、percona-toolkit、percona-xtrabackup、tpcc-mysql、设置配置文件/etc/my.cnf、更改默认root密码、mysql的安装方式包括yum和rpm

mkdir -p /etc/puppet/modules/linuxpercona/{manifests,templates,files}
vi /etc/puppet/modules/linuxpercona/manifests/init.pp
class linuxpercona::perconayum {
exec {"yum install https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/percona-release-0.1-7.noarch.rpm -y":
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => 'ls /etc/yum.repos.d/percona-release.repo',
}
exec {'ensure data':
command => 'mkdir /data',
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => 'ls /data',
}
}
class linuxpercona::perconaxtradbcluster57rpm {
exec {"client57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-XtraDB-Cluster-client-57-5.7.23-31.31.2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-XtraDB-Cluster-client-57",
}
exec {"qpress11":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/qpress-11-1.el7.x86_64.rpm",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep qpress-11",
}
exec {"socat":
command => "yum install -y socat perl* libev",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "whereis socat",
}
exec {"xtrabackup24":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep percona-xtrabackup-24",
}
exec {"sharedcompat57":
command => "rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-XtraDB-Cluster-shared-compat-57-5.7.23-31.31.2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-XtraDB-Cluster-shared-compat-57",
}
exec {"shared57":
command => "rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-XtraDB-Cluster-shared-57-5.7.23-31.31.2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-XtraDB-Cluster-shared-57",
}
exec {"server57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-XtraDB-Cluster-server-57-5.7.23-31.31.2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-XtraDB-Cluster-server-57",
}
exec {"sysbench":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/sysbench-1.0.9-1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep sysbench-1.0.9",
}
exec {"tpcc":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/sysbench-tpcc-1.0.15-2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep sysbench-tpcc-1.0.15",
}
exec {"toolkit":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/percona-toolkit-3.0.9-1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep percona-toolkit-3.0.9",
}
package {"unzip":
ensure => installed,
before => Exec["mysqltpcc"],
}
exec {"datamysql":
command => "mkdir /data",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data",
before => Exec["mysqltpcc"],
}
exec {"mysqltpcc":
command => "cd /data&& wget https://github.com/Percona-Lab/tpcc-mysql/archive/master.zip -O tpcc-mysql.zip&&unzip tpcc-mysql.zip",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/tpcc-mysql-master",
}
file {"/etc/my.cnf":
ensure => present,
source => "puppet:///soft/my.cnf",
require => Exec["server57"],
}
file {"/data/changemysql57pass.sh":
ensure => present,
source => "puppet:///soft/changemysql57pass.sh",
require => File["/etc/my.cnf"],
notify => Exec["changepass"],
}
exec {"changepass":
command => "sh /data/changemysql57pass.sh",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
require => File["/data/changemysql57pass.sh"],
refreshonly => true,
}
}

class linuxpercona::perconaserver57rpm {
exec { "sharedcompat57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-Server-shared-compat-57-5.7.23-25.1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-Server-shared-compat-57",
}
exec { "shared57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-Server-shared-57-5.7.23-25.1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-Server-shared-57",
}
exec { "client57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-Server-client-57-5.7.23-25.1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-Server-client-57",
}
exec {"qpress11":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/qpress-11-1.el7.x86_64.rpm",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep qpress-11",
}
exec {"socat":
command => "yum install -y socat perl* libev",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "whereis socat",
}
exec { "server57":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/Percona-Server-server-57-5.7.23-25.1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep Percona-Server-server-57",
}
exec {"sysbench":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/sysbench-1.0.9-1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep sysbench-1.0.9",
}
exec {"tpcc":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/sysbench-tpcc-1.0.15-2.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep sysbench-tpcc-1.0.15",
}
exec {"toolkit":
command => "rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/percona/yum/release/centos/7Server/RPMS/x86_64/percona-toolkit-3.0.9-1.el7.x86_64.rpm --force --nodeps",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "rpm -qa|grep percona-toolkit-3.0.9",
}
package {"unzip":
ensure => installed,
before => Exec["mysqltpcc"],
}
exec {"datamysql":
command => "mkdir /data",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data",
before => Exec["mysqltpcc"],
}
exec {"mysqltpcc":
command => "cd /data&& wget https://github.com/Percona-Lab/tpcc-mysql/archive/master.zip -O tpcc-mysql.zip&&unzip tpcc-mysql.zip",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/tpcc-mysql-master",
}
file {"/etc/my.cnf":
ensure => present,
source => "puppet:///soft/my.cnf",
require => Exec["server57"],
}
file {"/data/changemysql57pass.sh":
ensure => present,
source => "puppet:///soft/changemysql57pass.sh",
require => File["/etc/my.cnf"],
notify => Exec["changepass"],
}
exec {"changepass":
command => "sh /data/changemysql57pass.sh",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
require => File["/data/changemysql57pass.sh"],
refreshonly => true,
}
}

class linuxpercona::perconaxtradbcluster57 {
require linuxpercona::perconayum
package {"Percona-XtraDB-Cluster-57":
ensure => installed,
}
}
class linuxpercona::perconaxtradbcluster56 {
require linuxpercona::perconayum
package {"Percona-XtraDB-Cluster-56":
ensure => installed,
}
}
class linuxpercona::perconaxtradbcluster55 {
require linuxpercona::perconayum
package {"Percona-XtraDB-Cluster-55":
ensure => installed,
}
}
class linuxpercona::perconaserver57 {
require linuxpercona::perconayum
package {"Percona-Server-server-57":
ensure => installed,
}
}
class linuxpercona::perconaserver56 {
require linuxpercona::perconayum
package {"Percona-Server-server-56":
ensure => installed,
}
}
class linuxpercona::perconaserverserver55 {
require linuxpercona::perconayum
package {"Percona-Server-server-55":
ensure => installed,
}
}
class linuxpercona::sysbench {
require linuxpercona::perconayum
package {"sysbench":
ensure => installed,
}
}
class linuxpercona::sysbenchtpcc {
require linuxpercona::perconayum
package {"sysbench-tpcc":
ensure => installed,
}
}
class linuxpercona::perconatoolkit {
require linuxpercona::perconayum
package {"percona-toolkit":
ensure => installed,
}
}
class linuxpercona::perconaxtrabackup {
require linuxpercona::perconayum
package {"percona-xtrabackup":
ensure => installed,
}
}

修改

vi /etc/puppet/manifests/nodes/huangat-test.pp
node 'huangat-test' {
include test
include linuxbaseinstall
include linuxoptimize
include linuxjdktomcat::tomcat8036
include linuxclean::yumclean,linuxclean:puppetclean
}


provider => rpm,
source => "/tmp/rhel5/postfix-2.5.17-1.rhel5.x86_64.rpm",

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
14天前
|
Linux Python
Linux 安装python3.7.6
本教程介绍在Linux系统上安装Python 3.7.6的步骤。首先使用`yum`安装依赖环境,包括zlib、openssl等开发库。接着通过`wget`下载Python 3.7.6源码包并解压。创建目标文件夹`/usr/local/python3`后,进入解压目录执行配置、编译和安装命令。最后设置软链接,使`python3`和`pip3`命令生效。
|
17天前
|
Ubuntu Linux
Linux 各发行版安装 ping 命令指南
如何在不同 Linux 发行版(Ubuntu/Debian、CentOS/RHEL/Fedora、Arch Linux、openSUSE、Alpine Linux)上安装 `ping` 命令,详细列出各发行版的安装步骤和验证方法,帮助系统管理员和网络工程师快速排查网络问题。
104 20
|
10天前
|
NoSQL 关系型数据库 MySQL
Linux安装jdk、mysql、redis
Linux安装jdk、mysql、redis
111 7
|
17天前
|
Unix Linux 编译器
UNIX/Linux 上的安装
UNIX/Linux 上的安装。
37 2
|
2月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
73 4
|
2月前
|
存储 安全 数据管理
如何在 Rocky Linux 8 上安装和配置 Elasticsearch
本文详细介绍了在 Rocky Linux 8 上安装和配置 Elasticsearch 的步骤,包括添加仓库、安装 Elasticsearch、配置文件修改、设置内存和文件描述符、启动和验证 Elasticsearch,以及常见问题的解决方法。通过这些步骤,你可以快速搭建起这个强大的分布式搜索和分析引擎。
60 5
|
2月前
|
存储 缓存 Linux
【Linux】另一种基于rpm安装yum的方式
通过本文的方法,您可以在离线环境中使用RPM包安装YUM并进行必要的配置。这种方法适用于无法直接访问互联网的服务器或需要严格控制软件源的环境。通过配置本地YUM仓库,确保了软件包的安装和更新可以顺利进行。希望本文能够为您在特定环境中部署YUM提供实用的指导。
229 0
|
2月前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
133 8
|
2月前
|
监控 Linux
如何检查 Linux 内存使用量是否耗尽?这 5 个命令堪称绝了!
本文介绍了在Linux系统中检查内存使用情况的5个常用命令:`free`、`top`、`vmstat`、`pidstat` 和 `/proc/meminfo` 文件,帮助用户准确监控内存状态,确保系统稳定运行。
536 6
|
2月前
|
Linux
在 Linux 系统中,“cd”命令用于切换当前工作目录
在 Linux 系统中,“cd”命令用于切换当前工作目录。本文详细介绍了“cd”命令的基本用法和常见技巧,包括使用“.”、“..”、“~”、绝对路径和相对路径,以及快速切换到上一次工作目录等。此外,还探讨了高级技巧,如使用通配符、结合其他命令、在脚本中使用,以及实际应用案例,帮助读者提高工作效率。
103 3