2020年12月8日 星期二

Win10 關閉(大易輸入法關閉相關詞)

電腦\HKEY_CURRENT_USER\SOFTWARE\Microsoft\TableTextService\0x00000404\{037B2C25-480C-4D7F-B027-D6CA6B69788A}
HKEY_CURRENT_USER\Software\Microsoft\TableTextService\0x00000404\{037B2C25-480C-4D7F-B027-D6CA6B69788A} 實測 新增DWORD類型EnableAssociatePhrase數值改為 0 即可關閉相關字詞

2020年10月12日 星期一

Windows 10 MTU

TCP Analyzer
https://www.speedguide.net/

netsh interface ipv4 show subinterfaces
netsh int ipv4 set subinterface "iPhone-jojo" mtu=1440 store=persistent

2020年9月22日 星期二

openssl 1.1.1g

wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz
tar -zxvf perl-5.28.0.tar.gz
cd perl-5.28.0
./Configure -des -Dprefix=$HOME/localperl
make test
make install

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.tar.gz
tar -xzf OpenSSL_1_1_1g.tar.gz
cd openssl-OpenSSL_1_1_1g
./config --prefix=/usr
make && make install
ldconfig
openssl version

2020年8月3日 星期一

Redis Cluster docker-compose.yml

run.sh
docker-compose down
docker-compose up -d

#設定 cluster
docker exec -it redis1 redis-cli --cluster create 10.123.123.11:7001 10.123.123.11:7002 10.123.123.11:7003 10.123.123.11:7004 10.123.123.11:7005 10.123.123.11:7006 --cluster-replicas 1
docker exec -it redis1 redis-cli -h 10.123.123.11 -p 7001 -c
docker-compose.yml
version: '2'
services:
  redis1:
    image: redis
    hostname: redis1
    container_name: redis1
    restart: always
    network_mode: host
    entrypoint:  
      - redis-server
      - --port 7001
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no
    ports:
      - 7001

  redis2:
    image: redis
    hostname: redis2
    container_name: redis2
    restart: always
    network_mode: host
#    volumes:
#      - ./vol/opt/:/opt/
    ports:
      - 7002
    entrypoint:  
      - redis-server
      - --port 7002
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis3:
    image: redis
    hostname: redis3
    container_name: redis3
    restart: always
    network_mode: host
    ports:
      - 7003
    entrypoint:  
      - redis-server
      - --port 7003
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis4:
    image: redis
    hostname: redis4
    container_name: redis4
    restart: always
    network_mode: host
    ports:
      - 7004
    entrypoint:  
      - redis-server
      - --port 7004
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis5:
    image: redis
    hostname: redis5
    container_name: redis5
    restart: always
    network_mode: host
    ports:
      - 7005
    entrypoint:  
      - redis-server
      - --port 7005
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

  redis6:
    image: redis
    hostname: redis6
    container_name: redis6
    restart: always
    network_mode: host
    ports:
      - 7006
    entrypoint:  
      - redis-server
      - --port 7006
      - --appendonly yes
      - --cluster-enabled yes
      - --protected-mode no

2020年6月26日 星期五

CentOS 安裝 redis

yum -y --enablerepo=remi,remi-test install redis
設定 Redis 為背景服務
sudo systemctl daemon-reload
sudo systemctl enable redis.service
開啟防火牆 6379 埠號
# Add allow port 6379
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload
啟動 Redis
# Start Redis service
sudo systemctl start redis.service
Ping Redis
redis-cli ping
yum -y remove redis

nginx /var/log/nginx/error.log failed (13: Permission denied), SELinux Problem

2020/06/26 00:59:59 [error] 9825#0: *52 open() "/home/user/www/index.html" failed (13: Permission denied),
解決方式,SELinux
chcon -R -u system_u -t httpd_sys_content_t /home/user/www

CentOS 安裝nginx

安裝能夠選擇指定 yum 的套件:
yum install yum-utils -y
vim /etc/yum.repos.d/nginx.repo
# 穩定版
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true

