差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版 前次修改 | |||
tech:logsrv_docker [2025/05/07 09:31] – 參考網址 jonathan | tech:logsrv_docker [2025/05/09 02:21] (目前版本) – 將 log 目錄存放至另外一個硬碟 jonathan | ||
---|---|---|---|
行 45: | 行 45: | ||
</ | </ | ||
+ | ===== 將 log 目錄存放至另外一個硬碟 ===== | ||
+ | - 先在 host 加上一顆硬碟 Exp. sdb | ||
+ | - 將 sdb 建立為 lvm + ext4 < | ||
+ | * ++詳細處理畫面|< | ||
+ | syslog-30: | ||
+ | Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel | ||
+ | Building a new DOS disklabel. Changes will remain in memory only, | ||
+ | until you decide to write them. After that the previous content | ||
+ | won't be recoverable. | ||
+ | |||
+ | |||
+ | The number of cylinders for this disk is set to 13054. | ||
+ | There is nothing wrong with that, but this is larger than 1024, | ||
+ | and could in certain setups cause problems with: | ||
+ | 1) software that runs at boot time (e.g., old versions of LILO) | ||
+ | 2) booting and partitioning software from other OSs | ||
+ | | ||
+ | |||
+ | Command (m for help): p | ||
+ | Disk /dev/sdb: 100 GB, 107374182400 bytes, 209715200 sectors | ||
+ | 13054 cylinders, 255 heads, 63 sectors/ | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | |||
+ | Device | ||
+ | |||
+ | Command (m for help): n | ||
+ | Partition type | ||
+ | | ||
+ | | ||
+ | p | ||
+ | Partition number (1-4): 1 | ||
+ | First sector (63-209715199, | ||
+ | Using default value 63 | ||
+ | Last sector or +size{, | ||
+ | Using default value 209715199 | ||
+ | |||
+ | Command (m for help): t | ||
+ | Selected partition 1 | ||
+ | Hex code (type L to list codes): 8e | ||
+ | Changed system type of partition 1 to 8e (Linux LVM) | ||
+ | |||
+ | Command (m for help): p | ||
+ | Disk /dev/sdb: 100 GB, 107374182400 bytes, 209715200 sectors | ||
+ | 13054 cylinders, 255 heads, 63 sectors/ | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | |||
+ | Device | ||
+ | / | ||
+ | |||
+ | Command (m for help): w | ||
+ | The partition table has been altered. | ||
+ | Calling ioctl() to re-read partition table | ||
+ | </ | ||
+ | - 參考 [[/ | ||
+ | pvcreate /dev/sdb1 | ||
+ | vgcreate vglogdata /dev/sdb1 | ||
+ | lvcreate -l +100%FREE -nlogdata vglogdata | ||
+ | mkfs.ext4 / | ||
+ | </ | ||
+ | * ++詳細處理畫面|< | ||
+ | syslog-30: | ||
+ | Physical volume "/ | ||
+ | syslog-30: | ||
+ | Volume group " | ||
+ | syslog-30: | ||
+ | Logical volume " | ||
+ | syslog-30: | ||
+ | mke2fs 1.47.1 (20-May-2024) | ||
+ | Discarding device blocks: done | ||
+ | Creating filesystem with 26213376 4k blocks and 6553600 inodes | ||
+ | Filesystem UUID: d89e5e2c-fb17-46d9-96be-f3a537662b1a | ||
+ | Superblock backups stored on blocks: | ||
+ | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
+ | 4096000, 7962624, 11239424, 20480000, 23887872 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (131072 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | |||
+ | </ | ||
+ | - 掛上路徑 Exp. /logdata <cli> | ||
+ | mkdir -p /logdata | ||
+ | chown 1000:1000 /logdata | ||
+ | vi /etc/fstab | ||
+ | </ | ||
+ | : | ||
+ | / | ||
+ | </ | ||
+ | mount /logdata | ||
+ | df -h | ||
+ | </ | ||
+ | - 修改 docker-compose.yml 內容 <cli> | ||
+ | vi docker-compose.yml | ||
+ | </ | ||
+ | : | ||
+ | volumes: | ||
+ | - ./ | ||
+ | - / | ||
+ | : | ||
+ | </ | ||
+ | docker compose down | ||
+ | </ | ||
+ | - 將原本 log 檔搬移到 /logdata <cli> | ||
+ | cp -a ./log/* /logdata/ | ||
+ | ln -s /logdata . | ||
+ | </ | ||
+ | - 重新啟動 syslog-ng <cli> | ||
+ | docker compose up -d | ||
+ | </ | ||
===== 參考網址 ===== | ===== 參考網址 ===== | ||
* https:// | * https:// |