-
Notifications
You must be signed in to change notification settings - Fork 35
/
deploy-zabbix-service.yml
135 lines (132 loc) · 4.09 KB
/
deploy-zabbix-service.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 一键部署Zabbix监控系统,包括VPC、安全组、ECS实例及Zabbix服务配置,支持内网访问。
en: One-click deployment of the Zabbix monitoring system, encompassing VPC setup,
security group configurations, ECS instance provisioning, and Zabbix service configuration,
with support for internal network access.
Parameters:
ZoneId:
Type: String
Label:
zh-cn: 可用区ID
en: Zone ID
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
EcsInstanceType:
Type: String
Label:
zh-cn: 实例类型
en: Instance Type
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
ZoneId: ${ZondId}
InstanceChargeType: PostPaid
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 192.168.0.0/16
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: Vpc
SecurityGroupIngress_80:
Type: 'ALIYUN::ECS::SecurityGroupIngress'
Properties:
SecurityGroupId:
Ref: SecurityGroup
IpProtocol: tcp
NicType: intranet
SourceCidrIp: 0.0.0.0/0
PortRange: 80/80
VSwitch:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
InstanceGroup:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: centos_7
SystemDiskCategory: cloud_essd
IoOptimized: optimized
InstanceType:
Ref: EcsInstanceType
MaxAmount: 1
InstallZabbix:
Type: 'ALIYUN::ECS::RunCommand'
Properties:
InstanceIds:
'Fn::GetAtt':
- InstanceGroup
- InstanceIds
Type: RunShellScript
CommandContent:
'Fn::Sub': |-
sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sudo yum clean all
sudo yum makecache
sudo yum install zabbix-server-mysql zabbix-agent -y
sudo yum install centos-release-scl -y
sudo sed -i 's/^enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo
sudo yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
sudo yum install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation <<EOF
y
zabbix
zabbix
y
n
y
y
EOF
sudo mysql -uroot -pzabbix -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;"
sudo mysql -uroot -pzabbix -e "CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix';"
sudo mysql -uroot -pzabbix -e "GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';"
sudo mysql -uroot -pzabbix -e "FLUSH PRIVILEGES;"
sudo zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
sudo sed -i 's/^# DBPassword=/DBPassword=zabbix/' /etc/zabbix/zabbix_server.conf
sudo sed -i 's/^; php/php/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
sudo sed -i 's/Europe\/Riga/Asia\/Shanghai/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
sudo systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
sudo systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
Sync: true
Timeout: 3600
DependsOn:
- SecurityGroupIngress_80
Outputs:
ZabbixUrl:
Description:
zh-cn: Zabbix页面。
en: Zabbix Page.
Value:
'Fn::Sub':
- 'http://${IP}/zabbix'
- IP:
'Fn::Jq':
- First
- '.[0]'
- 'Fn::GetAtt':
- InstanceGroup
- PublicIps
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId
- EcsInstanceType
TemplateTags:
- acs:solution:开发运维:一键部署Zabbix监控系统