1. 安装前准备
a. 关闭防火墙
service iptables stop
b. 关闭selinux
setenforce 0 #临时关闭
vim /etc/selinux/config #将SELINUX的值修改为disable,永久关闭
2. 安装 mysql
a. 下载 mysql 安装文件:mysql-5.6.37-linux-glibc2.12-x86_64.tar
b. 解压 tar zxvf mysql-5.6.37-linux-glibc2.12-x86_64.tar
c. 复制解压后的文件
cp -r mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql
d. 添加用户组和用户
groupadd mysql
useradd -g mysql mysql
e. 安装
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
f. 修改启动项,配置环境变量
vi /etc/init.d/mysqld
修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
环境变量:
vi /etc/profile
添加:export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile
g. 启动服务测试连接
启动:service mysqld start
测试:./mysql/bin/mysql -uroot
查看运行状态:service mysqld status
关闭:service mysqld stop
3. 安装 mysql 常见错误
a. sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
use mysql;
select 'host' from user where user='root';
delete from user where root=" ";
update user set host = '%' where user ='root';
flush privileges;
b. 安装时遇到:-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
c. error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel
d. MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
解决: ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
报错:ln: creating symbolic link `/data/mysqldata/mysql.sock' to `/tmp/mysql.sock': File exists
rm mysql.sock #上面提示文件存在,所以删除之前的mysql.sock文件
ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
e. Access denied for user 'root'@'localhost' (using password:YES)
解决:在 my.cnf 文件中最后 skip-grant-tables 保存并关闭文件,重启mysql;
输入“mysql -u root -p”(不输入密码),回车即可进入数据库,执行:update user set password=PASSWORD("yourPassword") where user='root';
打开my.chf 删除刚刚添加的 skip-grant-tables 保存退出,重启 mysql 即可。
4. 安装 zabbix
a. 添加用户组和用户
groupadd zabbix
useradd -g zabbix zabbix
b. 创建数据库和用户
mysql> CREATE DATABASE zabbix CHARACTER SET utf8;
mysql> show databases;
mysql> GRANT ALL on zabbix.* TO zabbix@'%' IDENTIFIED BY 'zabbix';
c. 下载 zabbix 安装包:zabbix-2.4.6.tar.gz
解压:tar zxvf zabbix-2.4.6.tar.gz
安装LAMP环境:
yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear
(由于mysql数据库上面已经安装了,这个可以不安装mysql了mysql mysql-server mysql-devel)
安装zabbix所需的组件(server,agent)
yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
编译安装,如果是客户端安装选择--enable-agent就行了。
./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
报错:configure: error: in `/home/zabbix/zabbix-2.4.7':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
解决:执行:yum install gcc
继续 ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
成功,执行 make install
d. 初始化 zabbix 数据库
cd zabbix-2.4.7/database/mysql
ls 查看 存在 data.sql , images.sql , schema.sql 3个脚本文件
mysql -uzabbix -pzabbix 登录 mysql 执行
mysql> source schema.sql;
mysql> source images.sql;
mysql> source data.sql;
e. 设置zabbix为启动服务
cd zabbix/zabbix-2.4.7/misc/init.d/tru64
[root@mysqlmaster tru64]# cp zabbix_agentd /etc/init.d/
[root@mysqlmaster tru64]# cp zabbix_server /etc/init.d/
[root@mysqlmaster tru64]# chmod +x /etc/init.d/zabbix_*
添加服务:
[root@mysqlmaster init.d]# export LANG=zh_cn.GB2312
[root@mysqlmaster init.d]# chkconfig --add zabbix_agentd
service zabbix_agentd does not support chkconfig
报不支持把如下两行添加到zabbix_server和zabbix_agentd中
#chkconfig: 35 95 95
#description:zabbix Agent server
[root@mysqlmaster init.d]# chkconfig --add zabbix_server
[root@mysqlmaster init.d]# chkconfig --add zabbix_agentd
[root@mysqlmaster init.d]# chkconfig zabbix_server on
[root@mysqlmaster init.d]# chkconfig zabbix_agentd on
f. 修改配置文件
/usr/local/etc
[root@zabbix etc]# vi zabbix_server.conf #服务端的配置
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@zabbix etc]# vi zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
g. 安装zabbix web页面
启动zabbix:/etc/init.d/zabbix_server start
复制php文件将frontends/php下面的php文件拷贝到web服务器html文件目录下面
[root@mysqlmaster zabbix-2.4.7]# cp -r frontends/php /var/www/html/zabbix
启动 apache 服务 : /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100 for ServerName
在浏览器中打开web界面 : http://192.168.1.100/zabbix/php/setup.php
h. 配置web页面
修改/etc/php.ini配置文件
post_max_size =16M
max_execution_time =300
max_input_time =300
date.timezone = Asia/Shanghai
post_max_size = 32M
重启apache
[root@mysqlmaster etc]# /etc/init.d/httpd restart
还是报错Php bcmath fail
Php bcmath fail是因为包没有安装
安装php-bcmath包
[root@mysqlmaster etc]# yum install php-bcmath*
重启apache点击retry通过
[root@mysqlmaster etc]# /etc/init.d/httpd restart
j. 登录:默认用户名:Admin,密码:zabbix
a. 关闭防火墙
service iptables stop
b. 关闭selinux
setenforce 0 #临时关闭
vim /etc/selinux/config #将SELINUX的值修改为disable,永久关闭
2. 安装 mysql
a. 下载 mysql 安装文件:mysql-5.6.37-linux-glibc2.12-x86_64.tar
b. 解压 tar zxvf mysql-5.6.37-linux-glibc2.12-x86_64.tar
c. 复制解压后的文件
cp -r mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql
d. 添加用户组和用户
groupadd mysql
useradd -g mysql mysql
e. 安装
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
f. 修改启动项,配置环境变量
vi /etc/init.d/mysqld
修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
环境变量:
vi /etc/profile
添加:export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile
g. 启动服务测试连接
启动:service mysqld start
测试:./mysql/bin/mysql -uroot
查看运行状态:service mysqld status
关闭:service mysqld stop
3. 安装 mysql 常见错误
a. sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
use mysql;
select 'host' from user where user='root';
delete from user where root=" ";
update user set host = '%' where user ='root';
flush privileges;
b. 安装时遇到:-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
c. error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel
d. MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
解决: ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
报错:ln: creating symbolic link `/data/mysqldata/mysql.sock' to `/tmp/mysql.sock': File exists
rm mysql.sock #上面提示文件存在,所以删除之前的mysql.sock文件
ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
e. Access denied for user 'root'@'localhost' (using password:YES)
解决:在 my.cnf 文件中最后 skip-grant-tables 保存并关闭文件,重启mysql;
输入“mysql -u root -p”(不输入密码),回车即可进入数据库,执行:update user set password=PASSWORD("yourPassword") where user='root';
打开my.chf 删除刚刚添加的 skip-grant-tables 保存退出,重启 mysql 即可。
4. 安装 zabbix
a. 添加用户组和用户
groupadd zabbix
useradd -g zabbix zabbix
b. 创建数据库和用户
mysql> CREATE DATABASE zabbix CHARACTER SET utf8;
mysql> show databases;
mysql> GRANT ALL on zabbix.* TO zabbix@'%' IDENTIFIED BY 'zabbix';
c. 下载 zabbix 安装包:zabbix-2.4.6.tar.gz
解压:tar zxvf zabbix-2.4.6.tar.gz
安装LAMP环境:
yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear
(由于mysql数据库上面已经安装了,这个可以不安装mysql了mysql mysql-server mysql-devel)
安装zabbix所需的组件(server,agent)
yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
编译安装,如果是客户端安装选择--enable-agent就行了。
./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
报错:configure: error: in `/home/zabbix/zabbix-2.4.7':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
解决:执行:yum install gcc
继续 ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
成功,执行 make install
d. 初始化 zabbix 数据库
cd zabbix-2.4.7/database/mysql
ls 查看 存在 data.sql , images.sql , schema.sql 3个脚本文件
mysql -uzabbix -pzabbix 登录 mysql 执行
mysql> source schema.sql;
mysql> source images.sql;
mysql> source data.sql;
e. 设置zabbix为启动服务
cd zabbix/zabbix-2.4.7/misc/init.d/tru64
[root@mysqlmaster tru64]# cp zabbix_agentd /etc/init.d/
[root@mysqlmaster tru64]# cp zabbix_server /etc/init.d/
[root@mysqlmaster tru64]# chmod +x /etc/init.d/zabbix_*
添加服务:
[root@mysqlmaster init.d]# export LANG=zh_cn.GB2312
[root@mysqlmaster init.d]# chkconfig --add zabbix_agentd
service zabbix_agentd does not support chkconfig
报不支持把如下两行添加到zabbix_server和zabbix_agentd中
#chkconfig: 35 95 95
#description:zabbix Agent server
[root@mysqlmaster init.d]# chkconfig --add zabbix_server
[root@mysqlmaster init.d]# chkconfig --add zabbix_agentd
[root@mysqlmaster init.d]# chkconfig zabbix_server on
[root@mysqlmaster init.d]# chkconfig zabbix_agentd on
f. 修改配置文件
/usr/local/etc
[root@zabbix etc]# vi zabbix_server.conf #服务端的配置
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@zabbix etc]# vi zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
g. 安装zabbix web页面
启动zabbix:/etc/init.d/zabbix_server start
复制php文件将frontends/php下面的php文件拷贝到web服务器html文件目录下面
[root@mysqlmaster zabbix-2.4.7]# cp -r frontends/php /var/www/html/zabbix
启动 apache 服务 : /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100 for ServerName
在浏览器中打开web界面 : http://192.168.1.100/zabbix/php/setup.php
h. 配置web页面
修改/etc/php.ini配置文件
post_max_size =16M
max_execution_time =300
max_input_time =300
date.timezone = Asia/Shanghai
post_max_size = 32M
重启apache
[root@mysqlmaster etc]# /etc/init.d/httpd restart
还是报错Php bcmath fail
Php bcmath fail是因为包没有安装
安装php-bcmath包
[root@mysqlmaster etc]# yum install php-bcmath*
重启apache点击retry通过
[root@mysqlmaster etc]# /etc/init.d/httpd restart
j. 登录:默认用户名:Admin,密码:zabbix