天天看點

centos7.x之yum安裝zabbix

1、安裝LAMP

<code>#關閉防火牆友善測試</code>

<code>yum </code><code>install</code> <code>epel-release -y</code>

<code>systemctl stop firewalld.service</code>

<code>systemctl disable firewalld.service</code>

<code>setenforce 0</code>

<code>#安裝httpd</code>

<code>yum </code><code>install</code> <code>httpd</code>

<code>systemctl start httpd.service </code>

<code>systemctl </code><code>enable</code> <code>httpd.service</code>

<code>#安裝資料庫5.6</code>

<code>wget http:</code><code>//dev</code><code>.mysql.com</code><code>/get/mysql-community-release-el7-5</code><code>.noarch.rpm</code>

<code>rpm -ivh mysql-community-release-el7-5.noarch.rpm</code>

<code>yum </code><code>install</code> <code>mysql-community-server</code>

<code>systemctl restart mysqld.service</code>

<code>#設定msyql密碼為 123456</code>

<code>mysql&gt; </code><code>set</code> <code>password </code><code>for</code> <code>'root'</code><code>@</code><code>'localhost'</code> <code>=password(</code><code>'123456'</code><code>);</code>

<code>#遠端連接配接設定,所有以root賬号連接配接的遠端使用者,設其密碼為 123456</code>

<code>mysql&gt; grant all on xxxx.* to </code><code>'root'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'123456'</code> <code>with grant option;</code>

<code>#更新權限</code>

<code>mysql&gt;flush privileges;</code>

<code>#資料庫開機啟動</code>

<code>systemctl </code><code>enable</code> <code>mysqld.service</code>

<code>#安裝php</code>

<code>yum </code><code>install</code> <code>php -y</code>

<code>#安裝PHP元件,使PHP支援mysql</code>

<code>yum </code><code>install</code> <code>php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash -y</code>

<code>#重新開機對應服務</code>

<code>systemctl restart httpd.service</code>

<code>#以上 安裝 apahce 、mysql 、php  安裝完畢。</code>

<code>檢視安裝環境版本:</code>

<code>cd</code>  <code>/var/www/html</code>  <code>,建立index.php檔案,輸入:</code>

<code>&lt;?php</code>

<code>    </code><code>phpinfo();</code>

<code>?&gt;</code>

2、安裝zabbix

<code>#安裝zabbix server</code>

<code>rpm -ivh http:</code><code>//repo</code><code>.zabbix.com</code><code>/zabbix/3</code><code>.4</code><code>/rhel/7/x86_64/zabbix-release-3</code><code>.4-1.el7.centos.noarch.rpm</code>

<code>#安裝Zabbix server and agent(agent是可選的)</code>

<code>yum </code><code>install</code> <code>zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y</code>

<code>vi</code> <code>/etc/httpd/conf</code><code>.d</code><code>/zabbix</code><code>.conf</code>

<code>更新時區:</code>

<code>php_value </code><code>date</code><code>.timezone Asia</code><code>/Shanghai</code>

<code>#重新開機httpd</code>

<code>systemctl restart httpd</code>

<code>#建立MySQL 資料庫和使用者</code>

<code>mysql –u root –p</code>

<code>mysql&gt; create database zabbix character </code><code>set</code> <code>utf8;</code>

<code>mysql&gt; grant all privileges on zabbix.* to </code><code>'zabbix'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'zabbix'</code><code>;</code>

<code>mysql&gt; flush privileges;</code>

<code>#資料庫導入zabbix template</code>

<code>#-p 後面的zabbix不是密碼,而是選擇zabbix資料庫,導入都是資料表</code>

<code>zcat </code><code>/usr/share/doc/zabbix-server-mysql-3</code><code>.4.0</code><code>/create</code><code>.sql.gz | mysql -uzabbix -p zabbix</code>

<code>#Configure database for Zabbix server/proxy</code>

<code># vi /etc/zabbix/zabbix_server.conf</code>

<code>DBHost=192.168.1.100</code>

<code>DBName=zabbix</code>

<code>DBUser=zabbix</code>

<code>DBPassword=zabbix</code>

<code>#Starting Zabbix server process</code>

<code>systemctl start zabbix-server</code>

<code>systemctl </code><code>enable</code> <code>zabbix-server</code>

<code>#添加selinux設定</code>

<code>setsebool -P httpd_can_connect_zabbix on</code>

<code>setsebool -P httpd_can_network_connect_db on</code>

<code>systemctl start httpd</code>

<code>#修改PHP 設定,後來再搭建多幾次發現這個php設定可以不用更改</code>

<code>vi</code> <code>/etc/php</code><code>.ini</code>

<code>max_execution_time = 600</code>

<code>max_input_time = 600</code>

<code>memory_limit = 256</code>

<code>Mpost_max_size = 32M</code>

<code>upload_max_filesize = 16M</code>

<code>date</code><code>.timezone = Asia</code><code>/Shanghai</code>

<code>#允許Zabbix web console 對特定IP段可用 (可選)</code>

<code>如果設定 ‘Allow from All’, 這可以允許全部可以通路</code>

<code>        </code><code>php_value upload_max_filesize 2M</code>

<code>        </code><code>php_value max_input_time 300</code>

<code>        </code><code>php_value always_populate_raw_post_data -1</code>

<code>        </code><code># php_value date.timezone Europe/Riga</code>

<code>        </code><code>php_value </code><code>date</code><code>.timezone Asia</code><code>/Shanghai</code>

<code>    </code><code>&lt;</code><code>/IfModule</code><code>&gt;</code>

<code>&lt;</code><code>/Directory</code><code>&gt;</code>

<code>&lt;Directory </code><code>"/usr/share/zabbix/conf"</code><code>&gt;</code>

<code>    </code><code>Require all denied</code>

<code>&lt;Directory </code><code>"/usr/share/zabbix/app"</code><code>&gt;</code>

<code>&lt;Directory </code><code>"/usr/share/zabbix/include"</code><code>&gt;</code>

<code>&lt;Directory </code><code>"/usr/share/zabbix/local"</code><code>&gt;</code>

<code>#前端web界面通路配置</code>

<code>http:</code><code>//192</code><code>.168.1.100</code><code>/zabbix/setup</code><code>.php</code>

<code>#zabbix預設賬号和密碼</code>

<code>The default user name is Admin, password zabbix.</code>

<code>#添加zabbix-agent,前面安裝zabbix server的時候,一起yum安裝了,現在隻要修改一下資料即可</code>

<code>vim </code><code>/etc/hosts</code>

<code>添加</code>

<code>192.168.1.100   Zabbix server</code>

<code>service zabbix-agent start</code>

<code>chkconfig zabbix-agent on</code>

<a href="https://s1.51cto.com/wyfs02/M02/03/E6/wKiom1mi7LSB7_ZxAABTpYoJcXo765.png-wh_500x0-wm_3-wmp_4-s_2269190362.png" target="_blank"></a>

<a href="https://s1.51cto.com/wyfs02/M02/A2/97/wKioL1mi7KnzKmpSAAByS9KrRYY731.png-wh_500x0-wm_3-wmp_4-s_2569219284.png" target="_blank"></a>

本文轉自 yanconggod 51CTO部落格,原文連結:http://blog.51cto.com/yanconggod/1959796