MAC はサーバー CentOS にリモート接続してエラー ログを表示します

MACリモート接続サーバー CentOS

ローカル MAC、リモート Cent0S Linux リリース 8.2.2004 (コア)

突然、404 や 500 などのエラーを報告するインターフェイス ドキュメントが表示されます。サーバーがどのプロジェクトを実行しているのか、サーバーがどのような環境にあるのか混乱していますか? 私は混乱していたので、今日はサーバーへの詳細なリモート接続を記録し、一連の操作を使用してエラーが報告された場所を特定します。

  1. リモート接続サーバー

    MAC 端末 SSH を直接使用してサーバーにリモート接続します

    SSH 構成ファイルを作成すると、将来的にアカウントとパスワードを繰り返し入力しなくてもリモート サーバーに直接接続できるようになります。

    ssh ディレクトリに入ります。設定ファイルがある場合は直接編集します。ない場合は、新しい設定ファイルを作成して編集します。

    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    # 允许使用密码身份验证 
    

    編集後、 Enter キーを押して終了して保存し、途中でサーバーのパスワードを 1 回入力:wqしてコマンドを実行します。ssh_copy_id myserver

    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 $ 
    

    次に、コマンドを直接使用して、パスワードを入力せずにサーバーにリモートでログインできます。

    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. テストインターフェイスのURLに従って、対応するポート番号を確認してください

    netstat -anp | グリップ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 
    

    有用な情報を抽出すると、Nginx プロキシが使用されていることがわかります。プロキシがどこにあるかを確認するには、Nginx 構成ファイルを見つける必要があります。

    (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
    

    この時点で、nginx 構成ファイルの場所が見つかり、nginx.conf構成ファイルを直接チェックしてリスニング65サーバーを見つけました。

    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;
    	}
    }
    

    65 でリッスンしているポートがポート 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. ログ ファイルとコードを確認して問題を特定します。

    このステップは基本的に完了です。コードが見つかり、.out出力ファイルが表示されました。残っているのは、vim でログ ファイルを開き、エラー ドキュメントに従ってエラー レポートを検索して見つけ、ファイル内で対応するコードを見つけることだけです。コードを作成して変更します。

おすすめ

転載: blog.csdn.net/Xiao_tongtong/article/details/132577856