1、基础信息
系统版本: CentOS Linux release 7.6.1810 (Core)
内核版本: 4.19.0-9.el7.ucloud.x86_64
2、开始安装
# 依赖安装
yum -y install gcc gcc-c++ unixODBC-devel httpd mysql-devel libcurl libcurl-devel libevent libevent-devel fping curl-devel libxml2 libxml2-devel snmpd net-snmp-devel net-snmp
# nginx安装
yum install -y http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.20.1-1.el7.ngx.x86_64.rpm
# 安装php7
#首先安装 EPEL 源
yum install epel-release -y
#安装 REMI 源:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
# 安装php
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum -y install php php-opcache
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
yum -y install php-mbstring
yum -y install php-json
yum -y install php-xml
yum -y install php-fedora-autoloader
yum -y install php-sodium
yum -y install php
yum -y install php-gd
yum -y install php-devel
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-gd
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pdo
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pdo php-process
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-mysqlnd
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-ldap
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-cli
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-pear
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-bcmath
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-devel php-pecl-msgpack php-pecl-redis5 php-bcmath php-pecl-zip oniguruma5php
yum install -y php-fpm
# 检查
rpm -qa|grep php
#设置开机启动、运行服务:如果无法启动php就重启一下主机
sed -i 's#nobody#zabbix#g' /etc/php-fpm.d/www.conf
systemctl restart php-fpm.service
systemctl status php-fpm.service
# mysql 安装
#卸载自带的mariadb
yum remove mariadb mariadb-libs -y
#下载mysql5.7的repo
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
#然后进行repo的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum clean all
yum makecache
yum install mysql-community-server -y
yum install mysql-devel -y
# 启动mysql和设置开机自启动
systemctl enable mysqld
systemctl start mysqld
#查看临时密码
grep 'temporary password' /var/log/mysqld.log
#登陆msyql
mysql -uroot -p 查看临时密码
#首先需要设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW 即可,
set global validate_password_policy=LOW;
set global validate_password_length=6;#修改默认密码长度
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'zabbix';
flush privileges;
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'zabbix';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
# zabbix_server安装
wget -c https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.13.tar.gz
tar xf zabbix-6.0.13.tar.gz
cd zabbix-6.0.13/
yum install -y net-snmp-devel
./configure --prefix=/usr/local/zabbix/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc && make && make install
#参数说明
--prefix #编译安装路径
--enable-server #启动server端
--enable-agent #启动agent端
--with-mysql #编译连接mysql相关依赖包
--with-net-snmp #启动snmp相关,用于snmp监控设备
--with-libcurl #启动curl相关
--with-libxml2 #启动xml相关
--with-unixodbc #启动odbc相关用于监控数据库
--enable-java #启动java-agent 用于监控java类
sed -i 's/# DBPassword=/DBPassword=zabbix/g' /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
sed -i 's/# DBHost=localhost/DBHost=localhost/g' /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
# 创建zabbix需要的数据
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/double.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
useradd zabbix -s /sbin/nologin
# 启动
/usr/local/zabbix/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
tail -200f /tmp/zabbix_server.log
#检查
netstat -lntup|grep 10051
# 杀死
ps aux |grep zabbix_server |grep -v grep |awk '{print $2}'|xargs kill -9
# systemd管理zabbix_server进程
cat /usr/lib/systemd/system/zabbix_server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/zabbix-server/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix_server
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/zabbix-server/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
### 重载
systemctl daemon-reload
### 启动zabbix
systemctl restart zabbix_server
systemctl enable zabbix_server
# nginx添加配置
cp -a /root/zabbix-6.0.13/ui /usr/share/
mv /usr/share/ui /usr/share/zabbix
cat /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/zabbix/;
index index.php;
location ~ .*\.php$ {
fastcgi_read_timeout 300;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
# 启动nginx php 加入开机自启
nginx -t
nginx
nginx -s reload
systemctl enable nginx
systemctl enable php-fpm.service
systemctl restart php-fpm.service
# 访问
http://192.168.1.1/setup.php
标签:CentOS,Kubernetes,7.0,devel,zabbix,yum,install,mysql,php
From: https://www.cnblogs.com/suyj/p/18382592