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

在服务端/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",

上一篇:.net中集合、容器(Collection)的这些事


下一篇:mysql5.7获取root密码