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

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 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",

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
15天前
|
Linux
手把手教会你安装Linux系统
手把手教会你安装Linux系统
|
7天前
|
Linux 测试技术 网络安全
Linux系统之安装OneNav个人书签管理器
【10月更文挑战第19天】Linux系统之安装OneNav个人书签管理器
26 5
Linux系统之安装OneNav个人书签管理器
|
9天前
|
监控 Java Linux
Linux系统之安装Ward服务器监控工具
【10月更文挑战第17天】Linux系统之安装Ward服务器监控工具
24 5
Linux系统之安装Ward服务器监控工具
|
11天前
|
JSON JavaScript Linux
Linux系统之安装cook菜谱工具
【10月更文挑战第15天】Linux系统之安装cook菜谱工具
28 2
Linux系统之安装cook菜谱工具
|
13天前
|
Ubuntu Linux 测试技术
Linux系统之Ubuntu安装cockpit管理工具
【10月更文挑战第13天】Linux系统之Ubuntu安装cockpit管理工具
48 4
Linux系统之Ubuntu安装cockpit管理工具
|
13天前
|
Linux 网络安全 数据安全/隐私保护
Linux系统之Centos7安装cockpit图形管理界面
【10月更文挑战第12天】Linux系统之Centos7安装cockpit图形管理界面
37 1
Linux系统之Centos7安装cockpit图形管理界面
|
3天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
13 2
|
4天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
12 3
|
15天前
|
Ubuntu 关系型数据库 MySQL
Linux系统MySQL安装
【10月更文挑战第19天】本文介绍了在 Linux 系统上安装 MySQL 的步骤,包括安装前准备、安装 MySQL、启动 MySQL 服务、配置 MySQL 以及验证安装。适用于 Ubuntu/Debian 和 CentOS/Fedora 系统,提供了详细的命令示例。
|
6天前
|
Linux 网络安全 虚拟化
适用于Linux的Windows子系统(WSL1)的安装与使用记录
并放到启动文件夹,就可以开机自动启动了。
9 0