<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>devops on Tony Wu&#39;s Blog</title>
    <link>https://tonywu1995.github.io/categories/devops/</link>
    <description>Recent content in devops on Tony Wu&#39;s Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Sat, 08 Apr 2023 19:53:48 +0800</lastBuildDate><atom:link href="https://tonywu1995.github.io/categories/devops/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>MQTT Server - EMQP建立</title>
      <link>https://tonywu1995.github.io/devops/emqx/</link>
      <pubDate>Sat, 08 Apr 2023 19:53:48 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/devops/emqx/</guid>
      <description>前言 市面上MQTT Server 有很多種，例如: EMQX Mosquitto 這次我們透過docker來建立IOT傳輸用的MQTT Sever EMQX 步驟 建立一個新的folder，命名emqx 在emqx目錄底下，建立名為data資料夾，用來存放eqmx資料 在emqx目錄底下，建立docker-compose.yml docker-compose.yml 底下輸入 version: &amp;#39;3&amp;#39; services: emqx: image: emqx:5.0.20 container_name: emqx healthcheck: test: [&amp;#34;CMD&amp;#34;, &amp;#34;/opt/emqx/bin/emqx_ctl&amp;#34;, &amp;#34;status&amp;#34;] interval: 5s timeout: 25s retries: 5 ports: - 1883:1883 ## tcp - 8083:8083 ## websockeet - 8084:8084 ## websocket ssl - 8883:8883 ## ssl - 18083:18083 ## web volumes: - ./data:/opt/emqx/data 執行docker-compose up -d，即可啟動emqx 打開browser，在localhost:18083即可看到啟動好的emqx，如下圖 預設帳密為: admin/public 參考連結 EQMX </description>
    </item>
    
    <item>
      <title>Redis Exporter建立</title>
      <link>https://tonywu1995.github.io/prometheus/redis-exporter/</link>
      <pubDate>Mon, 31 Oct 2022 21:22:46 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/prometheus/redis-exporter/</guid>
      <description>前言 redis exporter是用來監控Redis一個Prometheus Client，提供相關redis的監控metrics 步驟 建立一個新的folder，命名redis 在redis目錄底下，建立docker-compose.yml docker-compose.yml 底下輸入 version: &amp;#39;3&amp;#39; services: redis: restart: always container_name: redis image: redis:6.2.7-alpine ports: - 6379:6379 redis-exporter: restart: always image: oliver006/redis_exporter:v1.45.0-alpine container_name: redis-exporter ports: - 9121:9121 command: - &amp;#39;--redis.addr=redis://redis-server:6379&amp;#39; 執行docker-compose up -d，redis服務與redis exporter即可啟動
確認redis exporter服務，已經在執行輸入curl http://localhost:9121/metrics
λ curl http://localhost:9121/metrics # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile=&amp;#34;0&amp;#34;} 0 go_gc_duration_seconds{quantile=&amp;#34;0.25&amp;#34;} 0 go_gc_duration_seconds{quantile=&amp;#34;0.5&amp;#34;} 0 go_gc_duration_seconds{quantile=&amp;#34;0.75&amp;#34;} 0 go_gc_duration_seconds{quantile=&amp;#34;1&amp;#34;} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist.</description>
    </item>
    
    <item>
      <title>Redis建立</title>
      <link>https://tonywu1995.github.io/redis/redis/</link>
      <pubDate>Sun, 30 Oct 2022 19:37:19 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/redis/redis/</guid>
      <description>介紹 Redis 是一個開源的in memory key value cache,常用來降低服務內的延遲情況
Redis 支援的data type
Strings Lists Sets Hash Sroted sets Streams Geospatial HyperLogLog Bitmaps Bitfields 現在讓我們開始安裝Redis
建立 Redis 建立一個新的folder，命名redis-server 在redis-server目錄底下，建立docker-compose.yml docker-compose.yml 底下輸入 version: &amp;#39;3&amp;#39; services: redis: restart: always container_name: redis image: redis:6.2.7-alpine ports: - 6379:6379 執行docker-compose up -d，redis服務即可啟動
確認redis服務，已經在執行
λ docker exec -it redis sh /data # redis-cli 127.0.0.1:6379&amp;gt; ping PONG 127.0.0.1:6379&amp;gt; exit /data # redis-cli ping PONG /data # 小結 redis 已經安裝完成，下一章節將會開始使用java連接redis 參考連結 Redis </description>
    </item>
    
    <item>
      <title>SSH_Tunnel</title>
      <link>https://tonywu1995.github.io/devops/ssh_tunnel/</link>
      <pubDate>Fri, 27 May 2022 22:59:35 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/devops/ssh_tunnel/</guid>
      <description>前言 使用到 SSH Tunnel 情境
