您的当前位置:首页正文

基础排障实验

2024-11-06 来源:个人技术集锦

排障实验要求:

思路:

设置开机自启

添加一个mx记录解析到jxjz

mail        MX 10        mail.jxjz.com.

修改dhcphost

修改nginx配置文件25000*4

查看php版本,php版本过低,需要更新版本部署符合centos7版本的php

创建mysql用户并赋予密码

yum install telnet

set type=MX

dhcp -t -cf 检查命令


一、配置DNS

vim /etc/named.conf

options {
        listen-on port 53 { any; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { any; };

zone "jxjz.com" IN {
        type master;
        file "jxjz.com.zones";
};

cd /var/named/

[root@localhost named]# ls
data    named.empty      named.loopback
dynamic  named.ca        named.localhost  slaves

没有解析文件 复制一个出来并复制归属
[root@localhost named]# cp -R named.empty jxjz.com.zones
查看归属
[root@localhost named]# ll
总用量 20
drwxrwx---. 2 root root    6 1月  26 2023 data
drwxrwx---. 2 root root   31 8月   9 2023 dynamic
-rw-r-----. 1 root root 2253 4月   5 2018 named.ca
-rw-r-----. 1 root root  239 8月   9 16:00 jxjz.com.zones
-rw-r-----. 1 root root  152 12月 15 2009 named.empty
-rw-r-----. 1 root root  152 6月  21 2007 named.localhost
-rw-r-----. 1 root root  168 12月 15 2009 named.loopback
drwxrwx---. 2 root root    6 1月  26 2023 slaves
属组应该是named所以需要修改
[root@localhost named]# ll
总用量 20
drwxrwx---. 2 root named    6 1月  26 2023 data
drwxrwx---. 2 root named   31 8月   9 2023 dynamic
-rwxr-xr-x  1 root named  239 8月   9 16:00 jxjz.com.zones
-rw-r-----. 1 root named 2253 4月   5 2018 named.ca
-rw-r-----. 1 root named  152 12月 15 2009 named.empty
-rw-r-----. 1 root named  152 6月  21 2007 named.localhost
-rw-r-----. 1 root named  168 12月 15 2009 named.loopback
drwxrwx---. 2 root named    6 1月  26 2023 slaves

修改正向解析文件并重启

vim /var/named/jxjz.com.zones

$TTL 3H
@       IN SOA   jxjz.com. root.jxjz.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns.jxjz.com.
dns     A       192.168.100.150
mail    A       192.168.100.150
www     A       192.168.100.150
        MX 10   mail.jxjz.com.

[root@localhost named]# nslookup 
> www.jxjz.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	www.jxjz.com
Address: 192.168.100.150
> ^C[root@localhost named]# 

开启开机自启

[root@localhost named]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.

修改后重启dhcp并关闭开机自启

vim /etc/dhcp/dhcpd.conf

subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.100 192.168.100.210;
  option domain-name-servers 8.8.8.8;
  option domain-name "internal.example.org";
  option routers 192.168.100.1;
  option broadcast-address 192.168.100.255;
  default-lease-time 600;
  max-lease-time 7200;
}


host fantasia {
  hardware ethernet ff:0a:ac:44:33:22;
  fixed-address 192.168.100.200;
}

[root@localhost named]# systemctl restart dhcpd
[root@localhost named]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
[root@localhost named]# 

三、修改nginx配置文件为4线程50000+

nginx -t 排语法错误第55行多个分号

vim /etc/nginx/nginx.conf

设置开机自启

[root@localhost named]# vim /etc/nginx/nginx.conf

worker_processes  4;

events {
    worker_connections  25000;
}

    server {
        listen       8081;
        server_name  www.jxjz.com;
 
       location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }

[root@localhost html]# systemctl enable nginx

四、确保PHPMy
Admin能够管理数据库

遇到CentOS7原有php版本旧,查阅资料后得到的解决方案。

php要求版本不得低于5.6

查看当前版本

[root@cy-ed03-lvs ~]# php -v
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

查看相关软件包

[root@cy-ed03-lvs ~]# yum list installed | grep php
php.x86_64                            5.4.16-48.el7                  @base      
php-cli.x86_64                        5.4.16-48.el7                  @base      
php-common.x86_64                     5.4.16-48.el7                  @base      
php-fpm.x86_64                        5.4.16-48.el7                  @base      
php-mysql.x86_64                      5.4.16-48.el7                  @base      
php-pdo.x86_64                        5.4.16-48.el7                  @base 

 更换 RPM 源   (此处只适用于CentOS7。其他版本更新RPM源方法不一致)

yum install https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

[root@cy-ed03-lvs ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm
warning: /var/tmp/rpm-tmp.sPIfq2: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
	package epel-release-7-13.noarch (which is newer than epel-release-7-5.noarch) is already installed
[root@cy-ed03-lvs ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.olTJiE: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]

 停止相关服务

[root@cy-ed03-lvs ~]# systemctl stop nginx
[root@cy-ed03-lvs ~]# systemctl stop php-fpm

删除软件包

[root@cy-ed03-lvs ~]# yum remove php
[root@cy-ed03-lvs ~]# yum list installed | grep php
php-cli.x86_64                        5.4.16-48.el7                  @base      
php-common.x86_64                     5.4.16-48.el7                  @base      
php-fpm.x86_64                        5.4.16-48.el7                  @base      
php-mysql.x86_64                      5.4.16-48.el7                  @base      
php-pdo.x86_64                        5.4.16-48.el7                  @base
[root@cy-ed03-lvs ~]# yum remove php-*
[root@cy-ed03-lvs ~]# yum list installed | grep php
[root@cy-ed03-lvs ~]#

安装软件包

[root@cy-ed03-lvs ~]# yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt

正在安装:
 mod_php72w            x86_64       7.2.34-1.w7            webtatic       3.1 M
 php72w-cli            x86_64       7.2.34-1.w7            webtatic       3.1 M
 php72w-common         x86_64       7.2.34-1.w7            webtatic       1.3 M
 php72w-devel          x86_64       7.2.34-1.w7            webtatic       2.8 M
 php72w-embedded       x86_64       7.2.34-1.w7            webtatic       1.5 M
 php72w-fpm            x86_64       7.2.34-1.w7            webtatic       1.6 M
 php72w-gd             x86_64       7.2.34-1.w7            webtatic       142 k
 php72w-ldap           x86_64       7.2.34-1.w7            webtatic        36 k
 php72w-mbstring       x86_64       7.2.34-1.w7            webtatic       587 k
 php72w-mysqlnd        x86_64       7.2.34-1.w7            webtatic       198 k
 php72w-opcache        x86_64       7.2.34-1.w7            webtatic       247 k
 php72w-pdo            x86_64       7.2.34-1.w7            webtatic        90 k
 php72w-xml            x86_64       7.2.34-1.w7            webtatic       123 k
为依赖而安装:
 libargon2             x86_64       20161029-3.el7         epel            23 k
 pcre-devel            x86_64       8.32-17.el7            base           480 k
以下没有安装成功继续单独安装
Error downloading packages:
  php72w-ldap-7.2.34-1.w7.x86_64: [Errno 256] No more mirrors to try.
  php72w-embedded-7.2.34-1.w7.x86_64: [Errno 256] No more mirrors to try.
  php72w-devel-7.2.34-1.w7.x86_64: [Errno 256] No more mirrors to try.
  pcre-devel-8.32-17.el7.x86_64: [Errno 256] No more mirrors to try.

已安装:
  mod_php72w.x86_64 0:7.2.34-1.w7        php72w-cli.x86_64 0:7.2.34-1.w7        
  php72w-devel.x86_64 0:7.2.34-1.w7      php72w-embedded.x86_64 0:7.2.34-1.w7   
  php72w-fpm.x86_64 0:7.2.34-1.w7        php72w-gd.x86_64 0:7.2.34-1.w7         
  php72w-ldap.x86_64 0:7.2.34-1.w7       php72w-mbstring.x86_64 0:7.2.34-1.w7   
  php72w-mysqlnd.x86_64 0:7.2.34-1.w7    php72w-opcache.x86_64 0:7.2.34-1.w7    
  php72w-pdo.x86_64 0:7.2.34-1.w7        php72w-xml.x86_64 0:7.2.34-1.w7        

作为依赖被安装:
  libargon2.x86_64 0:20161029-3.el7       pcre-devel.x86_64 0:8.32-17.el7      

完毕!

重新启动相关服务,开启开机自启

[root@localhost html]# systemctl restart nginx.service
[root@localhost html]# systemctl restart php-fpm.service 
[root@localhost html]# php -v
PHP 7.2.34 (cli) (built: Oct  1 2020 13:37:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
[root@localhost html]# 
systemctl enable php-fpm

编辑网页

vim /usr/share/nginx/html/index.php

vim /usr/share/nginx/html/index.php
<?php
phpinfo();
?>

访问网页

访问成功 添加开机自启

systemctl enable mariadb

 

 

[root@localhost tmp]# systemctl restart mariadb
[root@localhost tmp]# mysqladmin -uroot password 123456

 创建admin用户给密码并给所有权限

mysql -uadmin -h 192.168.100.150 -p'1234.com'

[root@localhost tmp]# mysql -uadmin -h 192.168.100.150 -p'1234.com'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
Top