P07
修改配置文件/etc/selinux/config
[root@chenhao01 ~]# vim /etc/selinux/config # 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 # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection.重启服务器
mysql安装
yum -y remove mariadb-libs-1:5.5.64-1.el7.x86_64 yum -y install autoconf rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm # 查看mysql随机密码 cat /root/.mysql_secret # 连接mysql 修改root密码 SET PASSWORD = PASSWORD('982292'); # 查看mysql配置文件生效顺序 mysql --help | grep -E '*.cnf' # mysql远程连接 mysql -h 192.168.174.131 -P 3306 -u root -p982292 # 授权数据库远程访问 grant all privileges on *.* to 'root'@'%' identified by '982292' WITH GRANT OPTION; flush privileges; service mysql restart创建配置文件/etc/my.cnf 启用数据库远程连接
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 skip-character-set-client-handshake skip-name-resolvemysql目录权限配置
chmod 700 /var/lib/mysql/ -R chown mysql:mysql /var/lib/mysql/ -R service mysql restart访问zabbix-4.2.8/database/mysql/
连接mysql执行建库建表语句
mysql -u root -p mysql> create database zabbix default character set utf8 collate utf8_bin; mysql> use zabbix mysql> source schema.sql; mysql> source data.sql; mysql> source images.sql;安装MySQL相关rpm包
rpm -ivh MySQL-devel-5.6.24-1.el6.x86_64.rpm rpm -ivh MySQL-embedded-5.6.24-1.el6.x86_64.rpm rpm -ivh MySQL-shared-5.6.24-1.el6.x86_64.rpm rpm -ivh MySQL-shared-compat-5.6.24-1.el6.x86_64.rpm安装依赖
sudo yum install -y libcurl libcurl-devel libxml2 libxml2-devel net-snmp-devel libevent-devel pcre-devel gcc-c++进入解压目录zabbix-4.2.8
编译安装
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 make install修改zabbix-server配置文件
vim /usr/local/etc/zabbix_server.conf DBHost=chenhao01 DBName=zabbix DBUser=root DBPassword=XXXXXX修改zabbix-agent配置文件
vim /usr/local/etc/zabbix_agentd.conf Server=hadoop102 #ServerActive=127.0.0.1 #Hostname=Zabbix server编辑zabbix-server文件
vim /etc/init.d/zabbix-server内容如下
#!/bin/sh # # chkconfig: - 85 15 # description: Zabbix server daemon # config: /usr/local/etc/zabbix_server.conf # ### BEGIN INIT INFO # Provides: zabbix # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix server # Description: Zabbix server ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -x /usr/local/sbin/zabbix_server ]; then exec=/usr/local/sbin/zabbix_server else exit 5 fi prog=zabbix_server conf=/usr/local/etc/zabbix_server.conf pidfile=/tmp/zabbix_server.pid timeout=10 if [ -f /etc/sysconfig/zabbix-server ]; then . /etc/sysconfig/zabbix-server fi lockfile=/var/lock/subsys/zabbix-server start() { echo -n $"Starting Zabbix server: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix server: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action:" /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esac添加执行权限
chmod +x /etc/init.d/zabbix-server编辑zabbix-agent文件
vim /etc/init.d/zabbix-agent内容如下
#!/bin/sh # #chkconfig: - 86 14 # description: Zabbix agent daemon # processname: zabbix_agentd # config: /usr/local/etc/zabbix_agentd.conf # ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Should-Start: zabbix zabbix-proxy # Should-Stop: zabbix zabbix-proxy # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix agent # Description: Zabbix agent ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -x /usr/local/sbin/zabbix_agentd ]; then exec=/usr/local/sbin/zabbix_agentd else exit 5 fi prog=zabbix_agentd conf=/usr/local/etc/zabbix_agentd.conf pidfile=/tmp/zabbix_agentd.pid timeout=10 if [ -f /etc/sysconfig/zabbix-agent ]; then . /etc/sysconfig/zabbix-agent fi lockfile=/var/lock/subsys/zabbix-agent start() { echo -n $"Starting Zabbix agent: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix agent: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action:" /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esac添加执行权限
chmod +x /etc/init.d/zabbix-agent安装httpd
yum -y install httpd修改httpd配置文件
vim /etc/httpd/conf/httpd.conf 317 <Directory "/var/www/html"> 318 319 # 320 # Possible values for the Options directive are "None", "All", 321 # or any combination of: 322 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 323 # 324 # Note that "MultiViews" must be named *explicitly* --- "Options All" 325 # doesn't give it to you. 326 # 327 # The Options directive is both complicated and important. Please see 328 # http://httpd.apache.org/docs/2.2/mod/core.html#options 329 # for more information. 330 # 331 Options Indexes FollowSymLinks 332 333 # 334 # AllowOverride controls what directives may be placed in .htaccess files. 335 # It can be "All", "None", or any combination of the keywords: 336 # Options FileInfo AuthConfig Limit 337 # 338 AllowOverride None 339 340 # 341 # Controls who can get stuff from this server. 342 # 343 Order allow,deny 344 Allow from all 345 <IfModule mod_php5.c> 346 php_value max_execution_time 300 347 php_value memory_limit 128M 348 php_value post_max_size 16M 349 php_value upload_max_filesize 2M 350 php_value max_input_time 300 351 php_value max_input_vars 10000 352 php_value always_populate_raw_post_data -1 353 php_value date.timezone Asia/Shanghai 354 </IfModule> 355 356 </Directory>拷贝zabbix-web的php文件到httpd的指定目录
mkdir /var/www/html/zabbix cp -a /chenhaosoft/zabbix-4.2.8/frontends/php/* /var/www/html/zabbix/启动
service zabbix-server start开机自启
chkconfig --add zabbix-server chkconfig zabbix-server on启动
service zabbix-agent start开机自启
chkconfig --add zabbix-agent chkconfig zabbix-agent on启动
service httpd start开机自启
chkconfig httpd on上传zabbix安装包,解压,执行编译命令
./configure --enable-agent make install修改zabbix-agent配置文件
vim /usr/local/etc/zabbix_agentd.conf Server=hadoop102 #ServerActive=127.0.0.1 #Hostname=Zabbix server启动
service zabbix-agent start开机自启
chkconfig --add zabbix-agent chkconfig zabbix-agent on