# 最新版
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=0
module_hotfixes=true
yum-config-manager --enable nginx-stable
切換使用 nginx-stable 穩定版:
yum-config-manager --enable nginx-stable
查看欲安裝的 NGINX 版本資訊:
yum info nginx
安裝 NGINX:
yum install nginx -y
查看安裝的 NGINX 版本:
nginx -v
移除nginx
yum remove nginx -y

CentOS 7.x 安裝 OpenJDK 1.8

yum -y install java-1.8.0-openjdk
[root@localhost ~]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
[root@localhost ~]# 
yum -y remove java-1.8.0-openjdk

2020年2月28日 星期五

pytorch gpu (Cuda 9.2) python 3.8.1

cuda_9.2.148_win10.exe
cuda_9.2.148.1_windows.exe
cudnn-9.2-windows10-x64-v7.6.5.32.zip

(base) C:\Users\me> conda create --name pytorch-gpu
(base) C:\Users\me> conda create --name pytorch-gpu python=3.7

(pytorch-gpu) C:\Users\me>pip install numpy
Collecting numpy
  Downloading numpy-1.18.1-cp38-cp38-win_amd64.whl (12.8 MB)
     |████████████████████████████████| 12.8 MB 1.6 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.18.1

(pytorch-gpu) C:\Users\me>pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html
Looking in links: https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html
Collecting torch
  Downloading https://download.pytorch.org/whl/nightly/cu92/torch-1.5.0.dev20200227%2Bcu92-cp38-cp38-win_amd64.whl (690.3 MB)
     |████████████████████████████████| 690.3 MB 15 kB/s
Collecting torchvision
  Downloading https://download.pytorch.org/whl/nightly/cu92/torchvision-0.6.0.dev20200228%2Bcu92-cp38-cp38-win_amd64.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 284 kB/s
Collecting pillow>=4.1.1
  Downloading Pillow-7.0.0-cp38-cp38-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 930 kB/s
Requirement already satisfied: numpy in c:\users\me\anaconda3\envs\pytorch-gpu\lib\site-packages (from torchvision) (1.18.1)
Collecting six
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: torch, pillow, six, torchvision
Successfully installed pillow-7.0.0 six-1.14.0 torch-1.5.0.dev20200227+cu92 torchvision-0.6.0.dev20200228+cu92

(pytorch-gpu) C:\Users\me>python
Python 3.8.1 (default, Feb 27 2020, 14:41:12) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>>

(pytorch-gpu) C:\Users\me>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:08:12_Central_Daylight_Time_2018
Cuda compilation tools, release 9.2, V9.2.148

2020年2月26日 星期三

NGINX config

[root@www1 ~]# vi /etc/nginx/nginx.conf
#user  nginx;
user  root;
worker_processes  auto;
worker_rlimit_nofile 100000;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  16382;
    # 告訴nginx收到一個新連接通知後接受儘可能多的連接。
    multi_accept on; 
    accept_mutex off;
    use epoll; 
}


