Centos6安装Zabbix3.4

 一、关闭SELinux


查询是否开启了SELinux      

getenforce

SELinux一共有3种状态,分别是**Enforcing,Permissive**和**Disabled**状态。第一种是默认状态,表示强制启用,第二种是宽容的意思,即大部分规则都放行。第三种是禁用,即不设置任何规则

setenforce 0                   #把SELinux关闭,此操作为临时关闭,重启后失效

   vim /etc/selnux/conf              #修改为disabled,此操作为永久关闭,重启后生效。

    #This file controls the state of SELinux on the system.
#SELINUX= can take one of these three values:
#enforcing - SELinux security policy is enforced.
#permissive - SELinux prints warnings instead of enforcing.
#disabled - No SELinux policy is loaded.
SELINUX=disabled   #disabled为关闭
#SELINUXTYPE= can take one of three two values:
#targeted - Targeted processes are protected,
#minimum - Modification of targeted policy. Only selected processes are protected. 
#mls - Multi Level Security protection.
SELINUXTYPE=targeted

 二、关闭或防火墙或开放必需端口


关闭防火墙

service iptables stop      #关闭防火墙
chkconfig iptables off #关闭开机自启
service iptables status#查看防火墙状态

或者开放防火墙端口

vim /etc/sysconfig/iptables
# 加入如下代码,比着两葫芦画瓢 :)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#保存后重启防火墙,开启其他端口亦是如此。
service iptables restart

三、查看本机信息,安装编辑器,升级系统


                查看本机IP地址:ifconfig

查看系统版本 :cat /etc/issue 

查看系统版本位数 :getconf LONG_BIT

查看CPU是几核的 :cat /proc/cpuinfo |grep "cores"|uniq

查看有几颗逻辑CPU : cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c  

查看系统容量多少 :df -h

查看PHP版本  :php -v

查看端口 :ss -tnul


     安装vim编辑器以及升级系统补丁

yum install -y vim
yum  update

步骤


1.    由于Centos6自带的MySQL版本过低,需要安装更新MySQL,所以先卸载。

yum remove mysql*

2.    安装MySQL、Zabbix、PHP的yum源

rpm -ivhhttp://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm     
rpm -ivhhttp://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
rpm -ivhhttp://repo.webtatic.com/yum/el6/latest.rpm

3.    yum安装MySQL、Zabbix、PHP

yum install mysql-community-server
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
yum install httpd php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap

4.    编辑MySQL的配置文件并添加以下内容   #vim /etc/my.conf

[mysqld]
innodb_file_per_table=1

5.    编辑php的ini文件(vim /etc/php.ini)并修改一下内容,注意date.timezone一定要写对,否则在配置完zabbix后,显示的界面全部报错 

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1

6.    修改httpd的默认路径,修改为zabbix的路径,以便于输入IP直接访问zabbix。

#配置/etc/httpd/conf/httpd.conf,找到DocumenRoot以及Directory,修改路径为/usr/share/zabbix

DocumentRoot "/usr/share/zabbix"
<Directory "/usr/share/zabbix">

7.    初始化MySQL数据库

mysql_secure_installation 
mysql -uroot -p				-u为账号名,这里是root,-p是密码
...
mysql>  create database zabbix character set utf8 collate utf8_bin;
	Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
	Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
	Query OK, 0 rows affected (0.01 sec)

8.    导入默认的Zabbix数据库信息,由于版本不一样,所以路径会不一样。

zcat /usr/share/doc/zabbix-server-mysql-3.4.12/create.sql.gz | mysql zabbix -uroot -p


9.    修改Zabbix_server.conf的配置文件

找到如下行,DBuser为创建数据库时的账号

    DBpassword为数据库的密码

    DBhost为本机IP或localhost或127.0.0.1

    DBname为zabbix

vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

10.    启动各项服务,并设置为开机自启。

service httpd start
service zabbix-server start
service zabbix-agent start
service mysqld start
chkconfig httpd on
chkconfig mysqld on
chkconfig zabbix-agent on
chkconfig zabbix-server on

打开浏览器,输入zabbix服务器IP即可。

Zabbix默认管理员账号为Admin,默认密码为zabbix

登陆成功后尽快修改Admin的密码,并禁用访客访问。

移除setup.php文件

mv /usr/share/zabbix/setup.php /usr/share/zabbix/setup.php.bak


猜你喜欢

转载自blog.51cto.com/xyhms/2162137