设为首页 收藏本站
查看: 930|回复: 0

[经验分享] Zabbix 3.0 Beta on CentOS 6

[复制链接]

尚未签到

发表于 2019-1-20 13:29:11 | 显示全部楼层 |阅读模式
How to Install Zabbix 3.0 Beta on CentOS 6
  Posted on January 26, 2016 by Ingus
DSC0000.jpg

  The long awaited Zabbix 3.0 beta 1 is here. Now we are eager to see what it brings us therefore there is no better way to find that out than installing it and trying on our systems.
  In this tutorial we will be installing it on a blank CentOS 6.7 operating system. Check out our previous post How to Install CentOS 6 for Zabbix if you’d like to start with a short tutorial how to install CentOS itself.
  But now let’s get started with the actual installation of Zabbix 3.0 beta 1. First we will prepare database, then web server and once that is done we will install Zabbix server, agent and web interface.
Prepare database
  Before we even start with Zabbix we need to install a database for it. And here we will use the latest version of MySQL.
  CentOS by default is supplied with a very old version of MySQL – 5.1. We can check that by running:
yum list installed | grep mysqlExpected output:
mysql-libs.x86_64    5.1.73-5.el6_6     @anaconda-CentOS-201508042137.x86_64/6.7Although a basic installation of Zabbix can run on MySQL 5.1, it is highly recommended to use a more up-to-date version, which is 5.6 currently. Therefore we have to remove the old version first.
Please be aware of what you are doing. Never do this on a production system where existing MySQL instances might be running!
yum remove mysql*Then we need to install the MySQL repository configuration package. We pick the right version for our CentOS 6 system from here: http://dev.mysql.com/downloads/repo/yum/
Install the repository.
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpmRetrieving http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm  
Preparing...                ########################################### [100%]
  
   1:mysql-community-release########################################### [100%]
Install the MySQL server itself.
yum install mysql-serverIf everything is correct then one of the outputs should install mysql-community-server along with 10 other dependencies. Double check that you are going to install MySQL version 5.6.x.
Installing:  
mysql-community-server  x86_64   5.6.26-2.el6  mysql56-community      53 M
Read all questions you might be asked during the install but most likely you need to answer “yes” by pressing “y” key.
Before starting up the database we have to edit the MySQL configuration file but to open a file we need some text editor. Here you can use whichever you want, but in the tutorial we will be using vim, so here is how to install it.
yum install vim -yOpen the MySQL configuration file with “vim” file editor. If you are new to vim then hereis a quick tutorial on that.
vim /etc/my.cnfThis file consists of multiple sections. At this point we will not do much tuning and only add one setting under the [mysqld] section, which is important prior to creation of any database.
[mysqld]  
innodb_file_per_table
Save and close the file.
Start the MySQL service.
service mysqld startStarting mysqld:                 [  OK  ]It is highly recommended to secure your database and specify a password for the “root” account, remove anonymous logins etc. It is done by following all instructions after the MySQL secure installation.
mysql_secure_installationEnter current password for root (enter for none):  

  
Set root password? [Y/n]
  

  
Remove anonymous users? [Y/n]
  

  
Disallow root login remotely? [Y/n]
  

  
Remove test database and access to it? [Y/n]
  

  
Reload privilege tables now? [Y/n]
Normally you should answer “Yes” to all these questions.
Log in to your MySQL instance with the password set in the previous step.
mysql -u root -pCreate a new database for Zabbix. It is very important to also specify the character set and collation otherwise the database will be case insensitive.
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;Create a database user, set password and grant privileges.
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'your_password';Just to be sure check that the database is created.
mysql> show databases;  
+--------------------+
  
| Database           |
  
+--------------------+
  
| information_schema |
  
| mysql              |
  
| performance_schema |
  
| zabbix             |
  
+--------------------+
  
4 rows in set (0.00 sec)
If everything is fine then exit the database for now.
exitPrepare web server
Beside a database we also need a web server therefore we will install Apache and PHP.
Zabbix 3.0 requires PHP to be at least version 5.4 or higher. Our CentOS 6.7 repositories come with PHP 5.3.3 therefore we need to install a newer one.
To do this we need a repository that contains all our required packages. Webtatic could be a good choice therefore we will install it.
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpmNow let’s install the required packages.
yum install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldapTo run Zabbix some PHP options need to be modified as well.
vim /etc/php.inipost_max_size=16M  
max_execution_time=300
  
max_input_time=300
  
date.timezone=Europe/Riga
  
always_populate_raw_post_data=-1
Start the webserver.
service httpd start  Currently we will not be able to connect to our webserver because of internal firewall rules therefore we need to enable port 80 on iptables.
iptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPTSave the firewall rule.
iptables-save > /etc/sysconfig/iptablesNow we can open our local web browser and enter the IP address of your Zabbix server. The Apache landing page should appear.
If you have forgotten the IP address of your Zabbix server then have a look at the IP configuration.
ip a DSC0001.jpg
Download and install Zabbix 3.0
Now we are getting closer to Zabbix itself.
  Before installing Zabbix we need to ensure we have a user group and user account for it because Zabbix is not meant to be run under the “root” account.
