已经使用过的命令

时间:2022-09-02 20:16:22

一.某个(8000)端口被占用?

lsof -i:8000    查询该端口进程的 PID
kill -9 PID 杀掉它

 二.git 切换分支

git  branch -a   查询所有的分支
git  checkout  -b  name  origin/name   切换到分支
git pull 更新仓库代码

或者
git checkout 分支名称

 三. dcoker 如何运行 mysql 镜像

docker search mysql 
docker  pull mysql:5.7.26
docker images
docker run -p 3306:3306 --name mydb -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7.26

 四.CentOS 7.x 防火墙状态查询与关闭

firewall-cmd --state  查询防火墙状态
systemctl stop firewalld.service   关闭防火墙
systemctl disable firewalld.service 禁止开机启动
参考:https://www.cnblogs.com/yyxq/p/10551274.html

 五. 后台启动 jar 与结束

nohup java -jar  xxx.jar &  启动
 默认输出到:nohup.out
 输出重定向: nohup java -jar xxx.jar >>xxx.log &
 验证: jobs -l
ps au 查询后台进程与 PID
ps -ef 查询运行的进程
kill -9 PID 杀死后台进程

 六.nginx 前后端分离配置

conf/nginx.conf 主配置文件

前端项目:/work/project/AgileIotUI 

后端项目:/work/project/zoo.jar   

后端restful接口:ip:8000/iot/**/**

worker_rlimit_nofile 65535;

events {
    use epoll;
    worker_connections  65535;
  }

http {
      include mime.types;
      server_tokens off;
      default_type application/octet-stream;
      log_format main  '$clientRealIp - $remote_user [$time_local] "$request" '
               'fwf[$http_x_forwarded_for] tip[$http_true_client_ip] '
               '$upstream_addr $upstream_response_time $request_time '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent"';

## 这里取得原始用户的IP地址
map $http_x_forwarded_for  $clientRealIp {
        ""      $remote_addr;
        ~^(?P<firstAddr>[0-9\.]+),?.*$  $firstAddr;
 }



  server_names_hash_bucket_size 2048;
  client_header_buffer_size 512k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
  proxy_headers_hash_max_size 51200;
  proxy_headers_hash_bucket_size 6400;



  sendfile off;
  tcp_nopush on;
  keepalive_timeout 60;
  tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 2 256k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types text/plain application/x-javascript  application/xml text/javascript application/javascript application/octet-stream;
  gzip_vary on;

 include /work/webserver/nginx/module/*.conf;

}

modele/*.conf 从配置

 server {
        listen      80;
        server_name  119.23.42.20;
        access_log   logs/build.log  main;

        #ssl on;        
        #ssl_certificate /usr/local/nginx/ssl/*.crt;
        #ssl_certificate_key /usr/local/nginx/ssl/*.key;

location / {   
                index        index.html index.htm;
                root        /work/project/AgileIotUI; 
                try_files $uri $uri/ /index.html;
        }
        location ^~ /AgileIotUI {
                #gzip_static on;
                root     /work/project;
                expires max;
                add_header Cache-Control public;
        }
        location ^~ /iot {
        proxy_pass http://119.23.42.20:8000/iot;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
        location ~ .*\.(js|css|json)?$ {
        root  /work/project/AgileIotUI;
                expires 15d;
                access_log off;
        }

 }

 七. 如何动态的读取日志文件

tail -f  文件名
tail  -fn  行数  文件名