這裡有一台Server，上面架設一個Postgres，因為公司資安的關係，並不對外開啟port:5432 我們目前在Local開發一個服務，需要連線到Server上的Postgres，不太可能每次改完程式，部署上去測試，這樣來回時間會拉很長
主要內容 ssh -L [local_ip]:[local_port]:[host_ip]:[host_port] username@host local_ip :本地ip位置，預設綁定本機 local_port:本地開啟port host_ip:遠端Server ip host_port:遠端要轉發port L: 建立Tunnel Example ssh -L 5432:localhost:5432 tony@123.456.789.10 參考連結 SSH Tunnel 突破防火牆限制 </description>
    </item>
    
    <item>
      <title>Node Exporter建立</title>
      <link>https://tonywu1995.github.io/prometheus/node-exporter/</link>
      <pubDate>Sun, 03 Oct 2021 16:25:57 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/prometheus/node-exporter/</guid>
      <description>前言 node exporter是用來監控Linux vm的一個Prometheus Client 提供: CPU 使用率、硬碟使用率&amp;hellip; metrics 步驟 安裝Node Exporter在Ubuntu20.04 #!/bin/bash version=&amp;#34;${VERSION:-1.2.2}&amp;#34; arch=&amp;#34;${ARCH:-linux-amd64}&amp;#34; bin_dir=&amp;#34;${BIN_DIR:-/usr/local/bin}&amp;#34; wget &amp;#34;https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.$arch.tar.gz&amp;#34; \ -O /tmp/node_exporter.tar.gz mkdir -p /tmp/node_exporter cd /tmp || { echo &amp;#34;ERROR! No /tmp found..&amp;#34;; exit 1; } tar xfz /tmp/node_exporter.tar.gz -C /tmp/node_exporter || { echo &amp;#34;ERROR! Extracting the node_exporter tar&amp;#34;; exit 1; } sudo cp &amp;#34;/tmp/node_exporter/node_exporter-$version.$arch/node_exporter&amp;#34; &amp;#34;$bin_dir&amp;#34; chown root:staff &amp;#34;$bin_dir/node_exporter&amp;#34; sudo cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/systemd/system/node_exporter.service [Unit] Description=Node Exporter After=network.target [Service] Type=simple ExecStart=/usr/local/bin/node_exporter [Install] WantedBy=multi-user.</description>
    </item>
    
    <item>
      <title>Spring Boot監控(中)</title>
      <link>https://tonywu1995.github.io/java/spring-boot-monitor-2/</link>
      <pubDate>Sun, 03 Oct 2021 16:25:57 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/java/spring-boot-monitor-2/</guid>
      <description>步驟 安裝Prometheus/Grafana 設定Prometheus設定向我們spring boot application位置 # my global configglobal:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.scrape_configs:# The job name is added as a label `job=&amp;lt;job_name&amp;gt;` to any timeseries scraped from this config.- job_name: &amp;#39;My-Spring-Boot-Application&amp;#39;# Override the global default and scrape targets from this job every 5 seconds.</description>
    </item>
    
    <item>
      <title>Spring Boot監控(上)</title>
      <link>https://tonywu1995.github.io/java/spring-boot-monitor-1/</link>
      <pubDate>Wed, 22 Sep 2021 22:47:52 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/java/spring-boot-monitor-1/</guid>
      <description>前言 常在河邊走那裡不失鞋，當一個後端工程師，常常會遇到上線Application server突然無法壞掉的問題，因此我們需要一個監控的Server來輔助我們上線的Application，本篇將使用Prometheus監控server當作範例來做為展示 步驟 Spring boot 安裝Prometheus Client 在pom.xml上新增兩個dependency spring-boot-starter-actuator: spring boot內建的監控library micrometer-registry-prometheus: 在spring boot上提供prometheus metrics格式 &amp;lt;dependency&amp;gt;&amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&amp;lt;artifactId&amp;gt;spring-boot-starter-actuator&amp;lt;/artifactId&amp;gt;&amp;lt;/dependency&amp;gt;&amp;lt;dependency&amp;gt;&amp;lt;groupId&amp;gt;io.micrometer&amp;lt;/groupId&amp;gt;&amp;lt;artifactId&amp;gt;micrometer-registry-prometheus&amp;lt;/artifactId&amp;gt;&amp;lt;/dependency&amp;gt; Spring boot 調整設定檔 在applcation.yml 新增下列設定 management:endpoint:health:show-details: alwaysprometheus:enabled: trueendpoints:web:exposure:include: prometheus,healthmetrics:tags:application: ${spring.application.name}health:diskspace:enabled: truedefaults:enabled: false 設定好，啟動spring boot即可在http://:/actuator/prometheus看到metrics 參考連結 Spring boot Spring boot Actuator Micrometer Registry Prometheus </description>
    </item>
    
    <item>
      <title>Ngork</title>
      <link>https://tonywu1995.github.io/devops/ngork/</link>
      <pubDate>Tue, 21 Sep 2021 17:06:57 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/devops/ngork/</guid>
      <description>介紹 在本機上開發的時候常常遇到需要https和domain name的狀況，例如:Line Bot的webhook測試，這時候使用ngrok就可以解決這個問題，ngork賦予你一個暫時domain name和https 安裝 Windows choco install ngrok Mac brew install ngrok 在本機上登入ngork(使用token認證) ngrok authtoken &amp;lt;token&amp;gt; 使用 ngrok http &amp;lt;Port&amp;gt; 參考連結 ngork </description>
    </item>
    
    <item>
      <title>Mongo備份與還原</title>
      <link>https://tonywu1995.github.io/mongo/mongo_backup_restore/</link>
      <pubDate>Tue, 21 Sep 2021 16:45:55 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/mongo/mongo_backup_restore/</guid>
      <description>介紹 在工作上不免要定期備份database的資料與還原datdabase的資料 備份步驟 連線進入mongo mongo -u &amp;lt;username&amp;gt; -p &amp;lt;password&amp;gt; 切換db use admin 磁碟同步與上鎖 db.runCommand({fsync:1,lock:1}) 確認是否上鎖 db.currentOp() 備份資料 mongodump --host &amp;lt;host-ip&amp;gt; --port 27017 --db &amp;lt;database&amp;gt; --authenticationDatabase admin --username &amp;lt;username&amp;gt; --password &amp;lt;password&amp;gt; --out &amp;lt;Path&amp;gt; 解鎖 db.fsyncUnlock() 還原步驟 還原 mongorestore --host &amp;lt;host-ip&amp;gt; --port 27017 --username &amp;lt;username&amp;gt; --password &amp;lt;password&amp;gt; --db &amp;lt;database&amp;gt; &amp;lt;backup file path&amp;gt; 參考連結 Mongo </description>
    </item>
    
    <item>
      <title>Sdkman</title>
      <link>https://tonywu1995.github.io/devops/skdman/</link>
      <pubDate>Tue, 21 Sep 2021 15:46:52 +0800</pubDate>
      
      <guid>https://tonywu1995.github.io/devops/skdman/</guid>
      <description>介紹 SDKMAN是一款基於Linux/Mac的SDK管理工具，可以管理多個版本JDK，也可以安裝與JDK相容的套件 安裝SDKMAN $ curl -s &amp;#34;https://get.sdkman.io&amp;#34; | bash$ source &amp;#34;$HOME/.sdkman/bin/sdkman-init.sh&amp;#34;sdk version&amp;gt; sdkman 5.0.0+51 羅列Java版本 sdk list java 安裝JAVA sdk install java x.y.z-open 移除 sdk uninstall java ... 指定預設JAVA sdk default java 11 參考連結 SDKMAN </description>
    </item>
    
  </channel>
</rss>
