Skip to content

Zeroplex 生活隨筆

軟體開發、伺服器和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

將整台機器的記憶體給 Redis 使用時該調整的設定

Posted on 2022 年 2 月 16 日2022 年 8 月 30 日 By 日落 在〈將整台機器的記憶體給 Redis 使用時該調整的設定〉中有 4 則留言

塞個資料,沒想到 Redis 一直炸,看 log 才發現有設定要調整:

356416:C 15 Feb 2022 14:53:43.009 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
356416:C 15 Feb 2022 14:53:43.009 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=356416, just started
356416:C 15 Feb 2022 14:53:43.009 # Configuration loaded
356416:M 15 Feb 2022 14:53:43.010 * monotonic clock: POSIX clock_gettime
356416:M 15 Feb 2022 14:53:43.012 * Running mode=standalone, port=6379.
356416:M 15 Feb 2022 14:53:43.012 # Server initialized
356416:M 15 Feb 2022 14:53:43.012 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
356416:M 15 Feb 2022 14:53:43.017 * Loading RDB produced by version 6.2.6
356416:M 15 Feb 2022 14:53:43.017 * RDB age 1475 seconds
356416:M 15 Feb 2022 14:53:43.017 * RDB memory usage when created 5243.48 Mb
356416:signal-handler (1644908113) Received shutdown signal during loading, exiting now.
356427:C 15 Feb 2022 14:55:14.014 * Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.

注意到錯誤訊息中間有個關鍵字 vm.overcommit_memory,如果遇到 sysctl 或 vm 相關的,大多是與 Linux 系統參數有關係,這邊有 overcommit_memory 的設定說明,該設定會保護系統不會接受大型記憶體 allocate 的請求。

但 Redis 本來就是使用記憶體做服務,因此需要去 /etc/sysctl.conf 新增下面這段設定:

vm.overcommit_memory = 1

重新開機後即可套用設定。


另外 Redis 會在機器啟動時,從硬碟將 persistent data 載入記憶體中,若資料不少,載入會花掉相當的時間,因此 systemd 預設的設定,可能會誤以為 Redis 啟動失敗:

redis-server.service: start operation timed out. Terminating.

依據資料多寡,會影響 Redis 啟動的時間,所以需要調整 systemd 的 timeout。

開啟 /etc/systemd/system/redis.service 注意下面幾個 timeout 相關的參數:

TimeoutStartSec=300
TimeoutStopSec=300

參考 systemd 的文件,TimeoutStartSec=300 也可以改成可讀格式 TimeoutStartSec="5min"。


2022-02-18 更新:

感謝 JoeHorn 提醒,直接修改 /etc/systemd/ 底下的設定檔是有風險的,建議透過 systemctl edit xxx.service 的方式 override 預設參數值。

Tags:Linux, Redis

社群大小與活躍程度影響工具選擇

Posted on 2022 年 2 月 16 日2022 年 2 月 16 日 By 日落 在〈社群大小與活躍程度影響工具選擇〉中有 2 則留言

最近常需要決定專案到底要使用工具、平台來開發,結果常常會因為社群差異栽一腳。

像是:

  • 使用者數量不多,遇到的網路其他人沒遇過,只能自己 workaround
  • 活躍度不高,發現問題後,等問題修正大概幾個月就過去了
  • 喜歡自己創造新名詞,雖然說語言本來就是會隨著時間改變,當全世界只有那個工具這樣搞、又沒有說明時,就只能自己花時間瞎猜 (像是之前遇到天兵使用全形空白當分隔符號 …..)
Tags:生活雜記

用 Siege 替代 Apache Bench

Posted on 2022 年 2 月 14 日2022 年 2 月 14 日 By 日落 在〈用 Siege 替代 Apache Bench〉中尚無留言

查資料注意到 Apache Bench 並沒有 follow redirect 的功能,因此部分的測試可能會不準確。

文章中看到作者推薦了一個新的工具 – Siege,一個功能比 Apache Bench 更完整的 HTTP server 壓力測試工具,可以支援的功能也更齊全:

$ siege -C
CURRENT  SIEGE  CONFIGURATION
Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.0.4
Edit the resource file to change the settings.
----------------------------------------------
version:                        4.0.4
verbose:                        false
color:                          true
quiet:                          false
debug:                          false
protocol:                       HTTP/1.1
HTML parser:                    disabled
get method:                     HEAD
connection:                     close
concurrent users:               25
time to run:                    n/a
repetitions:                    n/a
socket timeout:                 30
cache enabled:                  false
.....

執行測試的範例:

$ siege -c 1 -r 100 'https://www.your.domain/'
** SIEGE 4.0.4
** Preparing 1 concurrent users for battle.
The server is now under siege...
Transactions:                    200 hits
Availability:                 100.00 %
Elapsed time:                  43.85 secs
Data transferred:               0.53 MB
Response time:                  0.22 secs
Transaction rate:               4.56 trans/sec
Throughput:                     0.01 MB/sec
Concurrency:                    1.00
Successful transactions:         200
Failed transactions:               0
Longest transaction:            0.58
Shortest transaction:           0.11
Tags:網路架站

手動更新 Office 365 的操作流程

Posted on 2022 年 2 月 14 日2022 年 2 月 14 日 By 日落 在〈手動更新 Office 365 的操作流程〉中尚無留言

Office 最近有重大安全性更新,我沒有讓 Office 365 和 Windows Update 綁一起,所以必須手動更新。手動更新的位置被放在很意外的地方:

(原始大小)
Tags:Windows

Ubuntu 上 LNMP 的 PPA

Posted on 2022 年 2 月 14 日2022 年 2 月 14 日 By 日落 在〈Ubuntu 上 LNMP 的 PPA〉中尚無留言

default packages 更新速度比較慢,所以後來都改用 3rd-party 的 PPA 來裝 LNMP 環境。

以 PHP 來說的話,主要會以 oerdnj 的 PPA 為主:https://launchpad.net/~ondrej/+archive/ubuntu/php

其他則是:

  • Nginx https://launchpad.net/~nginx/+archive/ubuntu/stable
  • Redis https://launchpad.net/~redislabs/+archive/ubuntu/redis

MySQL / Percona / MariaDB 更新、patch 速度沒那麼快的,則是直接使用預設的 packages 來安裝。

Tags:Linux, MySQL, Nginx, PHP, 網路架站

文章分頁

上一頁 1 ... 42 43 44 ... 318 下一頁

其他

關於我  (About me)

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Ubuntu Unix Vim Web Windows WordPress XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.