zabbix4.4.4 source compiler installation

zabbix4.4.4 source compiler installation

mysql 8.0.17 for binary packages

php72 yum install source

nginx 1.16.1 yum source installation

0. basic environment

zabbix_server 172.16.1.71
zabbix_agent 172.16.1.51

1. Install MySQL 8.0.17

(1) Installation dependencies
yum install bison-devel ncurses-devel libaio-devel
(2) download binary packages
wget -c https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
(3) extracting and move to the installation directory
tar -xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/mysql
(4) Create a directory and database initialization mysql user, and to authorize the root MySQL
mkdir /usr/local/mysql/data
useradd -s /sbin/login -M mysql
chown mysql.mysql /usr/local/mysql -R
(5) flexible connection to mysql library file system library
ln -s /usr/local/mysql/lib/* /usr/lib/
sudo ldconfig
(6) editing MySQL configuration file
echo '
[mysqld]
port=3306
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/mysql-err.log
user=mysql
default_authentication_plugin=mysql_native_password
socket=/usr/local/mysql/data/mysql.sock

[client]
socket=/usr/local/mysql/data/mysql.sock

[mysql]
socket=/usr/local/mysql/data/mysql.sock
' > /etc/my.cnf
(7) to initialize the database, unsafe initialization, you can not generate initialization code
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
(8) to initialize the MySQL database software library directory library connected to the system default directory
ln -s /usr/local/mysql/data  /var/lib/mysql
(7) modify environment variables
echo '
export PATH=/usr/local/mysql/bin:$PATH
' > /etc/profile

source /etc/profile
(8) to create a boot file
echo '
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
' > /usr/lib/systemd/system/mysqld.service
(9) to start the service and add boot from the start
systemctl daemon-reload
systemctl start mysqld
systemctl enable mysqld
(10) to create a library zabbix
# MySQL8.0后版本,创建用户并授权命令和MySQL5.7之前的版本有所不同,需要先创建用户再授权;
create database zabbix character set=utf8;

create user 'zabbix'@'localhost' identified by '123456';

grant all privileges on zabbix.* to 'zabbix'@'localhost' with grant option;

flush privileges;  

2. Install php7.2

(1) installation source
yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
(2) dependent libraries installed php and php files
yum -y install php72w \
php72w-cli \
php72w-fpm \
php72w-common \
php72w-devel \
php72w-embedded \
php72w-gd \
php72w-mbstring \
php72w-opcache \
php72w-pdo  \
php72w-xml  \
php72w-mysqlnd  \
php72w-pecl-memcached \
php72w-pecl-mongodb   \
php72w-pecl-redis     \
php72w-pecl-zip       \
php72w-bcmath \
php72w-ladp \
php72w-mysqli
(3) modify the php configuration file
sed -i '/post_max_size/s/8/16/g' /etc/php.ini
sed -i '/max_execution_time/s/30/300/g' /etc/php.ini
sed -i '/max_input_time/s/60/300/g' /etc/php.ini
sed -i '/date.timezone/a date.timezone=PRC' /etc/php.ini
# 指定MySQL的sock文件,经过测试必须是系统默认库文件目录才可以;所以安装MySQL时做了软连接
sed -i '/mysqli.default_socket/cmysqli.default_socket = /var/lib/mysql/mysql.sock' /etc/php.ini

sed -i '/always_populate_raw_post_data/a always_populate_raw_post_data=-1' /etc/php.ini
(4) to start the service, add the boot from Kai
systemctl start php-fpm
systemctl enable php-fpm

3. Install Nginx / 1.16.1

(1) Configuration source yum
echo '
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
' > /etc/yum.repos.d/nginx.repo
(2) install and modify users start
yum -y install nginx

# php的默认启动用户apache,经过测试nginx最好也使用apache用户,所以在此处修改
sed -i '/user nginx/cuser apache' /etc/nginx/nginx.conf
(3) create a virtual host configuration file zabbix
echo 'server {
        listen 80;
        server_name localhost;
        root /usr/share/nginx/html;
        location / {
             index   index.php setup.php;
        }
        location ~ \.php    {
             fastcgi_pass    127.0.0.1:9000;
             fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include         fastcgi_params;
        }
} ' > /etc/nginx/conf.d/zabbix.conf
(4) Start nginx and add the boot from Kai
systemctl start nginx
systemctl enable nginx

4. Installation source server zabbix4.4.4

(1) mounted reliance
yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI libven-devel
(2) Download Source
cd /root
wget -c https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz
(3) extracting and mounting precompiled
tar -xzvf zabbix-4.4.4.tar.gz
cd zabbix-4.4.4
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config  --with-net-snmp --with-libcurl
make && make install
(4) soft connection zabbix boot file to the system default startup file directory
ln -s /usr/local/zabbix/sbin/* /usr/sbin/
(5) copies zabbix server environment file to the default directory
cp /root/zabbix-4.4.4/misc/init.d/gentoo/zabbix-server /etc/sysconfig/
Source distal end (6) to copy zabbix nginx site directory, authorization and
\cp -r /root/zabbix-4.4.4/frontends/php/* /usr/share/nginx/html/
chown apache.apache /usr/share/nginx/html -R
(7) The zabbix database files into the database
mysql -uzabbix -p123456 zabbix < /root/zabbix-4.4.4/database/mysql/schema.sql 
mysql -uzabbix -p123456 zabbix < /root/zabbix-4.4.4/database/mysql/images.sql 
mysql -uzabbix -p123456 zabbix < /root/zabbix-4.4.4/database/mysql/data.sql 
(8) Configure the server configuration file zabbix
echo '
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
' > /usr/local/zabbix/etc/zabbix_server.conf
(9) the server startup files created zabbix
echo '
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=mysql.service
After=mysqld.service
After=mariadb.service
After=postgresql.service

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0

[Install]
WantedBy=multi-user.target
' > /usr/lib/systemd/system/zabbix.service
(10) to start the user to create, start the service and add boot from the start
useradd -M -s /sbin/nologin zabbix
systemctl daemon-reload
systemctl start zabbix.service
systemctl enable zabbix.service

The client source installation zabbix4.4.4

(1) mounted reliance
yum -y install epel-release pcre-devel
(2) Download Source Package
cd /root
wget -c https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz
(3) compile and install unzip
tar -xzvf zabbix-4.4.4.tar.gz
cd zabbix-4.4.4
./configure  --prefix=/usr/local/zabbix  --enable-agent
make
make install
(4) soft connection zabbix client boot file to the system default startup directory
ln  -s  /usr/local/zabbix/sbin/zabbix_*  /usr/sbin/
(5) copies zabbix client environment file to the default directory
cp /root/zabbix-4.4.4/misc/init.d/debian/zabbix-agent /etc/sysconfig/
(6) editing zabbix client profile
echo '
PidFile=/tmp/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log
LogFileSize=0
Server=172.16.1.71
ServerActive=172.16.1.71
Hostname=Zabbix server
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
' >  /usr/local/zabbix/etc/zabbix_agentd.conf
(7) to create a client boot files zabbix
echo '
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix

[Install]
WantedBy=multi-user.target
' > /usr/lib/systemd/system/zabbix_agnet.service
(8) to create a startup user, start the service and add boot from the start
useradd -M -s /sbin/nologin zabbix
systemctl daemon-reload
systemctl start zabbix_agent.service
systemctl enable zabbix_agent.service

Guess you like

Origin www.cnblogs.com/IMSCZ/p/12153352.html
Recommended