http {
    # 關閉在錯誤頁面中的nginx版本數字
    server_tokens off;
    # 可以讓sendfile()發揮作用。
#    sendfile on;
    # 告訴nginx在一個數據包裡發送所有頭文件,而不一個接一個的發送。
    tcp_nopush on;
    # 告訴nginx不要緩存數據,而是一段一段的發送–當需要及時發送數據時,就應該給應用設置這個屬性,這樣發送一小塊數據信息時就不能立即得到返回值。
    tcp_nodelay on;

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time "$http_accept_encoding" "$upstream_cache_status"' ;

     log_format rt_cache '$remote_addr - $upstream_cache_status [$time_local]  '
                      '"$request" $status $body_bytes_sent '
                      '"$http_referer" "$http_user_agent"';

    access_log  /var/log/nginx/access.log  main;
    access_log  /var/log/nginx/cache.log   rt_cache;

    sendfile        on;
#    tcp_nopush     on;
#    tcp_nodelay    on;


    keepalive_timeout 0;
#    keepalive_timeout  300;
    keepalive_requests 200000;
    #keepalive_timeout  65;
    #iproxy_read_timeout 300;
    #fastcgi_read_timeout 300;

    open_file_cache max=10240 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;

    #client_body_timeout 60s;
    #gzip                off;
    gzip                on;
    gzip_buffers        4 16k;
    gzip_http_version   1.0;
    gzip_types          text/plain  application/x-javascript text/css application/xml application/json text/javascript application/javascript;
    #gzip_types          text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_static on;


    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 1536;
#    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;


    proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=my_cache:10m max_size=2g inactive=60m use_temp_path=off;
    # Set cache key to include identifying components
    #proxy_cache_key $scheme$proxy_host$request_uri;
    #proxy_cache_key $scheme$host$request_uri$is_args$args;
    proxy_cache_key $host$request_uri$is_args$query_string;
    include /etc/nginx/conf.d/*.conf;
}
[root@www1 ~]# cat /etc/nginx/conf.d/default.conf
upstream ncdrapi {
  server 10.123.123.17:8009 max_fails=2 fail_timeout=10s;
}

upstream auth_api {
  server 10.123.123.17:8008 max_fails=2 fail_timeout=10s;
}


server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    #listen 443 ssl http2 default_server;
    #listen [::]:443 ssl http2 default_server;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate     /etc/nginx/conf.d/front-end.strangled.net/server.crt;
    ssl_certificate_key /etc/nginx/conf.d/front-end.strangled.net/private.key;
    ssl_dhparam /etc/nginx/conf.d/front-end.strangled.net/dhparams.pem;



    ssl_buffer_size 4k;
    ssl_session_cache shared:SSL:9m;
    ssl_session_cache shared:ssl_session_cache:10m;
    ssl_session_timeout 5m;
#    ssl_protocols TLSv1.3;
    ssl_protocols TLSv1.2 TLSv1.3;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    #remove TLS_RSA_WITH_3DES_EDE_CBC_SHA
    ssl_ciphers         HIGH:!aNULL:!MD5;
#    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_stapling on;
    ssl_stapling_verify on;
#       ssl_trusted_certificate /path/to/full_chain.pem;
        ssl_trusted_certificate /etc/nginx/conf.d/front-end.strangled.net/server.crt;
        resolver 210.69.1.1 210.69.2.1 valid=300s;
        resolver_timeout 5s;

    add_header X-Frame-Options "DENY";
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
#    resolver 8.8.8.8 8.8.4.4 valid=300s;
#    resolver_timeout 5s;
    location ~ /\.ht {
    deny all;
    }

        add_header X-Cache-Status $upstream_cache_status;
    location /rmrescad/ {
       proxy_pass http://ncdrapi/rmrescad/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /caseinfo/ {
       proxy_pass http://ncdrapi/caseinfo/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /rmresfca/ {
       proxy_ignore_headers "Set-Cookie";
       proxy_hide_header "Set-Cookie";
       proxy_cache my_cache;
       proxy_cache_valid 200 304 1s;

       proxy_cache_methods GET POST;  #增加此行
       proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
       proxy_redirect off;
       proxy_cache_revalidate on;
       proxy_cache_min_uses 1;
       proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
       proxy_cache_lock on;


       proxy_pass http://ncdrapi/rmresfca/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /rmressca/ {
       proxy_pass http://ncdrapi/rmressca/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /rmrestca/ {
       proxy_pass http://ncdrapi/rmrestca/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /rmresdef/ {
       proxy_pass http://ncdrapi/rmresdef/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }


    location /rmreq/ {
       proxy_ignore_headers "Set-Cookie";
       proxy_hide_header "Set-Cookie";

       proxy_pass http://ncdrapi/rmreq/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;

    }

         # 快取 集散地
    location /stockstation/ {
       proxy_pass http://ncdrapi/stockstation/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }


    # 快取 rmdisa/querycaseda/ 物資類別
    location /rmdisa/ {
       proxy_pass http://ncdrapi/rmdisa/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    #RM250: 入庫作業
    location /rmstation/ {
       proxy_pass http://ncdrapi/rmstation/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    #RM250: 入庫作業
    location /rmsdetail/ {
       proxy_pass http://ncdrapi/rmsdetail/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /unmarshal/ {
       proxy_pass http://ncdrapi/unmarshal/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /marshal/ {
       proxy_pass http://ncdrapi/marshal/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }



        # 首頁物資查詢
    location /homepage/ {
       proxy_pass http://ncdrapi/homepage/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

        # 物資圖示 快取 1小時
    location /materialImg/ {
       proxy_ignore_headers "Set-Cookie";
       proxy_hide_header "Set-Cookie";
       proxy_cache my_cache;
       proxy_cache_valid 200 304 1h;
       proxy_cache_methods GET POST;  #增加此行
       proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
           proxy_redirect off;
       proxy_cache_revalidate on;
       proxy_cache_min_uses 1;
       proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
       proxy_cache_lock on;

       proxy_pass http://ncdrapi/materialImg/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /frontend/ {
       proxy_pass http://ncdrapi/frontend/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /api/ {

       proxy_pass http://10.123.123.17:8008/api/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location /oauth/ {

       proxy_pass http://10.123.123.17:8008/oauth/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    #EMIC 查詢最新災害應變專案
    location /emicOpenCases/ {
        proxy_ignore_headers "Set-Cookie";
        proxy_hide_header "Set-Cookie";
        proxy_cache my_cache;
        proxy_cache_valid 200 304 1s;

        proxy_cache_methods GET POST;  #增加此行
        proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
            proxy_redirect off;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 1;
        proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
        proxy_cache_lock on;

       proxy_pass http://10.123.123.10:80/emicOpenCases/;

       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location  /nginx {
       proxy_cache off;
       proxy_pass http://localhost:2080/nginx;
    }

   # 線上 http://223.200.166.225/EDXL/
    location /EDXL/ {
       proxy_pass https://10.123.123.9/EDXL/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    # 測試 http://223.200.166.225/EDXL_test_material/
    location /EDXL_test_material/ {
       proxy_pass https://10.123.123.9/EDXL_test_material/;
       # 定義 header 變數, 記錄使用者的 IP
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
       proxy_max_temp_file_size 0;
    }

    location / {
       root /home/uiux/admin;
       #root   /usr/share/nginx/html;
       index  index.html;
    }

    location = /nginx_status {
      stub_status on;
      access_log off;
      #allow 223.200.181.30;
      allow 127.0.0.1;
      #allow 10.123.123.13;
      deny all;
      #allow all;
    }

    location /.well-known/acme-challenge/ {
      alias /var/www/dehydrated/;
    }   
}

CENTOS 7 sysctl 優化

[root@www1 ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).


# System level; Default : 19593930
# Get current opening files by : cat /proc/sys/fs/file-nr
fs.file-max = 19593930

# Process level; Default : 1048576
# nr_open should smaller than file-max
fs.nr_open = 1048576

# Aysnc I/O; Default : 65536
# Get current opening files by : cat /proc/sys/fs/aio-nr
fs.aio-max-nr=262144

# Maximum processes enabled; Default : 196608
kernel.pid_max = 4194303

kernel.sched_migration_cost_ns = 5000000
kernel.sched_autogroup_enabled = 0

net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_orphan_retries = 2
net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_max_syn_backlog = 3240000
net.ipv4.tcp_max_tw_buckets = 5000
#net.ipv4.tcp_max_tw_buckets = 1440000

net.core.netdev_max_backlog = 3240000
net.core.somaxconn = 50000
[root@www1 ~]# clear

[root@www1 ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).


# System level; Default : 19593930
# Get current opening files by : cat /proc/sys/fs/file-nr
fs.file-max = 19593930

# Process level; Default : 1048576
# nr_open should smaller than file-max
fs.nr_open = 1048576

# Aysnc I/O; Default : 65536
# Get current opening files by : cat /proc/sys/fs/aio-nr
fs.aio-max-nr=262144

# Maximum processes enabled; Default : 196608
kernel.pid_max = 4194303

kernel.sched_migration_cost_ns = 5000000
kernel.sched_autogroup_enabled = 0

net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_orphan_retries = 2
net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_max_syn_backlog = 3240000
net.ipv4.tcp_max_tw_buckets = 5000
#net.ipv4.tcp_max_tw_buckets = 1440000

net.core.netdev_max_backlog = 3240000
net.core.somaxconn = 50000
net.core.netdev_budget=600
net.core.busy_read=50
net.core.busy_poll=50

# Setup Buffer size
# tcp_mem : Page (4K) => 16777216 Pages = 64GB
# other : Byte => 16777216 Bytes = 16MB
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.optmem_max = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_mem = 16777216 16777216 16777216
net.ipv4.tcp_rmem = 16777216 16777216 16777216
net.ipv4.tcp_wmem = 16777216 16777216 16777216

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_fin_timeout = 7
net.ipv4.tcp_timestamps=1

# Google TCP fastopen => Fasten TCP 3-way handshake
net.ipv4.tcp_fastopen=3

kernel.numa_balancing=0

net.ipv4.tcp_tw_reuse = 1

#避免藍精靈攻擊
net.ipv4.icmp_echo_ignore_broadcasts = 1

#為錯誤的icmp錯誤消息打開保護
net.ipv4.icmp_ignore_bogus_error_responses = 1

# 打開並記錄欺騙,源路由和重定向數據包
net.ipv4.conf.all.log_martians = 1 
net.ipv4.conf.default.log_martians = 1

# 這裡沒有源路由包
net.ipv4.conf.all.accept_source_route = 0 
net.ipv4.conf.default.accept_source_route = 0

# 打開反向路徑過濾
net.ipv4.conf.all.rp_filter = 1 
net.ipv4.conf.default.rp_filter = 1


# 確保沒有人可以更改路由表
net.ipv4.conf.all.accept_redirects = 0 
net.ipv4.conf.default.accept_redirects = 0 
net.ipv4.conf.all.secure_redirects = 0 
net.ipv4.conf.default.secure_redirects = 0


# 不要充當路由器
net.ipv4.ip_forward = 0 
net.ipv4.conf.all.send_redirects = 0 
net.ipv4.conf.default.send_redirects = 0

# 打開execshild
# kernel.exec-shield = 1 
kernel.randomize_va_space = 1

# IPv6
net.ipv6.conf.default.router_solicitations = 0 
net.ipv6.conf.default.accept_ra_rtr_pref = 0 
net.ipv6.conf.default.accept_ra_pinfo = 0 
net.ipv6.conf.default.accept_ra_defrtr = 0 
net.ipv6.conf.default.autoconf = 0 
net.ipv6.conf.default.dad_transmits = 0 
net.ipv6.conf.default.max_addresses = 1
執行sysctl -p生效

Hadoop Name node is in safe mode.

hadoop dfsadmin -safemode leave

2020年1月17日 星期五

使用PowerShell的Windows 10系统的升级 Node.js, NPM

使用PowerShell的Windows 10系统的升级 Node.js, NPM

首先,确保您可以从PowerShell运行以下命令来在系统上执行脚本。要以管理员身份运行PowerShell,依次单击开始、搜索PowerShell、右键单击PowerShell,然后选择以管理员身份运行。

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force    

然后,要安装和使用这个升级工具,运行(也可以从PowerShell或cmd.exe):

npm install --global --production npm-windows-upgrade
npm-windows-upgrade

$ npm uninstall -g vue-cli
$ npm install -g @vue/cli