zabbix的安裝監控windows,linux操作流程

CentOS默認源裏沒有nginx軟件 :wget http://www.atomicorp.com/installers/atomic

sh ./atomic #安裝YUM源

yum check-update #更新yum軟件包

一、安裝nginx

yum install nginx

service nginx start

chkconfig nginx on

二、安裝mysql

yum install mysql mysql-server mysql-devel

service mysqld start

chkconfig mysqld on

三、安裝php

#安裝PHP及組件,使PHP支持 MySQL、PHP支持FastCGI模式

yum install php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring

php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap php-odbc php-bcmath php-xmlrpc php-fpm

service mysqld restart

service nginx restart

service php-fpm start

四、配置nginx支持php

vi /etc/nginx/nginx.conf  #修改運行用戶

user nginx;

vi /etc/nginx/conf.d/default.conf #開啓php支持

index index.php index.html index.htm;

location ~ \.php$ {

root html; #取消FastCGI server部分location的註釋

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/ $fastcgi_script_name; #$document_root設置爲網站根目錄

include fastcgi_params;

}

改成這樣:

location ~ \.php$ {

        root           /usr/share/nginx/html;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  /$document_root$fastcgi_script_name;

        include        fastcgi_params;

    }

並找到 index index.php index.html index.htm; 添加index.php

1、配置php

date.timezone = Asia/Shanghai #設置時區

expose_php = OFF #禁止顯示版本信息

2、配置php-fpm

vi /etc/php-fpm.d/www.conf

user = nginx

group = nginx

3、測試

chown -R nginx.nginx /usr/share/nginx/html/ #設置目錄所有者

chmod 774 -R /usr/share/nginx/html/ #設置目錄權限

service mysqld restart

service nginx restart

service php-fpm restart

cd /usr/share/nginx/html/

vi index.php

<?Php phpinfo();?>

http://127.0.0.1 #可以看到相關的配置信息!

編輯安裝zabbix

1、修改php.ini,以達到zabbixserver的要求

# vim  /etc/php.ini

date.timezone = Asia/Shanghai

max_input_time = 300

post_max_size = 32M

max_execution_time = 300

memory_limit = 128M

mbstring.func_overload = 2

2、創建zabbix用戶

3、創建zabbix庫,並且給庫創建用戶設置密碼。

set password =password('你的密碼');

grant all on zabbix.* to zabbix@localhost identified by 'zabbix';

flush privileges;

4、編譯zabbix(確定安裝mysql mysql-devel mysql-server) (需要安裝依賴庫yum -y install net-snmp-devel curl-devel)

./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl

5、在/etc/services中添加

zabbix-agent    10050/tcp               # Zabbix Agent

zabbix-agent    10050/udp               # Zabbix Agent

zabbix-server   10051/tcp               # zabbix Trapper

zabbix-server   10051/udp               # zabbix Trapper

6、導入數據庫並授權

ls database/mysql/

data.sql  images.sql  schema.sql

mysql -uzabbix -pzabbix zabbix < schema.sql

mysql -uzabbix -pzabbix zabbix < images.sql

mysql -uzabbix -pzabbix zabbix < data.sql

7、創建相關的目錄和連接

# mkdir /var/log/zabbix

# chown zabbix.zabbix /var/log/zabbix

# ln -s /usr/local/zabbix/etc/ /etc/zabbix

# ln -s /usr/local/zabbix/bin/* /usr/bin/

# ln -s /usr/local/zabbix/sbin/* /usr/sbin/

8、把zabbix server加入到系統服務

# cp zabbix-2.4.2/misc/init.d/fedora/core/zabbix_* /etc/init.d

# vim /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix

# vim /etc/init.d/zabbix_agentd

BASEDIR=/usr/local/zabbix

9、修改配置文件

# vim /etc/zabbix/etc/zabbix_server.conf

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

LogFile=/var/log/zabbix/zabbix_server.log ----自己搜索後再確定


10、設置zabbix監控自己

# vim /etc/zabbix/etc/zabbix_agentd.conf

LogFile=/var/log/zabbix/zabbix_agentd.log

Server=127.0.0.1,x.x.x.x    被動模式 

ServerActive=x.x.x.x:10051   主動模式

Hostname=主機名

UnsafeUserParameters=1

11、拷貝網頁文件到nginx網站目錄

# cp -r zabbix-2.4.2/frontends/php/ /www

# chown -R nginx.nginx /www

12、啓動zabbix_server和zabbix_agentd並設置開機自啓動

# service zabbix_server start

# chkconfig zabbix_server on

# service zabbix_agentd start

# chkconfig zabbix_agentd on

另外一種啓動方式:

/usr/local/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agent.conf /usr/local/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf

監控windows主機

直接解壓放置到C:\磁盤目錄中

安裝啓動:

zabbix_agent.exe的路徑 -c  zabbix_agentd.win.conf -i 安裝

zabbix_agent.exe的路徑 -c  zabbix_agentd.win.conf -s 啓動 -d 卸載


監控linux服務器:

    關閉selinux

groupadd zabbix -g 201

    useradd -g zabbix -u 201 -m zabbix

    ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix --enable-agent

修改/etc/zabbix/zabbix_agentd.conf文件

zabbix_agent.conf是用超級服務(xinetd)的方式來啓動的,

zabbix_agentd.conf是以獨立進程的方式來啓動的.

註釋:

server是被動模式,不要127也行,

serverActive是主動模式

啓動:

/usr/local/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agent.conf

添加:

    在server端可以用命令:/usr/local/zabbix/bin/zabbix_get -s 192.168.5.138 -p 10050 -k system.uname進行測試zabbix是否能獲取服務端上的數據。

如果打開了防火牆防火牆需要打開的端口:

    agent 客戶端打開:10050 

    server 打開:10050 10051 3306 80 9000

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章