zabbix安装
编译安装Nginx
groupadd -r nginx
useradd -r -g nginx -s /sbin/nologin -M nginx
yum -y install pcre* openssl* zlib zlib-devel wget
yum -y groupinstall "Development Tools"
mkdir /var/tmp/nginx/client/ -pv
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--error-log-path=/usr/local/nginx/logs/error.log \
--http-log-path=/usr/local/nginx/logs/access.log \
--pid-path=/usr/local/nginx/logs/nginx.pid \
--lock-path=/usr/local/nginx/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/usr/local/nginx/client/ \
--http-proxy-temp-path=/usr/local/nginx/proxy/ \
--http-fastcgi-temp-path=/usr/local/nginx/fcgi/ \
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi \
--http-scgi-temp-path=/usr/local/nginx/scgi \
--with-pcre
make && make install
更改nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
/usr/local/nginx/sbin/nginx -s reload # 重新载入配置文件 /usr/local/nginx/sbin/nginx -s reopen # 重启 Nginx /usr/local/nginx/sbin/nginx -s stop # 停止 Nginx
关闭防火墙:
systemctl stop firewalld
systemctl disable firewalld
关闭selinux:
setenforce 0
编译安装Mysql
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin mysql
cd /usr/local/src
tar xzf mysql-5.7.11.tar.gz
tar xzf boost_1_59_0.tar.gz
mkdir -p /data/mysql
mkdir /usr/local/mysql
chown -R mysql.mysql /data/mysql
mv boost_1_59_0 /usr/local/boost
cd mysql-5.7.11
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1
make && make install
拷贝启动服务:
/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
cd /usr/local/mysql
mkdir log pid socket
chown -R mysql.mysql /usr/local/mysql/
多用户配置文件:
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
/app/mysql/bin/mysql_ssl_rsa_setup --datadir=/data/mysql
/etc/init.d/mysqld start
iX%Tf_-2OZHL
update mysql.user set authentication_string=password("123456") where user="root";
grant all privileges on *.* to 'root'@'%' identified by "123456";
flush privileges;
编译安装zabbix
创建zabbix用户帐号
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
创建zabbix数据库,并赋权
# /usr/local/mysql/bin/mysql -uroot -p123456
mysql>create database zabbix character set utf8 collate utf8_bin; 创建zabbix数据库
mysql>grant all on zabbix.* to zabbix@localhost identified by '123456'; 给zabbix用户赋权
mysql>show grants for zabbix@localhost; 查看是否赋权
下载:
cd /usr/local/src
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.18/zabbix-3.0.18.tar.gz
tar -xvf zabbix-3.0.18.tar.gz
安装zabbix
安装相应依赖包:
yum -y install libxml2-devel net-snmp-devel curl-devel
安装java包:
yum -y install jdk-8u101-linux-x64.rpm
编译安装命令:
./configure --prefix=/usr/local/zabbix \
--enable-server \
--enable-agent \
--with-mysql=/usr/local/mysql/bin/mysql_config \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--enable-java \
--enable-proxy
./configure --prefix=/usr/local/zabbix \
--enable-server \
--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--enable-java \
--enable-proxy
错误:
configure: error: MySQL library not found
yum -y install mysql-devel
make安装:
make install
导入zabbix数据库数据
cd /usr/local/src/zabbix-3.0.18/database/mysql
mysql -uzabbix -p123456 zabbix < schema.sql
mysql -uzabbix -p123456 zabbix < images.sql
mysql -uzabbix -p123456 zabbix < data.sql
拷贝启动脚本:
cp /usr/local/src/zabbix-3.0.18/misc/init.d/fedora/core/zabbix_server /etc/init.d/
cp /usr/local/src/zabbix-3.0.18/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
创建日志目录:
mkdir /var/log/zabbix && chown -R zabbix:zabbix /var/log/zabbix
修改配置文件:
vim /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
主配置文件:
[root@localhost etc]# grep "^[a-Z]" /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix.log
DBHost=192.168.83.124
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3307
Timeout=30
LogSlowQueries=3000
安装php依赖:
yum install php-gettext php-session php-ctype php-xmlreader php-xmlwriter php-xml php-net-socket php-gd php-mysql libjpeg-devel libpng libpng-devel freetype-devel libicu-devel openldap openldap-devel