MAC se connecte à distance au serveur CentOS pour afficher le journal des erreurs

Serveur de connexion distant MAC CentOS

MAC local, version Cent0S Linux distante 8.2.2004 (Core)

Soudain, vous recevez un document d'interface qui signale les erreurs, notamment 404 et 500. Êtes-vous confus quant au projet que le serveur exécute et à l'environnement dans lequel il se trouve ? J'étais confus, je vais donc aujourd'hui enregistrer pour vous une connexion à distance détaillée au serveur, puis utiliser une série d'opérations pour localiser l'endroit où l'erreur a été signalée.

  1. Serveur de connexion distant

    Utilisez directement le terminal MAC SSH pour vous connecter à distance au serveur

    Écrivez un fichier de configuration SSH pour faciliter la connexion directe au serveur distant à l'avenir sans avoir à saisir à plusieurs reprises le compte et le mot de passe.

    Entrez dans le répertoire ssh. S'il y a un fichier de configuration, allez directement pour le modifier. Sinon, créez-en simplement un nouveau et modifiez le fichier de configuration.

    tong ~/.ssh $ cd ~/.ssh
    tong ~/.ssh $ ll
    total 40
    drwx------   7 tong  staff   224B Aug 29 17:17 .
    drwxr-x---+ 98 tong  staff   3.1K Aug 30 10:11 ..
    -rw-r--r--   1 tong  staff   301B Aug 29 15:26 config
    -rw-------   1 tong  staff   2.5K Dec  7  2022 id_rsa
    -rw-r--r--   1 tong  staff   576B Dec  7  2022 id_rsa.pub
    -rw-------   1 tong  staff   1.7K Aug 29 15:26 known_hosts
    -rw-------   1 tong  staff   1.5K Aug 29 15:23 known_hosts.old
    tong ~/.ssh $ vim config
    
    Host myserver 										# myserver 是可以自定义的名字,之后就使用这个别名直接连接指定的服务器
        HostName 123.123.123.123       # 实际的远程服务器域名 或 IP 地址
        Port 22                       # SSH 端口,默认为 22,如果不是 22,需要修改,注意要开启该端口,一般服务器都默认开启
        User root             			  # 登录用户名
        PassWordAuthentication yes    # 允许使用密码身份验证 
    

    Après l'édition, entrez :wqpour quitter et enregistrer, puis exécutez la commande ssh_copy_id myserveren saisissant une fois le mot de passe du serveur au milieu.

    tong ~/.ssh $ ssh_copy_id myserver
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    [email protected] 's password: 
    
    Number of key(s) added:        1
    
    Now try logging into the machine, with:   "ssh -o 'PreferredAuthentications=password' -o 'PubkeyAuthentication=no' 'nnserver'"
    and check to make sure that only the key(s) you wanted were added.
    
    tong ~/.ssh $ 
    

    Ensuite, vous pouvez directement utiliser la commande pour vous connecter au serveur à distance sans saisir de mot de passe.

    tong ~/.ssh $ ssh myserver
    	
    	Welcome to Huawei Cloud Service
    
    Last failed login: Wed Aug 30 00:31:10 CST 2023 from 123.123.123.123 on ssh:notty
    There were 2 failed login attempts since the last successful login.
    Last login: Tue Aug 29 17:17:02 2023 from 123.123.123.123
    (base) [root@Server-3401572e-0499-44a9 ~]# 
    
  2. Vérifiez le numéro de port correspondant en fonction de l'url de l'interface de test

    netstat-anp | Poignée 65

    (base) [root@Server-3401572e- ~]# netstat -anp | grep 65
    tcp        0      0 127.0.0.1:6655          0.0.0.0:*               LISTEN      889536/python       
    tcp        0      0 0.0.0.0:65              0.0.0.0:*               LISTEN      487900/nginx: maste 
    

    Après avoir extrait les informations utiles, on constate que le proxy Nginx est utilisé. Il faut maintenant trouver le fichier de configuration Nginx pour voir où se trouve le proxy ?

    (base) [root@Server-3401572e-0499 ~]# cd /
    (base) [root@Server-3401572e-0499 /]# find / -name nginx
    /usr/local/nginx
    /usr/local/srs/srs.oschina/trunk/objs/nginx
    /root/anaconda3/pkgs/notebook-6.0.3-py38_0/lib/python3.8/site-packages/notebook/static/components/codemirror/mode/nginx
    /root/anaconda3/lib/python3.8/site-packages/notebook/static/components/codemirror/mode/nginx
    /home/nginx
    /home/nginx/sbin/nginx
    (base) [root@Server-3401572e-0499 /]# cd /home/nginx/sbin/
    (base) [root@Server-3401572e-0499 sbin]# ./nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    

    À ce stade, nous avons trouvé l'emplacement du fichier de configuration nginx et vérifié directement nginx.confle fichier de configuration pour trouver le 65serveur d'écoute.

    server {
    	listen       65;
    	server_name  localhost;
    	location / {
    		proxy_connect_timeout 300s;
    		proxy_send_timeout 300s;
    		proxy_read_timeout 300s;
    		proxy_pass http://127.0.0.1:6655;
    		charset utf-8;
    	}
    }
    

    On voit que celui qui écoute sur 65 atteint le port 6655.

    (base) [root@Server-3401572e-0499-44a9 sbin]# netstat -anp | grep 6655
    tcp        0      0 127.0.0.1:6655          0.0.0.0:*               LISTEN      889536/python   
    (base) [root@Server-3401572e-0499-44a9-88bb-b2b2061f3c4e sbin]# conda env list
    # conda environments:
    #
    base                  *  /root/anaconda3
    detection                /root/anaconda3/envs/detection
    pygdal                   /root/anaconda3/envs/pygdal
    
    (base) [root@Server-3401572e-0499-44a9 sbin]# ps -ef | grep python
    
    root      713634       1  0 Apr02 ?        00:19:42 python FDEMO4.py
    root      889536       1  0 Jun15 ?        02:58:26 python EXGApi.py
    root     1046006 1045923  0 10:38 pts/4    00:00:00 grep --color=auto python
    (base) [root@Server-3401572e-0499-44a9 sbin]# cd /
    (base) [root@Server-3401572e-0499-44a9 /]# find / -name EXGApi.py
    /root/model/EXGApi.py
    (base) [root@Server-3401572e-0499-44a9 /]# cd ~/model/
    (base) [root@Server-3401572e-0499-44a9 model]# ll
    total 8636
    drwxr-xr-x  233 root root   12288 Aug 14  2022 exg
    -rw-r--r--    1 root root 7910788 Aug 29 11:06 EXGApi.out
    -rw-r--r--    1 root root   13351 Jun 15 16:55 EXGApi.py
    -rw-r--r--    1 root root  237289 Aug 30 03:16 fdemo4.log
    -rw-r--r--    1 root root  380102 Apr  2 22:36 fdemo4.out
    -rw-r--r--    1 root root    7050 Apr  2 22:36 FDEMO4.py
    drwxr-xr-x 4539 root root  135168 Aug 28 10:38 jpgresult
    -rw-r--r--    1 root root  108259 Aug  7  2022 model.out
    drwxr-xr-x    2 root root    4096 Apr  5 11:59 receive
    drwxr-xr-x  164 root root    4096 Apr  5 11:59 result
    drwxr-xr-x    2 root root    4096 Jul  4  2022 reve
    
  3. Vérifiez les fichiers journaux et le code pour localiser le problème

    Cette étape est pratiquement terminée. Nous avons trouvé le code et vu le .outfichier de sortie. Il ne reste plus qu'à ouvrir le fichier journal avec vim, rechercher et localiser le rapport d'erreur selon le document d'erreur, puis trouver le code correspondant dans le codez-le et modifiez-le. !

Je suppose que tu aimes

Origine blog.csdn.net/Xiao_tongtong/article/details/132577856
conseillé
Classement