Windows 10的Linux子系统Ubuntu安装Zabbix Server(2)

接上一篇Windows 10的Linux子系统Ubuntu安装Zabbix Server(1) ,两次尝试都因为内存过小导致无法继续安装。开始怀疑是否Linux子系统能否安装成功,试过就知道了。

Linux子系统安装Docker,再使用Docker安装Zabbix Server

启用Linux子系统功能

Linux子系统功能并非默认安装的,在Windows Store安装Ubuntu应用之后发现无法使用,多半原因是未启用Linux子系统功能。
在控制面板,启用或关闭功能中找到Linux子系统并启用。如果未找到Linux子系统选项,多半是Windows 10的系统版本过低,升级Windows 10之后就有Linux子系统选项了。

Ubuntu子系统安装Docker

查看Ubuntu版本信息

参考ubuntu:查看ubuntu系统的版本信息 ,原文中有一个命令手写有误(lsb_release写成了sb_release),索性作者的截图中有正确给出来。

uname -a

root@XX:/mnt/c/Users/sp# uname -a
Linux XX 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux

从命令返回信息看出来:内核版本是4.4.0 ,64位系统(x86_64)

cat /proc/version

root@XX:/mnt/c/Users/sp# cat /proc/version
Linux version 4.4.0-43-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1-Microsoft Wed Dec 31 14:42:53 PST 2014

lsb_release -a

root@XX:/mnt/c/Users/sp# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

Ubuntu 16.04.3 LTS:16年4月3号发布,LTS指Long Term Support长时间支持

安装Docker

$ sudo apt-get update

$ sudo apt-get install docker

拉取Zabbix Server image

因为已经安装了Docker for Windows,导致一直拉取失败。本以为是Ubuntu子系统安装有误,重新卸载安装之后仍无法正确pull。于是怀疑是安装了Docker for Windows,验证一下,在Ubuntu子系统中卸载Docker,敲击命令docker -v,仍然能查看docker版本号,证实怀疑。于是在Windows控制面板卸载Docker for Windows,卸载完成后Ubuntu子系统再次安装Docker。这一番查资料,反复折腾了有几个小时,彻底失去想要尝试使用Docker的想法。

Ubuntu子系统作为一个Windows 10 应用,卸载和安装十分方便,代价比虚拟机装Ubuntu系统小得多。索性卸载之后重装子系统,按照Zabbix Server官方给出的安装步骤 一点点的试着安装。

Linux子系统安装Zabbix Server

正确选择OS VERSION,虽说前面折腾了许久,好像一点用没有,赖好是知道了正确的版本。中途尝试了安装14.04LTS对应的Zabbix Server,安装失败。不要折腾,正确对应版本安装。
以下步骤摘自Zabbix官方安装配置文档

Install and configure Zabbix server

Install Repository with MySQL database

# wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
# dpkg -i zabbix-release_3.4-1+xenial_all.deb
# apt update

子系统实际上是在C盘占用了硬盘空间,wget时会下载当前所在目录,所以为了不让C盘过大,我选择了在F盘下执行wget命令。

Install Zabbix server, frontend, agent

# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Create initial database

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;

'password' 改为自己想要设置的密码
Import initial schema and data. You will be prompted to enter your newly created password.

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

执行该步骤是为了初始化zabbix表,新增一些表,需要耐心等待,我因为没有耐心,Ctrl+c退出该命令的执行过程,所以再次执行时报错提示表已经创建,所以只好登录进去mysql,删除zabbix数据库drop zabbix,重新执行下面创建数据库的命令。

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> quit;

Configure the database for Zabbix server

DBPassword=password

该条配置不是需要执行的命令,而是需要在zabbix_server.conf配置文件里加上的一条配置。我一开始将这条命令执行,启动Zabbix之后一直因为无法连上数据库导致没有server服务一直在页面下面黄条提示zabbix server is not running

# cd /etc/zabbix
# ls //该条命令是查看是否有zabbix_server.conf配置文件
# vim zabbix_server.conf

找到 注释的# DBPassword=,将password改为之前设置的MySQL密码,添加该配置,记得不要带#。

Start Zabbix server and agent processes

Start Zabbix server and agent processes and make it start at system boot:

# systemctl start zabbix-server zabbix-agent apache2
# systemctl enable zabbix-server zabbix-agent apache2

上述命令是为了启动zabbix-server、zabbix-agent、apache2,并将三个服务加入守护进程,但是因为是子系统,
# systemctl start zabbix-server zabbix-agent apache2 使用失败,
启动服务的命令改为

# service zabbix-server start
# service zabbix-agent start
# service zabbix-agent apache2

启动之后再执行# systemctl enable zabbix-server zabbix-agent apache2,并且保证有一个Ubuntu命令窗口开启,zabbix才能正常运行。

Configure PHP for Zabbix frontend

Edit file /etc/zabbix/apache.conf, uncomment and set the right timezone for you.

# php_value date.timezone Europe/Riga

修改配置文件apache.conf,将时区配置成当前所在时区,中国的时区是 Asia/Shanghai。

Configure Zabbix frontend

Connect to your newly installed Zabbix frontend: http://server_ip_or_name/zabbix
Follow steps described in Zabbix documentation: Installing frontend

Start using Zabbix

See Quickstart guide

猜你喜欢

转载自blog.csdn.net/u014654707/article/details/79760253