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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 在服务端/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
目录
相关文章
|
16天前
|
Linux 测试技术 网络安全
Linux系统之安装OneNav个人书签管理器
【10月更文挑战第19天】Linux系统之安装OneNav个人书签管理器
37 5
Linux系统之安装OneNav个人书签管理器
|
18天前
|
监控 Java Linux
Linux系统之安装Ward服务器监控工具
【10月更文挑战第17天】Linux系统之安装Ward服务器监控工具
41 5
Linux系统之安装Ward服务器监控工具
|
21天前
|
JSON JavaScript Linux
Linux系统之安装cook菜谱工具
【10月更文挑战第15天】Linux系统之安装cook菜谱工具
33 2
Linux系统之安装cook菜谱工具
|
13天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
35 2
|
14天前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
24 3
|
3天前
|
关系型数据库 MySQL Linux
Linux-安装Mariadb
本文介绍了在 Alibaba Cloud Linux 系统上安装和配置 MariaDB 10.5 的步骤。包括下载安装、初始化数据库、启动服务、处理启动失败的常见问题(如权限问题),以及如何连接数据库、设置密码和允许外部连接。通过这些步骤,您可以顺利完成 MariaDB 的安装和基本配置。
12 0
|
16天前
|
Linux 网络安全 虚拟化
适用于Linux的Windows子系统(WSL1)的安装与使用记录
并放到启动文件夹,就可以开机自动启动了。
20 0
|
5月前
|
NoSQL Java Linux
linux 安装 neo4j简介
Neo4j是高性能NoSQL图形数据库,利用图结构存储数据。推荐使用JDK 11配合Neo4j 3.x版本。下载3.5.9版,通过`curl`命令在Linux上获取tar.gz文件,然后解压。配置`neo4j.conf`,调整内存设置,开启远程访问。执行`./bin/neo4j start`启动,通过`http://服务器IP:7474`访问,默认凭据是username: neo4j, password: neo4j,登录后应更改密码。
476 1
|
存储 缓存 Ubuntu
【嵌入式开发】 Linux Kernel 下载 配置 编译 安装 及 驱动简介(二)
【嵌入式开发】 Linux Kernel 下载 配置 编译 安装 及 驱动简介(二)
209 0
|
Ubuntu 安全 Unix
【嵌入式开发】 Linux Kernel 下载 配置 编译 安装 及 驱动简介(一)
【嵌入式开发】 Linux Kernel 下载 配置 编译 安装 及 驱动简介(一)
257 0