Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update en doc #181

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module.exports = {
collapsable: false,
children: [
['', 'Finding optimal configurations'],
// ['System_monitor_of_Zabbix.md', 'System monitoring installation and use of Zabbix'],
['System_monitor_of_Zabbix.md', 'System monitoring (Zabbix)'],
]
}
],
Expand Down
152 changes: 82 additions & 70 deletions docs/operation/System_monitor_of_Zabbix.md
Original file line number Diff line number Diff line change
@@ -1,178 +1,190 @@


#### 一、服务器基础配置:
## Initial setup

```bash
systemctl stop firewalld
systemctl disbale firewalld
vim /etc/selinux/config
$ systemctl stop firewalld
$ systemctl disbale firewalld
$ vim /etc/selinux/config

SELINUX=disabled //修改selinux为disabled
setenforce 0 //临时修改selinux状态
getenforce //查看selinux状态
$ SELINUX=disabled # change selinux to disabled
$ setenforce 0 # temporarily change selinux status
$ getenforce # check selinux status
```

#### 二、安装相关软件包
## Install software dependencies

```bash
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all && yum makecache
$ rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
$ yum clean all && yum makecache

// server端安装zabbix-server和zabbix-agent
# yum install zabbix-server-mysql zabbix-agent -y
# Install zabbix-server and zabbix-agent
$ yum install zabbix-server-mysql zabbix-agent -y

//安装zabbix默认的nginx
# yum install centos-release-scl -y
# yum install rh-php72-php-mysqlnd zabbix-nginx-conf-scl -y
# Install zabbix-ready nginx
$ yum install centos-release-scl -y
$ yum install rh-php72-php-mysqlnd zabbix-nginx-conf-scl -y
```

修改zabbix的安装源配置文件,启用前端的源
Change zabbix configurations and start Web GUI.

```bash
# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 //此处改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
$ vim /etc/yum.repos.d/zabbix.repo
```

```toml
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 # change to 1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
```


#### 三、安装MySQL
## Install MySQL

```bash
mkdir mysql-dir
cd mysql-dir
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
tar -zxvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
yum install *.rpm -y
$ mkdir mysql-dir
$ cd mysql-dir
$ wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
$ tar -zxvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
$ yum install *.rpm -y
```

```bash
systemctl start mysqld
$ systemctl start mysqld
```

```bash
cat /var/log/mysqld.log | grep root
$ cat /var/log/mysqld.log | grep root
```

Grep default password.

```bash
2021-07-26T10:50:49.538494Z 1 [Note] A temporary password is generated for root@localhost: **20yyk:Ar67S;**
```

登录数据库:
Login to database.

```mysql
# mysql -uroot -p
```bash
$ mysql -uroot -p
Enter password: 20yyk:Ar67S;
```

配置数据库:
Config database.

```bash
set global validate_password_policy=0;
set global validate_password_length=1;
alter user 'root'@'localhost' identified by 'venus'; #修改root登录密码为venus
alter user 'root'@'localhost' identified by 'venus'; # Change root password

use mysql;
update user set host = '%' where user = 'root';
create user 'zabbix'@'%' identified by '123456';
grant all privileges on zabbix.* to 'zabbix'@'%';
flush privileges;

# 创建zabbix所需的数据库
# Create tables for Zabbix
create database zabbix character set utf8 collate utf8_bin;
```

导入zabbix模版文件:
Import zabbix template files.

```bash
zcat /usr/share/doc/zabbix-server-mysql-5.0.14/create.sql.gz | mysql -uzabbix -p123456 zabbix
$ zcat /usr/share/doc/zabbix-server-mysql-5.0.14/create.sql.gz | mysql -uzabbix -p123456 zabbix
```

## Configure zabbix


#### 四、修改zabbix默认配置文件

1、修改连接数据库的密码:
Change database password.

```bash
# vim /etc/zabbix/zabbix_server.conf
$ vim /etc/zabbix/zabbix_server.conf
DBPassword=123456
```
2、修改nginx和所属地域
Configure Nginx.

```bash
# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
# 在第6行后边加上一个nginx
$ vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
```

Append `nginx` at the end of line 6.

```
listen.acl_users = apache,nginx
```

Change location to your choice at line 24.

# 在第24行修改zabbix所属的地域
```
php_value[date.timezone] = Asia/shanghai
```

3、配置监听端口和访问方式
Configure port.

```bash
vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
$ vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
server {
listen 80;//取消注释
server_name test.zabbix.com;//取消注释修改成IP或自己的域名
listen 80; # uncomment this line
server_name test.zabbix.com; # uncomment and change to your own ip
```

4、如果是伪装域名则修改本地的hosts文件
Change your hosts file too if using hostname.

```bash
vim /etc/hosts
$ vim /etc/hosts
192.168.xx.xx test.zabbix.com
```

If you are using windows.

window hosts文件也需要添加一下
```bash
# for window hosts
C:\Windows\System32\drivers\etc\hosts
192.168.xxx.xxx test.zabbix.com
```

5、启动服务并设为开机自启
Start service and configure to run on boot.

```bash
# 启动服务
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
```

6、修改zabbix-agent的配置文件
Change zabbix agent config fie

```bash
cat /etc/zabbix/zabbix_agentd.conf | egrep -v "^$|^#"
$ cat /etc/zabbix/zabbix_agentd.conf | egrep -v "^$|^#"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.88.11 //指定zabbix-server的ip地址
Server=192.168.88.11 # point to ip of zabbix-server
Hostname=venus-sealer
Include=/etc/zabbix/zabbix_agentd.d/*.conf
```

#### 四、配置zabbix监控主机
1、在浏览器输入zabbix-server的ip地址或者主机名
## Configure monitoring

Visit your zabbix-server with a browser.
![](/01-zabbix-install.jpg)
![](/02-zabbix-install.jpg)

2、配置数据库连接地址信息
Configure database connection information.
![](/03-zabbix-config.jpg)
![](/04-zabbix-hostname.jpg)
![](/05-zabbix-all.jpg)
![](/06-zabbix-finished.jpg)

3、登录到zabbix系统,默认的用户为Admin,密码为zabbix;注意Admin的A是大写字母
Login to zabbix. Default user is `Admin` with `zabbix` as password.
![](/07-zabbix-login.jpg)
![](/08-zabbix-dashboard.jpg)

4、添加zabbix-agent主机
Add zabbix-agent.
![](/09-zabbix-agent.jpg)
![](/10-zabbix-agent-add.jpg)

5、查看zabbix监控机器的内存图
Check zabbix RAM usage.
![](/11-zabbix-graphs.jpg)
![](/12-zabbix-memory.jpg)

6、异常报警,需要处理的机器
Check problems in dashboard.
![](/13-Alarm-information.jpg)