CentOS6离线安装Zabbix4.0
Posted HAOZ未
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6离线安装Zabbix4.0相关的知识,希望对你有一定的参考价值。
“ 上一期完成了本地yum源的配置,接下来就是Zabbix依赖的各个模块的安装以及Zabbix服务的安装操作了。总的来说这几期的文章中不单是Zabbix的安装指导,其中还包含了像yum源的本地仓库配置、Apache、mysql、php服务的安装等等技巧,一文多益呢”
八、安装Apache
1.检查yum源
[ ]
2.安装
[ ]
3.检查安装
[ ]
[ ]
Serverversion: Apache/2.2.15 (Unix)
Serverbuilt: Jun 19 2018 15:45:13
4.安装httpd开发工具包
[ ]
[ ]
/usr/sbin/apxs
"/usr/sbin/apxs"在源码编译安装php的时候会用到
九、安装PHP(Zabbix的web管理界面要求PHP版本5.4.0以上,但是CentOS6.X系统最高5.3.x,所以需要升级PHP版本)
1.安装依赖的库
[root@localhost /]# yum install gcc gcc-c++ php-mcrypt libmcrypt
libmcrypt-devel mhash mhash-devel libevent libevent-devel libjpeg-devel
libpng-devel freetype-devel openssl openssl-devel readline-devel libxml2-devel bzip2-devel curl curl-devel openldap openldap-devel
2.解压源码包
[ ]
3.配置编译环境
[root-5.6.25]# ./configure --prefix=/usr/local/php php
--with-config-file-path=/usr/local/php/etc --enable-inline-optimization
--disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
--with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash
--with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl
--enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets
--with-curl --with-zlib --enable-zip --with-bz2 --with-gd --with-freetype-dir
--with-jpeg-dir --with-png-dir --with-readline --with-ldap
--with-apxs2=/usr/sbin/apxsbuf
我这边安装过程遇到部分报错:
configure:error: mcrypt.h not found. Please reinstall libmcrypt.
解决方案:
[ ]
[ ]
[ ]
[
libmcrypt-2.5.7]
[
libmcrypt-2.5.7]
configure:error: Don't know how to define struct flock on this system, set --enable-opcache=no
分析解决步骤:
[root@localhost php-5.6.25]# cat /etc/ld.so.conf
include
ld.so.conf.d/*.conf
[root@localhost php-5.6.25]# vi /etc/ld.so.conf
include
ld.so.conf.d/*.conf
/usr/local/lib
/usr/local/lib64
[root@localhost php-5.6.25]# ldconfig
configure:
error: Cannot find ldap libraries in /usr/lib.
[root@localhost php-5.6.25]# ll /usr/lib64/libldap*
lrwxrwxrwx.
1 root root 10 Mar 14 19:05 /usr/lib64/libldap-2.4.so.2 -> libldap.so
lrwxrwxrwx.
1 root root 12 Mar 14 19:05 /usr/lib64/libldap_r-2.4.so.2 -> libldap_r.so
lrwxrwxrwx.
1 root root 30 Mar 14 19:05 /usr/lib64/libldap_r.so ->
/lib64/libldap_r-2.4.so.2.10.3
lrwxrwxrwx.
1 root root 28 Mar 14 19:05 /usr/lib64/libldap.so ->
/lib64/libldap-2.4.so.2.10.3
[root@localhost lib64]# cp -frp /usr/lib64/libldap* /usr/lib/
4.编译:make & make install
[ ]
[ ]
[ ]
5.配置PHP服务
php.ini是php运行核心配置文件,php-fpm.conf是php-fpm进程服务的配置文件。
[ ]
[ ]
将php和php-fpm拷贝到/usr/local/bin:
[ ]
[ ]
设置php-fpm开机自动启动,将init.d.php-fpm放在启动里面:
[root@localhost php-5.6.25]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-5.6.25]# chmod +x /etc/init.d/php-fpm
[root@localhost php-5.6.25]# chkconfig --add php-fpm
[root@localhost php-5.6.25]# chkconfig php-fpm on
[root@localhost php-5.6.25]# service php-fpm start
Startingphp-fpm done
[root@localhost php-5.6.25]# ps -ef|grep php
root 30991 1 0 20:53 ? 00:00:00 php-fpm: master process(/usr/local/php/etc/php-fpm.conf)
nobody 30992 30991 0 20:53 ? 00:00:00 php-fpm:pool www
nobody 30993 30991 0 20:53 ? 00:00:00 php-fpm:pool www
root 30995 1256 0 20:53 pts/0 00:00:00 grep php
[root@localhostphp-5.6.25]# netstat -nltp|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 30991/php-fpm
十、关闭防火墙及SELinux
1.查看防火墙状态
[ ]
2.关闭防火墙
[ ]
3.禁止防火墙开机启动
[ ]
4.关闭selinux,将SELINUX=enforcing改为SELINUX=disabled
[root@localhost ~]# vi /etc/selinux/config
# Thisfile controls the state of SELinux on the system.
#SELINUX= can take one of these three values:
# enforcing - SELinux security policy isenforced.
# permissive - SELinux prints warningsinstead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
#SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes areprotected,
# minimum - Modification of targeted policy.Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
5.把selinux禁用掉
[ ]
十一、配置Apache+PHP
cp/etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak.bak
修改默认端口
[root@localhost conf]# sed -i 's/^Listen 80/Listen 9018/g' /etc/httpd/conf/httpd.conf
修改ServerName为当前IP,例如
[root@localhost conf]# sed -i 's/^#ServerName www.example.com:80/ServerName192.168.1.120:9018/g' /etc/httpd/conf/httpd.conf
添加支持类型
vi /etc/httpd/conf/httpd.conf
AddType application/x-httpd-php .php
启动apache,开机自启
[ ]
[ ]
[ ]
验证apache:
[ ]
验证php:
[root@localhost html]# cd /var/www/html
[root@localhost html]# vi a.php
<?php
echo"Hello World!";
[root@localhost html]# vi phpinfo.php
<?php
phpinfo();
通过浏览器访问测试:
http://192.168.1.120:9018/phpinfo.php
十二、MySQL安装
1.检查yum源
[root@localhost ~]#yum list |grep mysql-community-server
2.安装
[root@localhost ~]#yum install -y mysql-community-server
3.修改配置:这里主要配置端口号、数据目录、socket、pid-file参数,其他部分参数优化仅供参考
[root@localhost ~]# cp /etc/my.cnf /etc/my.cnf.bak
[root@localhost ~]# mkdir -p /data/mysql
[root@localhost ~]# vi /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
port=3601
socket=/data/mysql/mysql.sock
default-character-set=utf8
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
port=3601
datadir=/data/mysql
socket=/data/mysql/mysql.sock
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
pid-file=/data/mysql/mysql.pid
explicit_defaults_for_timestamp=true #关闭警告[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
skip_name_resolve
log_bin_trust_function_creators = 1
event_scheduler=ON
group_concat_max_len = 200000
lower_case_table_names=1
federated
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 256M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
max_connections = 3000
max_connect_errors = 10000
lower_case_table_names=1
character_set_server = utf8
innodb_buffer_pool_size = 12G
log_slow_admin_statements=1 #记录那些慢的optimize table,analyze table和alter table语句
log_slow_slave_statements=1 #记录由Slave所产生的慢查询
slow_launch_time=5
long_query_time=5
slow_query_log=1 #慢查询开关,用于优化查询语句
slow_query_log_file=/var/log/mysql.slow.log
log-queries-not-using-indexes
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
pid-file=/data/mysql/mysql.pid
4.启动
[root@localhost ~]# service mysqld start
5.设置开机自启
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig mysqld on
6.登陆,首次登陆密码为空,直接回车即可
[root@localhost ~]#mysql -uroot -p
Enter password:
7.设置root密码
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
mysql>SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('password');
mysql>use mysql;
mysql>select user,host,password from user;
+------+-----------------------+-------------------------------------------+
|user | host |password |
+------+-----------------------+-------------------------------------------+
|root | localhost |*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
|root | localhost.localdomain | |
|root | 127.0.0.1 |*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
|root | ::1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+-------------------------------------------+
6rows in set (0.00 sec)
8.添加局域网访问
mysql>update user set host = '%' where user = 'root' and host = 'localhost';
Query OK,1 row affected (0.00 sec)
Rowsmatched: 1 Changed: 1 Warnings: 0
mysql>flush privileges;
Query OK,0 rows affected (0.00 sec)
9.再将localhost的访问添加回来
mysql> INSERTINTO `mysql`.`user`(`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`,`Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`,`Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`,`Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`,`Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`,`Repl_client_priv`, `Create_view_priv`, `Show_view_priv`,`Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`,`Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`,`x509_issuer`, `x509_subject`, `max_questions`, `max_updates`,`max_connections`, `max_user_connections`, `plugin`, `authentication_string`,`password_expired`) select 'localhost', `User`, `Password`, `Select_priv`,`Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`,`Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`,`References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`,`Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`,`Repl_client_priv`, `Create_view_priv`, `Show_view_priv`,`Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`,`Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`,`x509_issuer`, `x509_subject`, `max_questions`, `max_updates`,`max_connections`, `max_user_connections`, `plugin`, `authentication_string`,`password_expired` from `mysql`.`user` where user = 'root' and host = '%';
Query OK, 1 rowaffected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> flushprivileges;
10.查看端口号
mysql> showglobal variables like 'port';
11.重启
[root@localhost ~]#service mysqld restart
12.软连接mysql.sock,Zabbix web服务使用的是/var/lib/mysql目录下的sock文件连接的。
[root@localhost ~]#cd /var/lib/mysql
[root@localhost mysql]# ln -sf /data/mysql/mysql.sock mysql.sock
13.修改php配置,指定mysql端口,sock文件
[root@localhost ~]#vi /usr/local/php/etc/php.ini
mysqli.default_port= 3601
mysqli.default_socket= /var/lib/mysql/mysql.sock
[root@localhost ~]#/etc/init.d/php-fpm restart
[root@localhost ~]#service httpd restart
看来两期是搞不定了,莫慌,下期就开始安装Zabbix Server啦!
觉得本文有帮助?请分享给更多的人
在看是不是在这个位置
以上是关于CentOS6离线安装Zabbix4.0的主要内容,如果未能解决你的问题,请参考以下文章