paulwong

          #

          如何找出LINUX中消耗CPU最大的應用的PID

          有時查看LINUX時,會發現當前CPU消耗連續保持80%,如何找出是哪個應用呢?
          top -i //輸出應用列表,并隱藏IDEL的應用
          P //在列表時,按P,則按CPU的使用排序


          How To Check CPU Utilization In Linux With Command Line
          https://phoenixnap.com/kb/check-cpu-usage-load-linux

          posted @ 2020-08-14 11:52 paulwong 閱讀(328) | 評論 (0)編輯 收藏

          CompletableFuture

          很久以前多線程是這樣創建:
          Thread t1 = new Thread();
          Thread t2 = new Thread();
          t1.start(); // 啟動新線程
          t2.start(); // 啟動新線程

          由于創建和銷毀線程是非常耗資源,因此改成線程建好后不銷毀,可以重用,用戶只需提供run方法的具體實現:
          public static void main(String[] args) throws Exception {
                  ExecutorService executor = Executors.newSingleThreadExecutor();
                  Future<String> stringFuture = executor.submit(new Callable<String>() {
                      @Override
                      public String call() throws Exception {
                          Thread.sleep(2000);
                          return "async thread";
                      }
                  });
                  Thread.sleep(1000);
                  System.out.println("main thread");
                  System.out.println(stringFuture.get());

              }

          但如果很多線程被創建,并且線程間有依賴,即按流程和條件執行線程,實現起來就有點復雜,于是CompletableFuture橫空出世。一共有50各方法可供使用。
          CompletableFuture.supplyAsync(),相當于創建了ExecutorService,同時也創建了Callable,然后提交到線程池中執行。
          CompletableFuture<String> futureA = CompletableFuture.supplyAsync(() -> "任務A");
          CompletableFuture<String> futureB = CompletableFuture.supplyAsync(() -> "任務B");
          CompletableFuture<String> futureC = futureB.thenApply(b -> {
                System.out.println("執行任務C.");
                System.out.println("參數:" + b);//參數:任務B
                return "a";
          });


          !!How to use CompletableFuture and Callable in Java
          https://ducmanhphan.github.io/2020-02-10-How-to-use-CompletableFuture-Callable-in-Java/

          使用CompletableFuture優化你的代碼執行效率
          https://www.cnblogs.com/fingerboy/p/9948736.html

          CompletableFuture 使用詳解
          https://www.jianshu.com/p/6bac52527ca4

          使用CompletableFuture
          https://www.liaoxuefeng.com/wiki/1252599548343744/1306581182447650


          https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java

          posted @ 2020-08-14 11:46 paulwong 閱讀(306) | 評論 (0)編輯 收藏

          Springboot+proguard+maven 混淆

          https://blog.csdn.net/qq_35981283/article/details/78529929

          posted @ 2020-08-13 10:53 paulwong 閱讀(920) | 評論 (0)編輯 收藏

          MYSQL經典配置

          /etc/my.cnf

          [mysqld]
          datadir=/var/lib/mysql
          socket=/var/lib/mysql/mysql.sock
          #symbolic-links=0

          #vish start
          open_files_limit = 8000
          max_connections = 500
          #set-variable=max_connections=500
          thread_concurrency = 8
          #concurrent_insert=2
          thread_cache_size=2000

          interactive_timeout=180
          wait_timeout=180

          max_allowed_packet = 32M
          key_buffer_size = 3000M
          read_buffer_size = 16M
          read_rnd_buffer_size = 4M
          bulk_insert_buffer_size = 256M
          myisam_sort_buffer_size = 16M
          myisam_max_sort_file_size = 256M
          myisam_repair_threads = 1
          #myisam_recover = 4
          max_heap_table_size = 2048M
          tmp_table_size = 1024M
          table_open_cache = 2000
          table_cache = 2000
          sort_buffer_size = 128M 
          join_buffer_size = 128M 
          query_cache_size = 128M 
          query_cache_limit = 128M 

          #slow_query_log=1
          log-slow-queries
          long_query_time=2
          #log_queries_not_using_indexes=1
          slow_query_log_file = /var/log/mariadb/host_name-slow.log

          [mysqldump]
          user=root
          password=*********
          #max_allowed_packet = 1024M 

          [myisamchk] 
          key_buffer_size = 2500M 
          sort_buffer_size = 1024M 
          read_buffer = 32M
          write_buffer = 32M

          [innodb]
          innodb_buffer_pool_size=3G
          innodb_buffer_pool_instance=2
          innodb_additional_mem_pool_size=20M
          innodb_log_file_size= 512M
          innodb_log_buffer_size=16M
          innodb_flush_log_at_trx_commit=1
          innodb_thread_concurrency=16
          #innodb_read_io_threads=16
          #innodb_write_io_threads=16
          #innodb_io_capacity=2000
          #innodb_lock_wait_timeout=120

          innodb_flush_method=O_DIRECT
          #vish end

          [mysqld_safe]
          log-error=/var/log/mariadb/mariadb.log
          pid-file=/var/run/mariadb/mariadb.pid
          #!includedir /etc/my.cnf.d

          posted @ 2020-08-07 18:01 paulwong 閱讀(302) | 評論 (0)編輯 收藏

          shell 腳本替換文件中某個字符串

          1、將當前目錄下包含jack串的文件中,jack字符串替換為tom
          sed -i "s/jack/tom/g" `grep "jack" -rl ./`

          2、將某個文件中的jack字符串替換為tom

          sed -i "s/jack/tom/g" test.txt

          參考連接:http://blog.csdn.net/lizhi200404520/article/details/7968483

          posted @ 2020-08-07 18:01 paulwong 閱讀(3081) | 評論 (0)編輯 收藏

          JMETER連接數據庫做壓力測試

          JMETER作為一個壓力測試工具,可模擬上千用戶進行登錄之類的操作。
          但一般圖形界面只用來制作測試計劃,真正運行是在LINUX上。
          同時也可以作為壓測MYSQL數據庫等。

          配置基本流程:添加測試計劃-->添加線程組,在添加的線程組中-->添加JDBC配置組件-->添加JDBC訪問的SQL語句的REQUEST組件-->配置REQUEST和配置組件相關聯的變量值-->添加查看結果組件-->設定要運行的線程數-->執行。

          執行期間如有問題,查看DOS窗口。

          【JMeter】JMeter完成一個MySql壓力測試
          https://www.cnblogs.com/zhaoxd07/p/4895681.html

          JMeter 如何與 MySQL 進行整合測試
          https://juejin.im/post/6844903728215162887

          JMeter JDBC連接MySql配置
          https://www.jianshu.com/p/cde2729421d1

          jmeter(二十五)linux環境運行jmeter并生成報告
          https://www.cnblogs.com/imyalost/p/9808079.html

          posted @ 2020-08-07 17:59 paulwong 閱讀(351) | 評論 (0)編輯 收藏

          TCL 的連接TIME_WAIT太多的處理

          TCP TIME_WAIT 詳解
          https://www.zhuxiaodong.net/2018/tcp-time-wait-instruction/

          mysql服務器,大量tcp連接狀態TIME_WAIT
          https://www.cnblogs.com/zhjh256/p/6363312.html

          linux下釋放TIME_WAIT方法
          https://blog.csdn.net/u013488847/article/details/46421867

          posted @ 2020-08-07 10:27 paulwong 閱讀(339) | 評論 (0)編輯 收藏

          Different ways to create objects in Java

          https://www.geeksforgeeks.org/different-ways-create-objects-java/


          posted @ 2020-08-07 10:04 paulwong 閱讀(248) | 評論 (0)編輯 收藏

          RHEL\CentOS 7 下 MySQL 連接數被限制為214個

          MARIADB的默認最大連接數是100,當試圖更改配置文件/etc/my.conf追加max_connections=1000,并重啟服務時,發現最大連接數被重置為214,這是由于系統問題,open_files數為1024,如何正確地更改是個復雜的問題。

          MARIADB中一些查當前連接數/最大連接數的命令為:

          MariaDB [(none)]
          show variables like "max_connections";
          show processlist;
          show status where variable_name = 'threads_connected';
          show status where variable_name = 'max_used_connections';
          show variables like 'max_user_connections';
          show variables like '%connection%';

          正確方案:
          RHEL\CentOS 7 下 MySQL 連接數被限制為214個
          https://waylau.com/rhel-mysql-connections-limit-214/

          Centos7.4下面mysql的max_connections不生效的問題。
          https://blog.51cto.com/wangqh/2131340

          為何要在SERVICE中添加允許打開的文件數?
          Centos7下修改/etc/security/limits.conf文件只在用戶登錄后打開的進程有效,系統服務或通過rc.local啟動的無效,系統服務修改文件/usr/lib/systemd/system/SOME_SERVICE.service添加:
          [Service]
          LimitNOFILE=65535


          關于LINUX系統的最大打開文件數:
          https://blog.51cto.com/as007012/1956222

          https://www.haiyun.me/archives/linux-file-limit.html

          posted @ 2020-08-05 20:55 paulwong 閱讀(390) | 評論 (0)編輯 收藏

          統計文件行數或LIST目錄的條數

          https://www.thegeekdiary.com/how-to-count-lines-in-a-file-in-unix-linux/

          posted @ 2020-08-05 11:32 paulwong 閱讀(316) | 評論 (0)編輯 收藏

          僅列出標題
          共115頁: First 上一頁 15 16 17 18 19 20 21 22 23 下一頁 Last 
          主站蜘蛛池模板: 盖州市| 临颍县| 东港市| 邯郸市| 凯里市| 铜山县| 永定县| 大连市| 绥德县| 邯郸市| 虹口区| 鄂托克前旗| 北宁市| 绍兴市| 中阳县| 启东市| 满城县| 隆尧县| 寻甸| 柞水县| 澄江县| 齐河县| 长岭县| 镇原县| 丰城市| 泾源县| 常德市| 将乐县| 循化| 化隆| 汝南县| 报价| 宿州市| 武功县| 石林| 土默特左旗| 南雄市| 浪卡子县| 星座| 商南县| 洛南县|