groupadd zabbix  
useradd -g zabbix zabbix
Create a directory where downloaded source files will be stored.
mkdir /home/zabbix/downloadsMove to the newly created directory.
cd /home/zabbix/downloadsInstall “wget” to download files from the internet.
yum install wget -yGo to the Zabbix website http://www.zabbix.com/download.php and download the source archives for the latest Zabbix 3.0.0beta1.
It is recommended that you do it from your command line directly.
wget "http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Development/3.0.0beta1/zabbix-3.0.0beta1.tar.gz"Extract the downloaded archive.
tar -zxvf zabbix-3.0.0beta1.tar.gzGo to the directory where Zabbix database schema for MySQL is stored.
cd /home/zabbix/downloads/zabbix-3.0.0beta1/database/mysqlImport the database schema. Provide the password you set when creating the Zabbix user for database.
mysql -u zabbix -p zabbix < schema.sql!! Don’t import the next two files in case you are preparing a database for Zabbix proxy.
Do the same for images and data as well. Note that it is important in what order you import the schema files therefore always start with schema then images and then data.
mysql -u zabbix -p zabbix < images.sql  
mysql -u zabbix -p zabbix < data.sql
When the database is prepared, we will have to compile Zabbix from sources. During this process some additional packages are required therefore we will install them first. It is not a big problem if we don’t but then we will end up with errors during the install.
yum install gcc mysql-community-devel libxml2-devel  unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-develWhen done, go up two folders.
cd ../..If required, read more on how to configure installation.
./configure --helpConfigure all components required for Zabbix.
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-opensslAfter successful compilation we are ready to install everything.
***********************************************************  
*            Now run 'make install'                       *
  
*                                                         *
  
*            Thank you for using Zabbix!                  *
  
*                                  *
To do so just run the following command.
make installBefore starting Zabbix server we need to modify its configuration file in order to connect to the database.
vim /usr/local/etc/zabbix_server.confReplace the values with the actual ones you used during the database setup.
DBName=zabbix  
DBUser=zabbix
  
DBPassword=your_password
Create a new directory for web frontend files.
mkdir /var/www/html/zabbixMove to the downloaded web interface sources.
cd /home/zabbix/downloads/zabbix-3.0.0beta1/frontends/php/Copy all files to the server web directory.
cp -a . /var/www/html/zabbix/By default CenoOS comes with the SELinux option enabled. While it can be sometimes in your way and difficult to manage, it is recommended to leave it on.
Let’s create a rule to allow our web server to access the frontend files.
chcon -Rv --type=httpd_sys_content_t /var/www/htmlWhile we are still at SELinux, let’s allow also Apache and Zabbix to connect to network.
setsebool -P httpd_can_network_connect=1  
setsebool -P zabbix_can_network=1
Set Apache user as owner of the web interface files.
chown -R apache:apache /var/www/html/zabbixAdd permissions to execute files for Zabbix web interface.
chmod +x /var/www/html/zabbix/conf/Add Zabbix server and Zabbix agent to startup scripts.
cp /home/zabbix/downloads/zabbix-3.0.0beta1/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server  

  
cp /home/zabbix/downloads/zabbix-3.0.0beta1/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
Add Zabbix server and Zabbix agent as services.
chkconfig --add /etc/init.d/zabbix_server  
chkconfig --add /etc/init.d/zabbix_agentd
Enable Zabbix server, Zabbix agent, Apache and MySQL services on boot.
chkconfig httpd on  
chkconfig mysqld on
  
chkconfig zabbix_server on
  
chkconfig zabbix_agentd on
Start Zabbix server.
service zabbix_server startStart Zabbix agent.
service zabbix_agentd startFinally it is time to proceed to the frontend installation in your web browser.
Use the same address you have for your server now and add /zabbix to the URL.
DSC0002.jpg
Check for pre-requisites and fix errors if you have any.
DSC0003.jpg
Enter settings to connect to database.
DSC0004.jpg
Enter details to connect to web interface.
DSC0005.jpg
The “Name” field can be left blank or you can enter a name that will appear on each page.
Review the last settings in the next page and if all is good your Zabbix should be able to automatically create configuration files.
DSC0006.jpg
Connect to the Zabbix web interface with default credentials.
Username: AdminPassword: zabbix DSC0007.jpg
And this is the new web interface.
DSC0008.jpg
Congratulations! You have installed the new Zabbix 3.0. Have fun! Don’t forget to check our documentation for 3.0. And stay tuned for next tutorials and articles where we will cover the main features of Zabbix 3.0 and do lots of useful configuration.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-665628-1-1.html 上篇帖子: CentOS上配置Zabbix-10319031 下篇帖子: Zabbix的snmp监控一些snmp常用的一些OID (KEY)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表