TASK [yum install mariadb zabbix httpd] **************************************** fatal: [192.168.100.112]: FAILED! => {"changed": false, "msg": "No package matching 'zabbix-server-mysql' found available, installed or updated", "rc": 126, "results": ["httpd-2.4.6-99.el7.centos.1.x86_64 providing httpd is already installed", "No package matching 'zabbix-server-mysql' found available, installed or updated"]}
时间: 2023-07-19 07:56:47 浏览: 132
这是一个 Ansible playbook 中的错误提示,它说明在执行该任务时,系统无法找到名为 'zabbix-server-mysql' 的软件包。可能的原因是该软件包没有被正确安装或者软件源配置不正确。你可以尝试检查一下系统中是否已经安装了该软件包,或者检查一下 playbook 中使用的软件源是否可用。另外,你也可以尝试使用其他方式来安装 'zabbix-server-mysql'。
相关问题
创建2台系统为centos7.5的云主机,其中一台作为Ansible的母机并命名为ansible,另一台云主机命名为node,通过http服务中的ansible.tar.gz软件包在ansible节点安装Ansible服务;并用这台母机,补全Ansible脚本(在HTTP中下载install_zabbix.tar.gz并解压到/root目录下),补全Ansible脚本使得执行install_zabbix.yaml可以在node节点上完成zabbix服务的安装。 ftp.repo: [zabbix] name=zabbix baseurl=file:///opt/Zabbix enabled=1 gpgcheck=0 [ftp_centos] name=ftp_centos baseurl=ftp://controller/centos enabled=1 gpgcheck=0 [root@ansible ~]# cat install_zabbix.yaml - hosts: zabbix remote_user: root tasks: - name: rm repo shell: rm -f /etc/yum.repos.d/* - name: cp repo copy: src=/etc/yum.repos.d/ftp.repo dest=/etc/yum.repos.d/ - name: cp zabbix copy: src=/opt/zabbix dest=/opt/ - name: yum install mariadb zabbix httpd yum: name=mariadb,mariadb-server,zabbix-server-mysql,zabbix-web-mysql,zabbix-agent,trousers state=present - name: start httpd service: name=httpd state=started enabled=yes - name: start mariadb service: name=mariadb state=started enabled=yes -name: mysql passwd shell: mysqladmin -u root password 123456 - name: grant shell: mysql -u root -p123456 -e "create database zabbix character set utf8 collate utf8_bin;" && mysql -u root -p123456 -e "grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';" && mysql -u root -p123456 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';" - name: sql shell: zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz |mysql -u zabbix -pzabbix zabbix - name: cp config copy: src=/etc/zabbix/zabbix_server.conf dest=/etc/zabbix/ - name: start zabbix service: name=zabbix-server state=started
好的,我了解了您的问题。您想创建2台系统为CentOS 7.5的云主机,其中一台作为Ansible的母机并命名为ansible,另一台云主机命名为node,并通过http服务中的ansible.tar.gz软件包在ansible节点安装Ansible服务。然后用这台母机,补全Ansible脚本(在HTTP中下载install_zabbix.tar.gz并解压到/root目录下),补全Ansible脚本使得执行install_zabbix.yaml可以在node节点上完成zabbix服务的安装。
以下是您需要执行的步骤:
1. 在您的云平台上创建2台CentOS 7.5的云主机,分别命名为ansible和node。
2. 在ansible节点上安装Ansible服务,可以通过以下命令完成安装:
```
$ yum install ansible
```
3. 从http服务中下载ansible.tar.gz软件包,并将其解压到ansible节点上的/opt目录下:
```
$ wget http://your_http_server/ansible.tar.gz -P /opt/
$ tar -zxvf /opt/ansible.tar.gz -C /opt/
```
4. 在ansible节点上创建一个名为hosts的文件,并添加node节点的IP地址:
```
$ vi /etc/ansible/hosts
```
添加以下内容:
```
[node]
192.168.1.100
```
5. 从http服务中下载install_zabbix.tar.gz软件包,并将其解压到ansible节点上的/root目录下:
```
$ wget http://your_http_server/install_zabbix.tar.gz -P /root/
$ tar -zxvf /root/install_zabbix.tar.gz -C /root/
```
6. 创建一个名为install_zabbix.yaml的Ansible脚本,并将以下内容复制到脚本中:
```
---
- hosts: node
remote_user: root
tasks:
- name: rm repo
shell: rm -f /etc/yum.repos.d/*
- name: cp repo
copy: src=/etc/yum.repos.d/ftp.repo dest=/etc/yum.repos.d/
- name: cp zabbix
copy: src=/opt/zabbix dest=/opt/
- name: yum install mariadb zabbix httpd
yum:
name: "{{ item }}"
state: present
with_items:
- mariadb
- mariadb-server
- zabbix-server-mysql
- zabbix-web-mysql
- zabbix-agent
- trousers
- name: start httpd
service:
name: httpd
state: started
enabled: yes
- name: start mariadb
service:
name: mariadb
state: started
enabled: yes
- name: mysql passwd
shell: mysqladmin -u root password 123456
- name: grant
shell: mysql -u root -p123456 -e "create database zabbix character set utf8 collate utf8_bin;" && mysql -u root -p123456 -e "grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';" && mysql -u root -p123456 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
- name: sql
shell: zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -pzabbix zabbix
- name: cp config
copy: src=/etc/zabbix/zabbix_server.conf dest=/etc/zabbix/
- name: start zabbix
service:
name: zabbix-server
state: started
```
7. 执行install_zabbix.yaml脚本,使得在node节点上完成zabbix服务的安装:
```
$ ansible-playbook /root/install_zabbix.yaml
```
以上就是您所需要执行的步骤,祝您顺利完成任务!
centos zabbix 脚本
以下在CentOS系统上安装Zabbix监控系统的脚本:
1. 安装EPEL仓库和Zabbix仓库:
```bash
yum install epel-release -y
rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
```
2. 安装Zabbix server, agent, frontend:
```bash
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
```
3. 安装MySQL数据库:
```bash
yum install mariadb-server -y
systemctl enable mariadb
systemctl start mariadb
```
4. 创建Zabbix数据库和用户:
```bash
mysql -uroot -p
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
quit
```
5. 导入Zabbix数据库结构:
```bash
zcat /usr/share/doc/zabbix-server-mysql-5.0.*/create.sql.gz | mysql -uzabbix -p zabbix
```
6. 配置Zabbix server:
```bash
vi /etc/zabbix/zabbix_server.conf
```
修改以下行:
```conf
DBName=zabbix
DBUser=zabbix
DBPassword=password
```
7. 配置PHP时区:
```bash
vi /etc/httpd/conf.d/zabbix.conf
```
添加以下行:
```conf
php_value date.timezone Asia/Shanghai
```
8. 启动Zabbix服务:
```bash
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl restart zabbix-server
systemctl restart zabbix-agent
systemctl restart httpd
```
9. 安装Zabbix agent:
```bash
yum install zabbix-agent
```
10. 配置Zabbix agent:
```bash
vi /etc/zabbix/zabbix_agentd.conf
```
修改以下行:
```conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=CentOS-7
```
11. 启动Zabbix agent:
```bash
systemctl enable zabbix-agent
systemctl restart zabbix-agent
```
这样,您就可以访问Zabbix Web界面并开始监控您的服务器了。默认的登录用户名和密码是“Admin / zabbix”。
阅读全文