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