In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Preparatory work:
1. Demo environment:
IP
Operating system
Hostnam
Deploy the package
192.168.0.120
CentOS 7.7 x86_64
Zabbix-server
Nginx (nginx-1.16.1.tar.gz)
CMake (cmake-3.15.3.tar.gz)
Boost Library (boost_1_59_0.tar.gz)
MySQL (mysql-5.7.27.tar.gz)
Libzip (libzip-1.5.2.tar.xz)
PHP (php-7.3.9.tar.xz)
JDK (jdk-8u221-linux-x64.tar.gz)
Zabbix (zabbix-4.2.6.tar.gz)
2. Close SELinux and firewalld
3. Configure epel source
4. Configure virtual machine time synchronization
5. Configure hostname
6. Configuration / etc/hosts file:
# vim / etc/hosts-- > 192.168.0.120 zabbix-server
7. Download the required software packages:
(1) Nginx: http://nginx.org/en/download.html
(2) CMake: https://cmake.org/download/
(3) Boost Library: http://www.boost.org/
(4) MySQL: https://dev.mysql.com/downloads/mysql/
(5) Libzip: https://libzip.org/download/
(6) PHP: https://www.php.net/downloads.php
(7) JDK: https://www.oracle.com/technetwork/java/javase/downloads/index.html
(8) Zabbix: https://www.zabbix.com/download/
2. Set up a LNMP environment:
1. Deploy Nginx:
(1) install the development environment: # yum-y groupinstall "Development Tools"
(2) install dependent software packages: # yum-y install pcre-devel zlib-devel openssl-devel libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed geoip-devel
(3) create nginx users and groups:
# groupadd-r nginx
# useradd-g nginx-r-s / sbin/nologin nginx
# id nginx
(4) compile and install Nginx:
# tar-xf nginx-1.16.1.tar.gz-C / usr/src
# cd / usr/src/nginx-1.16.1
# / configure-- prefix=/usr/local/nginx-- user=nginx-- group=nginx-- with-threads-- with-file-aio-- with-http_ssl_module-- with-http_v2_module-- with-http_realip_module-- with-http_addition_module-- with-http_xslt_module-- with-http_image_filter_module-- with-http_geoip_module-- with-http_sub_module-- with-http_dav_module-- with-http _ flv_module-with-http_mp4_module-- with-http_gunzip_module-- with-http_gzip_static_module-- with-http_auth_request_module-- with-http_random_index_module-- with-http_secure_link_module-- with-http_degradation_module-- with-http_slice_module-- with-http_stub_status_module-- with-http_perl_module-- with-mail-- with-mail_ssl_module-- With-stream-with-stream_ssl_module-with-stream_realip_module-with-stream_geoip_module-with-stream_ssl_preread_module-with-compat-with-pcre
# make & & make install
(5) configure Nginx environment variables:
# vim / etc/profile.d/nginx.sh
Export PATH=/usr/local/nginx/sbin:$PATH
#. / etc/profile.d/nginx.sh
# nginx-v
# nginx-h
(6) start Nginx:
# nginx-t
# nginx
# ps aux | grep nginx
# ss-tunlp | grep-w: 80
(7) configure Nginx to boot:
# vim / etc/rc.d/rc.local
/ usr/local/nginx/sbin/nginx
# chmod + x / etc/rc.d/rc.local
(8) browsers access http://192.168.0.120
2. Deploy MySQL:
(1) close the virtual machine and add a new 10G hard disk to store MySQL data:
(2) enable virtual machine and create LVM logical volume to facilitate future expansion:
A. Disk partition:
# fdisk-l | grep / dev/sdb
# fdisk / dev/sdb-- > n-- > p-- > enter-> t-- > 8e-- > p-- > w
# partx-a / dev/sdb
Note: ignore the error prompt "partx: / dev/sdb: error adding partition 1"
# cat / proc/partitions
B. Create PV:# pvcreate / dev/sdb1 # pvs
C. Create VG:# vgcreate mysqlvg / dev/sdb1 # vgs
D. Create LV:# lvcreate-l + 100%FREE mysqlvg-n mysqldata # lvs
E. Format LVM partition: # mke2fs-t ext4 / dev/mysqlvg/mysqldata
F. Create mount point: # mkdir-pv / data
G. Auto mount on boot:
# vim / etc/fstab-> / dev/mysqlvg/mysqldata / data ext4 defaults 0 0
H. Mount partition: # mount-a
I. View partition information:
# mount | grep mysqldata
# df-Th
(3) install dependent software packages:
# yum-y install gcc gcc-c++ make libxml2-devel ncurses-devel openssl openssl-devel zlib-devel bison-devel
(4) create mysql users and groups:
# groupadd-r mysql
# useradd-g mysql-r-s / sbin/nologin mysql
# id mysql
(5) create a MySQL installation directory: # mkdir-pv / usr/local/mysql
(6) modify the permissions of the installation directory: # chown-R mysql.mysql / usr/local/mysql
(7) create a directory for storing MySQL data: # mkdir-pv / data/mysql
(8) modify the permissions of the data directory:
# chown-R mysql.mysql / data/mysql
# chmod-R o-rx / data/mysql
(9) remove the MariaDB-related components built into CentOS 7.7:
# rpm-qa | grep-I mariadb--> mariadb-libs-5.5.64-1.el7.x86_64
# rpm-e-nodeps mariadb-libs-5.5.64-1.el7.x86_64
If you have previously installed MySQL, delete: # rpm-qa | grep-I mysql
If there is a / etc/my.cnf configuration file, delete: # rm-rf / etc/my.cnf first
(10) compile and install CMake:
# which cmake
# cmake-version
# tar-xf cmake-3.15.3.tar.gz-C / usr/src
# cd / usr/src/cmake-3.15.3
#. / bootstrap
# gmake & & gmake install
# which cmake-- > / usr/local/bin/cmake
# cmake-version
Note: after MySQL version 5.5,. / configure is no longer used, but CMake is used.
(11) decompress the Boost library:
# tar-xf boost_1_59_0.tar.gz-C / usr/local
# cd / usr/local
# mv boost_1_59_0 boost
Note: MySQL version 5.7 requires Boost library support for compilation and installation, and it is recommended that the Boost library version is 1.59.0
(12) compile and install MySQL:
# tar-xf mysql-5.7.27.tar.gz-C / usr/src
# cd / usr/src/mysql-5.7.27
# cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DMYSQL_DATADIR=/data/mysql\
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock\
-DMYSQL_TCP_PORT=3306\
-DSYSCONFDIR=/etc\
-DDEFAULT_CHARSET=utf8\
-DEXTRA_CHARSETS=all\
-DDEFAULT_COLLATION=utf8_general_ci\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_PARTITION_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\
-DWITH_LIBWRAP=0\
-DENABLED_LOCAL_INFILE=1\
-DWITH_DEBUG=0\
-DWITH_BOOST=/usr/local/boost
# make & & make install
Note: it takes a long time to compile and install
(13) create a MySQL configuration file:
# vim / etc/my.cnf
[mysqld]
Port=3306
Socket=/usr/local/mysql/mysql.sock
Datadir=/data/mysql
Basedir=/usr/local/mysql
Lower_case_table_names=1
Character_set_server=utf8mb4
Collation_server=utf8mb4_general_ci
Innodb_file_per_table=1
Skip_name_resolve=1
Slow_query_log=1
Slow_query_log_file=mysql-slow.log
Symbolic-links=0
Explicit_defaults_for_timestamp=1
Server_id=1
Sync_binlog=1
Innodb_flush_log_at_trx_commit=1
Log_bin=mysql-bin
Log_bin_index=mysql-bin.index
Binlog_format=mixed
[mysqld_safe]
Log-error=/var/log/mysql.log
Pid-file=/var/run/mysql.pid
(14) initialize the MySQL database:
# / usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-initialize-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysql
Note:
Make sure the / data/mysql directory is empty before initialization
B, MySQL version 5.7 no longer uses mysql_install_db when initializing the database, but uses mysqld-- initialize
C, parameter-- defaults-file=/etc/my.cnf should be placed first of all parameters
D. The initial password of the root@localhost user will be displayed
(15) configure MySQL environment variables:
# vim / etc/profile.d/mysql.sh
Export PATH=/usr/local/mysql/bin:$PATH
#. / etc/profile.d/mysql.sh
# mysql-V
# mysql-- help | less
(16) manage service processes through mysql.server:
# cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
# chmod + x / etc/init.d/mysqld
(17) configure MySQL to boot:
# chkconfig-add mysqld
# chkconfig mysqld on
(18) start MySQL:
# systemctl start mysqld.service
# systemctl status mysqld.service
# ps aux | grep mysqld
# ss-tunlp | grep-w: 3306
# tail-100 / var/log/mysql.log
(19) configure MySQL Security Wizard: # mysql_secure_installation
(20) Log in to MySQL, create and authorize 'root'@'192.168.0.%' users to manage remotely:
# mysql-uroot-p
Mysql > create user 'root'@'192.168.0.%' identified by' 123456'
Mysql > grant all on *. * to 'root'@'192.168.0.%'
Mysql > flush privileges
3. Deploy PHP:
(1) install dependent software packages:
# yum-y install gcc gcc-c++ make pcre-devel zlib-devel openssl openssl-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel expat-devel bzip2-devel curl-devel gmp-devel libc-client-devel recode-devel net-snmp-devel libtidy-devel readline-devel libxslt-devel libicu-devel
(2) create www users and groups:
# groupadd-r www
# useradd-g www-r-s / sbin/nologin www
# id www
(3) compile and install Libzip:
# tar-xf libzip-1.5.2.tar.xz-C / usr/src
# cd / usr/src/libzip-1.5.2
# mkdir build
# cd build
# cmake..
# make & & make install
Note:
A. If Libzip is not compiled and installed, it will prompt "configure: error: Please reinstall the libzip distribution".
B. You need to compile and install CMake first. MySQL was already installed when you compiled and installed MySQL before.
(4) modify the ld.so.conf configuration file:
# vim / etc/ld.so.conf, add the following code:
/ usr/local/lib64
/ usr/local/lib
/ usr/lib
/ usr/lib64
# ldconfig-v
Note: do not perform this step, "configure: error: off_t undefined; check your library configuration" will be prompted when compiling and installing PHP
(5) compile and install PHP:
# tar-xf php-7.3.9.tar.xz-C / usr/src
# cd / usr/src/php-7.3.9
# / configure-- prefix=/usr/local/php-- disable-rpath-- enable-fpm-- with-fpm-user=www-- with-fpm-group=www-- with-litespeed-- enable-phpdbg--enable-phpdbg-webhelper-- with-config-file-path=/usr/local/php/etc-- with-config-file-scan-dir=/usr/local/php/etc/php.d-- enable-sigchild-- enable-libgcc-- disable-ipv6-- enable-dtrace-- with-libxml -dir-- with-openssl--with-kerberos-- with-pcre-regex-- with-zlib--with-zlib-dir-- enable-bcmath-- with-bz2-- enable-calendar-- with-curl-- enable-exif-- disable-fileinfo-- with-pcre-dir-- enable-ftp-- with-openssl-dir-- with-gd-- with-jpeg-dir-with-png-dir-- with-freetype-dir-- with-gettext-- with-mhash-- enable- Intl-enable-mbstring-enable-mbregex-with-mysqli=mysqlnd-with-mysql-sock=/usr/local/mysql/mysql.sock-enable-pcntl with-pdo-mysql=mysqlnd-with-readline-with-recode-enable-shmop-with-snmp-enable-soap-enable-sockets-enable-sysvmsg enable-sysvsem enable-sysvshm with-tidy enable-wddx with-xmlrpc with-iconv-dir with-xsl enable- Zip-with-libzip-enable-mysqlnd-with-pear
# make & & make install
Note: it takes a long time to compile and install
(6) create a php.ini configuration file: # cp / usr/src/php-7.3.9/php.ini-production / usr/local/php/etc/php.ini
(7) create a php-fpm.conf configuration file: # cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf
Note: php-fpm,PHP FastCGI Process Manager,PHP FastCGI process Manager runs PHP as a stand-alone service through FastCGI
(8) create and modify www.conf configuration files:
# cd / usr/local/php/etc/php-fpm.d
# cp www.conf.default www.conf
# vim www.conf
Before modification
After modification
Listen = 127.0.0.1 9000
Listen = 192.168.0.1209000
(9) configure PHP environment variables:
# vim / etc/profile.d/php.sh
Export PATH=/usr/local/php/sbin:/usr/local/php/bin:$PATH
#. / etc/profile.d/php.sh
# php-v
# php-h | less
# php-fpm-h
(10) manage service processes through php-fpm.service: # cp / usr/src/php-7.3.9/sapi/fpm/php-fpm.service / usr/lib/systemd/system/
(11) start php-fpm:
# php-fpm-t
# systemctl start php-fpm.service
# systemctl status php-fpm.service
# ps aux | grep php-fpm
# ss-tunlp | grep 9000
# tail-100 / usr/local/php/var/log/php-fpm.log
(12) configure PHP to boot: # systemctl enable php-fpm.service
4. Nginx integrates PHP:
(1) modify the nginx.conf configuration file:
# cd / usr/local/nginx/conf
# vim nginx.conf
Worker_processes auto
Location / {
Root html
Index index.php index.html index.htm
}
Location ~\ .php$ {
Root html
Fastcgi_pass 192.168.0.120:9000
Fastcgi_index index.php
Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
Include fastcgi_params
}
# nginx-t
# nginx-s reload
(2) create a test page:
# vim / usr/local/nginx/html/index.php
Note: if you use the mysql_connect () function of the old version of PHP to connect to MySQL in the new version of PHP, you will be prompted with "undefined function mysql_connect ()". Since PHP version 5.5, MySQL has not recommended using the mysql_connect () function, which is an obsolete function. It is not supported at all in PHP 7, and the mysqli_connect () function has been added. In a sense, mysqli is the enhanced version of mysql system function, which is more stable, efficient and secure. It belongs to object-oriented and operates and drives MySQL database in an object-oriented way.
(3) browsers access http://192.168.0.120
Stop MySQL:# systemctl stop mysqld.service
Refresh the page:
3. Set up Zabbix:
1. Deploy Zabbix:
(1) install dependent software packages:
# yum-y install gcc gcc-c++ make net-snmp-devel libxml2-devel libcurl-devel libevent-devel zlib-devel openssl openssl-devel fping
(2) create zabbix users and groups:
# groupadd-r zabbix
# useradd-g zabbix-r-s / sbin/nologin zabbix
# id zabbix
(3) decompress JDK:
# java-version
# tar-xf jdk-8u221-linux-x64.tar.gz-C / usr/local
# cd / usr/local
# ln-sv jdk1.8.0_221 jdk
Note: if the-- enable-java option is enabled when compiling and installing Zabbix 4.2.6, you need to configure JDK
(4) configure JDK environment variables:
# vim / etc/profile.d/jdk.sh
Export JAVA_HOME=/usr/local/jdk
Export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Export PATH=$JAVA_HOME/bin:$PATH
#. / etc/profile.d/jdk.sh
# echo $JAVA_HOME
# java-version
(5) find the mysql_config path: # find /-name mysql_config-- > / usr/local/mysql/bin/mysql_config
(6) compile and install Zabbix:
# tar-xf zabbix-4.2.6.tar.gz-C / usr/src
# cd / usr/src/zabbix-4.2.6
# / configure-- prefix=/usr/local/zabbix-- enable-server-- enable-proxy-- enable-agent-- enable-java-- with-mysql=/usr/local/mysql/bin/mysql_config-- with-libxml2-- with-net-snmp-- with-zlib-- with-libevent-- with-openssl-- with-libcurl
# make & & make install
(7) configure Zabbix environment variables:
# vim / etc/profile.d/zabbix.sh
Export PATH=/usr/local/zabbix/sbin:/usr/local/zabbix/bin:$PATH
#. / etc/profile.d/zabbix.sh
# ln-sv / usr/local/mysql/lib/libmysqlclient.so.20 / usr/lib64/libmysqlclient.so.20
Note: do not perform this step, "zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory" will be prompted when executing the # zabbix_server-- version command
# zabbix_server-version
# zabbix_server-h | less
2. Configure Zabbix:
(1) Log in to MySQL, create zabbix database and 'zabbix'@'192.168.0.%' user, and authorize' zabbix'@'192.168.0.%' user to manage remotely:
# mysql-uroot-p
Mysql > create database zabbix character set utf8 collate utf8_bin
Mysql > create user 'zabbix'@'192.168.0.%' identified by' 123456'
Mysql > grant all on zabbix.* to 'zabbix'@'192.168.0.%'
Mysql > flush privileges
(2) initialize the zabbix database:
Mysql > use zabbix
Mysql > source / usr/src/zabbix-4.2.6/database/mysql/schema.sql
Mysql > source / usr/src/zabbix-4.2.6/database/mysql/images.sql
Mysql > source / usr/src/zabbix-4.2.6/database/mysql/data.sql
Note: the import order of SQL statements cannot be changed.
(3) modify the zabbix_server.conf configuration file:
# cd / usr/local/zabbix/etc
# cp zabbix_server.conf zabbix_server.conf.bak
# vim zabbix_server.conf
Before modification
After modification
# ListenPort=10051
ListenPort=10051
LogFile=/tmp/zabbix_server.log
LogFile=/usr/local/zabbix/zabbix_server.log
# DBHost=localhost
DBHost=192.168.0.120
DBName=zabbix
Keep the default
DBUser=zabbix
Keep the default
# DBPassword=
DBPassword=123456
# DBSocket=
DBSocket=/usr/local/mysql/mysql.sock
# DBPort=
DBPort=3306
# ListenIP=127.0.0.1
ListenIP=192.168.0.120
# AlertScriptsPath=$ {datadir} / zabbix/alertscripts
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts
# ExternalScripts=$ {datadir} / zabbix/externalscripts
ExternalScripts=/usr/local/zabbix/share/zabbix/externalscripts
# FpingLocation=/usr/sbin/fping
FpingLocation=/usr/sbin/fping
# AllowRoot=0
AllowRoot=0
# User=zabbix
User=zabbix
(4) modify the permissions of the installation directory: # chown-R zabbix.zabbix / usr/local/zabbix
(5) start zabbix_server:
# zabbix_server
# ps aux | grep zabbix_server
# ss-tunlp | grep 10051
# tail-100 / usr/local/zabbix/zabbix_server.log
(6) configure zabbix_server to boot:
# vim / etc/rc.d/rc.local
/ usr/local/zabbix/sbin/zabbix_server
# chmod + x / etc/rc.d/rc.local
(7) create a directory for storing Zabbix pages: # mkdir-pv / usr/local/nginx/html/zabbix
(8) copy the PHP file to the directory where the Zabbix page is stored:
# cp-a / usr/src/zabbix-4.2.6/frontends/php/* / usr/local/nginx/html/zabbix/
(9) modify the permissions of the Zabbix web page storage directory: # chown-R nginx.nginx / usr/local/nginx
(10) browsers access http://192.168.0.120/zabbix
(11) modify the php.ini configuration file:
# vim / usr/local/php/etc/php.ini
Before modification
After modification
Post_max_size = 8m
Post_max_size = 16m
Max_execution_time = 30
Max_execution_time = 300
Max_input_time = 60
Max_input_time = 300
; date.timezone =
Date.timezone = Asia/Shanghai
# systemctl restart php-fpm.service
(12) the browser refreshes the page and continues to visit http://192.168.0.120/zabbix
Note: the zabbix user does not have permission to create files in the nginx directory
(13) download the zabbix.conf.php file as prompted
(14) upload the downloaded zabbix.conf.php file to the / usr/local/nginx/html/zabbix/conf/ directory
(15) modify zabbix.conf.php file permissions: # chown nginx.nginx / usr/local/nginx/html/zabbix/conf/zabbix.conf.php
(16) the browser refreshes the page and continues to visit http://192.168.0.120/zabbix
(17) Log in to Zabbix, user name Admin, password zabbix:
(18) modify the default password for Admin users:
Administration-- > Users-- > Admin-- > Change password-- > enter the new password root@123-- > Update twice
Log out and log back in:
(19) Zabbix Server temporarily stops monitoring the status of its own server:
Configuration-- > Hosts-- > check Zabbix server-- > Disable
(20) disable guest users:
Administration-- > User groups-- > check Guests group-- > Disable
Administration-- > Users-- > guest user's status has changed to Disabled
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.