Wiki » History » Version 4
Redmine Admin, 02/10/2026 04:56 PM
| 1 | 1 | Redmine Admin | 初期設定 |
|---|---|---|---|
| 2 | 1。MVMEの設定最適化 |
||
| 3 | これを行わないとハングアップする可能性がある |
||
| 4 | 2. |
||
| 5 | EEPROM更新 |
||
| 6 | sudo rpi-eeprom-update |
||
| 7 | sudo rpi-eeprom-update -a |
||
| 8 | sudo reboot |
||
| 9 | sudo apt install rpi-eeprom |
||
| 10 | sudo rpi-eeprom-update |
||
| 11 | sudo rpi-eeprom-update -a |
||
| 12 | sudo reboot |
||
| 13 | ブート順序確認 |
||
| 14 | vcgencmd bootloader_config |
||
| 15 | sudo -E rpi-eeprom-config --edit |
||
| 16 | [all] |
||
| 17 | BOOT_UART=1 |
||
| 18 | BOOT_ORDER=0xf416 |
||
| 19 | PCIE_PROBE=1 |
||
| 20 | NET_INSTALL_AT_POWER_ON=0 |
||
| 21 | にする |
||
| 22 | ② NVMe が認識されているか確認 |
||
| 23 | lsblk |
||
| 24 | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS |
||
| 25 | loop0 7:0 0 42.9M 1 loop /snap/snapd/24787 |
||
| 26 | loop1 7:1 0 41.6M 1 loop /snap/snapd/25939 |
||
| 27 | nvme0n1 259:0 0 476.9G 0 disk |
||
| 28 | ├─nvme0n1p1 259:1 0 512M 0 part /boot/firmware |
||
| 29 | └─nvme0n1p2 259:2 0 476.4G 0 part / |
||
| 30 | lspci | grep -i nvme |
||
| 31 | 0000:01:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (DRAM-less) (rev 01) |
||
| 32 | ③ Ubuntu 側の最適化 |
||
| 33 | sudo nano /etc/fstab |
||
| 34 | LABEL=writable / ext4 defaults 0 1 |
||
| 35 | LABEL=system-boot /boot/firmware vfat defaults 0 1 |
||
| 36 | 変更する |
||
| 37 | LABEL=writable / ext4 defaults,noatime,commit=60 0 1 |
||
| 38 | LABEL=system-boot /boot/firmware vfat defaults,noatime 0 0 |
||
| 39 | 書いた後 |
||
| 40 | sudo update-initramfs -u |
||
| 41 | sudo reboot |
||
| 42 | 再起動後確認 |
||
| 43 | mount | grep ' / ' |
||
| 44 | で下記表示 |
||
| 45 | /dev/nvme0n1p2 on / type ext4 (rw,noatime,commit=60) |
||
| 46 | |||
| 47 | I/O scheduler |
||
| 48 | cat /sys/block/nvme0n1/queue/scheduler |
||
| 49 | 下記表示 |
||
| 50 | [none] mq-deadline |
||
| 51 | |||
| 52 | swap(zram推奨) |
||
| 53 | sudo apt install zram-tools |
||
| 54 | |||
| 55 | 確認: |
||
| 56 | swapon --show |
||
| 57 | 表示 |
||
| 58 | NAME TYPE SIZE USED PRIO |
||
| 59 | /dev/zram0 partition 256M 0B 100 |
||
| 60 | ✔ initramfs 更新忘れ注意 |
||
| 61 | fstab 変更後: |
||
| 62 | sudo update-initramfs -u |
||
| 63 | |||
| 64 | 電源不足チェック |
||
| 65 | vcgencmd get_throttled |
||
| 66 | 下記表示でOK |
||
| 67 | throttled=0x0 |
||
| 68 | |||
| 69 | NVMEの状態確認 |
||
| 70 | ① NVMe が正しく認識されているか |
||
| 71 | lsblk |
||
| 72 | 下記表示 |
||
| 73 | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS |
||
| 74 | loop0 7:0 0 42.9M 1 loop /snap/snapd/24787 |
||
| 75 | loop1 7:1 0 41.6M 1 loop /snap/snapd/25939 |
||
| 76 | zram0 252:0 0 256M 0 disk [SWAP] |
||
| 77 | nvme0n1 259:0 0 476.9G 0 disk |
||
| 78 | ├─nvme0n1p1 259:1 0 512M 0 part /boot/firmware |
||
| 79 | └─nvme0n1p2 259:2 0 476.4G 0 part / |
||
| 80 | lsblk -f |
||
| 81 | NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS |
||
| 82 | loop0 |
||
| 83 | squash 4.0 0 100% /snap/snapd/24787 |
||
| 84 | loop1 |
||
| 85 | squash 4.0 0 100% /snap/snapd/25939 |
||
| 86 | zram0 |
||
| 87 | [SWAP] |
||
| 88 | nvme0n1 |
||
| 89 | |||
| 90 | ├─nvme0n1p1 |
||
| 91 | │ vfat FAT32 system-boot 8AA8-96C7 321.7M 36% /boot/firmware |
||
| 92 | └─nvme0n1p2 |
||
| 93 | ext4 1.0 writable 9276ecfd-6dd5-4e22-9a91-2afafd0a53a3 447.5G 1% / |
||
| 94 | |||
| 95 | ② PCIe / NVMe として認識されているか |
||
| 96 | lspci | grep -i nvme |
||
| 97 | 0000:01:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (DRAM-less) (rev 01) |
||
| 98 | |||
| 99 | ③ SMART(健康状態)確認【重要】 |
||
| 100 | sudo apt install nvme-cli |
||
| 101 | |||
| 102 | SMARTログ |
||
| 103 | sudo nvme smart-log /dev/nvme0 |
||
| 104 | Smart Log for NVME device:nvme0 namespace-id:ffffffff |
||
| 105 | critical_warning : 0 |
||
| 106 | temperature : 35 °C (308 K) |
||
| 107 | available_spare : 100% |
||
| 108 | available_spare_threshold : 10% |
||
| 109 | percentage_used : 0% |
||
| 110 | endurance group critical warning summary: 0 |
||
| 111 | Data Units Read : 15606 (7.99 GB) |
||
| 112 | Data Units Written : 23998 (12.29 GB) |
||
| 113 | host_read_commands : 352766 |
||
| 114 | host_write_commands : 327655 |
||
| 115 | controller_busy_time : 0 |
||
| 116 | power_cycles : 10 |
||
| 117 | power_on_hours : 0 |
||
| 118 | unsafe_shutdowns : 2 |
||
| 119 | media_errors : 0 |
||
| 120 | num_err_log_entries : 0 |
||
| 121 | Warning Temperature Time : 0 |
||
| 122 | Critical Composite Temperature Time : 0 |
||
| 123 | Temperature Sensor 1 : 35 °C (308 K) |
||
| 124 | Temperature Sensor 2 : 39 °C (312 K) |
||
| 125 | Thermal Management T1 Trans Count : 0 |
||
| 126 | Thermal Management T2 Trans Count : 0 |
||
| 127 | Thermal Management T1 Total Time : 0 |
||
| 128 | Thermal Management T2 Total Time : 0 |
||
| 129 | |||
| 130 | ⑦ I/O 状態(詰まり確認) |
||
| 131 | iostat -xm 1 |
||
| 132 | 2 | Redmine Admin | |
| 133 | ① 最低限の日本語化(文字が読めるようにする) |
||
| 134 | |||
| 135 | sudo apt update |
||
| 136 | sudo apt install language-pack-ja |
||
| 137 | |||
| 138 | locale |
||
| 139 | LANG=C.UTF-8 |
||
| 140 | LANGUAGE= |
||
| 141 | LC_CTYPE="C.UTF-8" |
||
| 142 | LC_NUMERIC="C.UTF-8" |
||
| 143 | LC_TIME="C.UTF-8" |
||
| 144 | LC_COLLATE="C.UTF-8" |
||
| 145 | LC_MONETARY="C.UTF-8" |
||
| 146 | LC_MESSAGES="C.UTF-8" |
||
| 147 | LC_PAPER="C.UTF-8" |
||
| 148 | LC_NAME="C.UTF-8" |
||
| 149 | LC_ADDRESS="C.UTF-8" |
||
| 150 | LC_TELEPHONE="C.UTF-8" |
||
| 151 | LC_MEASUREMENT="C.UTF-8" |
||
| 152 | LC_IDENTIFICATION="C.UTF-8" |
||
| 153 | LC_ALL= |
||
| 154 | |||
| 155 | sudo update-locale LANG=ja_JP.UTF-8 |
||
| 156 | |||
| 157 | ② 日本語フォントの導入(最重要) |
||
| 158 | sudo apt install \ |
||
| 159 | fonts-noto-cjk \ |
||
| 160 | fonts-ipafont \ |
||
| 161 | fonts-ipaexfont |
||
| 162 | |||
| 163 | フォント確認 |
||
| 164 | sudo apt install fontconfig |
||
| 165 | |||
| 166 | postgre16インストール |
||
| 167 | sudo apt update |
||
| 168 | sudo apt install curl ca-certificates -y |
||
| 169 | curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgsql.asc |
||
| 170 | echo "deb http://apt.postgresql.org/pub/repos/apt noble-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list |
||
| 171 | sudo apt update |
||
| 172 | sudo apt install postgresql-16 -y |
||
| 173 | sudo systemctl start postgresql |
||
| 174 | sudo systemctl status postgresql |
||
| 175 | |||
| 176 | postgresql.service - PostgreSQL RDBMS |
||
| 177 | Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; prese> |
||
| 178 | Active: active (exited) since Thu 2026-01-22 15:16:50 JST; 53s ago |
||
| 179 | Main PID: 3003 (code=exited, status=0/SUCCESS) |
||
| 180 | CPU: 1ms |
||
| 181 | |||
| 182 | 1月 22 15:16:50 TOYAMADC1 systemd[1]: Starting postgresql.service - PostgreSQL> |
||
| 183 | 1月 22 15:16:50 TOYAMADC1 systemd[1]: Finished postgresql.service - PostgreSQL> |
||
| 184 | lines 1-8/8 (END) |
||
| 185 | |||
| 186 | sudo -u postgres psql |
||
| 187 | CREATE USER toyamadcadmin WITH PASSWORD 'asahitoyama'; |
||
| 188 | CREATE DATABASE toyamadc_db OWNER toyamadcadmin ENCODING 'UTF8'; |
||
| 189 | GRANT ALL PRIVILEGES ON DATABASE toyamadc_db TO toyamadcadmin; |
||
| 190 | \q |
||
| 191 | sudo ufw allow 5432/tcp |
||
| 192 | sudo nano /etc/postgresql/16/main/postgresql.conf |
||
| 193 | listen_addresses = '*' |
||
| 194 | sudo nano /etc/postgresql/16/main/pg_hba.conf |
||
| 195 | host all all 0.0.0.0/0 md5 |
||
| 196 | sudo systemctl restart postgresql |
||
| 197 | |||
| 198 | NGINXインストール |
||
| 199 | |||
| 200 | NGINXインストール |
||
| 201 | sudo apt update |
||
| 202 | sudo apt install nginx -y |
||
| 203 | sudo systemctl start nginx |
||
| 204 | sudo systemctl enable nginx |
||
| 205 | sudo systemctl status nginx |
||
| 206 | |||
| 207 | ⭐【NGINX の設定ファイル位置】 |
||
| 208 | 内容 パス |
||
| 209 | メイン設定 /etc/nginx/nginx.conf |
||
| 210 | サイト設定 /etc/nginx/sites-available/ |
||
| 211 | 有効化されている設定 /etc/nginx/sites-enabled/ |
||
| 212 | |||
| 213 | ZABIX7.0 LTSインストール |
||
| 214 | sudo -s |
||
| 215 | wget https://repo.zabbix.com/zabbix/7.0/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb |
||
| 216 | dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb |
||
| 217 | apt update |
||
| 218 | apt install zabbix-server-pgsql zabbix-frontend-php php8.3-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent |
||
| 219 | sudo -u postgres createuser --pwprompt zabbix |
||
| 220 | password:asahitoyama |
||
| 221 | sudo -u postgres createdb -O zabbix zabbix |
||
| 222 | zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix |
||
| 223 | sudo nano /etc/zabbix/zabbix_server.conf |
||
| 224 | DBPassword=asahitoyama |
||
| 225 | sudo nano /etc/zabbix/nginx.conf |
||
| 226 | listen 8080; |
||
| 227 | server_name toyamadc.com; |
||
| 228 | systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm |
||
| 229 | systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm |
||
| 230 | sudo nano /etc/nginx/sites-available/zabbix |
||
| 231 | server { |
||
| 232 | listen 80; |
||
| 233 | server_name _; |
||
| 234 | |||
| 235 | root /usr/share/zabbix; |
||
| 236 | index index.php; |
||
| 237 | |||
| 238 | location = /favicon.ico { |
||
| 239 | log_not_found off; |
||
| 240 | } |
||
| 241 | |||
| 242 | location / { |
||
| 243 | # ここが 404 の原因になりやすい → index.php にフォールバック |
||
| 244 | try_files $uri $uri/ /index.php?$query_string; |
||
| 245 | } |
||
| 246 | |||
| 247 | location /assets { |
||
| 248 | access_log off; |
||
| 249 | expires 10d; |
||
| 250 | } |
||
| 251 | |||
| 252 | location ~ /\.ht { |
||
| 253 | deny all; |
||
| 254 | } |
||
| 255 | |||
| 256 | location ~ /(api\/|conf[^\.]|include|locale) { |
||
| 257 | deny all; |
||
| 258 | return 404; |
||
| 259 | } |
||
| 260 | |||
| 261 | location /vendor { |
||
| 262 | deny all; |
||
| 263 | return 404; |
||
| 264 | } |
||
| 265 | |||
| 266 | # PHP 実行部分(ソケットは /run/php 下に合わせる) |
||
| 267 | location ~ \.php$ { |
||
| 268 | include fastcgi_params; |
||
| 269 | fastcgi_pass unix:/run/php/zabbix.sock; |
||
| 270 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
||
| 271 | fastcgi_param DOCUMENT_ROOT $document_root; |
||
| 272 | |||
| 273 | fastcgi_intercept_errors on; |
||
| 274 | fastcgi_ignore_client_abort off; |
||
| 275 | fastcgi_connect_timeout 60; |
||
| 276 | fastcgi_send_timeout 180; |
||
| 277 | fastcgi_read_timeout 180; |
||
| 278 | fastcgi_buffer_size 128k; |
||
| 279 | fastcgi_buffers 4 256k; |
||
| 280 | fastcgi_busy_buffers_size 256k; |
||
| 281 | fastcgi_temp_file_write_size 256k; |
||
| 282 | } |
||
| 283 | } |
||
| 284 | 4 | Redmine Admin | #ZABBIXを起動して確認 |
| 285 | http://XXX.XXX.XXX.XXX:8080 |
||
| 286 | User Admin |
||
| 287 | Password Zabbix |
||
| 288 | 2 | Redmine Admin | |
| 289 | Django インストール |
||
| 290 | sudo apt update |
||
| 291 | sudo apt install python3-pip python3-venv python3-dev -y |
||
| 292 | mkdir ~/toyamadc |
||
| 293 | cd toyamadc |
||
| 294 | python3 -m venv .venv |
||
| 295 | source .venv/bin/activate |
||
| 296 | pip install --upgrade pip |
||
| 297 | pip install django |
||
| 298 | python -m django --version |
||
| 299 | django-admin startproject config . |
||
| 300 | sudo apt install libpq-dev -y |
||
| 301 | pip install psycopg2-binary |
||
| 302 | cd config |
||
| 303 | nano settings.py |
||
| 304 | DATABASES = { |
||
| 305 | 'default': { |
||
| 306 | 'ENGINE': 'django.db.backends.postgresql', |
||
| 307 | 'NAME': 'toyamadc_db', |
||
| 308 | 'USER': 'toyamadcadmin', |
||
| 309 | 'PASSWORD': 'asahitoyama', |
||
| 310 | 'HOST': '127.0.0.1', |
||
| 311 | 'PORT': '5432', |
||
| 312 | } |
||
| 313 | } |
||
| 314 | cd .. |
||
| 315 | python manage.py migrate |
||
| 316 | python manage.py createsuperuser |
||
| 317 | |||
| 318 | Username (leave blank to use 'toyamadc'): |
||
| 319 | Email address: admin@asahilogisatics.co.jp |
||
| 320 | Password: asahitoyama |
||
| 321 | Password (again): |
||
| 322 | Superuser created successfully. |
||
| 323 | |||
| 324 | pip install gunicorn |
||
| 325 | sudo nano /etc/systemd/system/gunicorn.service |
||
| 326 | [Unit] |
||
| 327 | Description=gunicorn daemon for Django |
||
| 328 | After=network.target |
||
| 329 | |||
| 330 | [Service] |
||
| 331 | User=toyamadc |
||
| 332 | Group=www-data |
||
| 333 | WorkingDirectory=/home/toyamadc |
||
| 334 | ExecStart=/home/toyamadc/.venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application |
||
| 335 | |||
| 336 | [Install] |
||
| 337 | WantedBy=multi-user.target |
||
| 338 | |||
| 339 | sudo nano /etc/nginx/sites-available/django |
||
| 340 | server { |
||
| 341 | listen 80 default_server; |
||
| 342 | server_name _; |
||
| 343 | |||
| 344 | # ========================== |
||
| 345 | # 1. Django (ルート "/") |
||
| 346 | # ========================== |
||
| 347 | location /static/ { |
||
| 348 | alias /home/toyamadc/static/; |
||
| 349 | } |
||
| 350 | |||
| 351 | location / { |
||
| 352 | include proxy_params; |
||
| 353 | proxy_pass http://unix:/run/gunicorn.sock; |
||
| 354 | } |
||
| 355 | |||
| 356 | # ========================== |
||
| 357 | # 2. Zabbix ("/zabbix" 以下) |
||
| 358 | # ========================== |
||
| 359 | |||
| 360 | # /zabbix/ → /usr/share/zabbix/index.php |
||
| 361 | location /zabbix { |
||
| 362 | root /usr/share; |
||
| 363 | index index.php; |
||
| 364 | } |
||
| 365 | |||
| 366 | # PHP 実行部分 |
||
| 367 | location ~ ^/zabbix/.+\.php$ { |
||
| 368 | root /usr/share; |
||
| 369 | fastcgi_pass unix:/run/php/zabbix.sock; |
||
| 370 | include fastcgi_params; |
||
| 371 | |||
| 372 | # ここがポイント:root と SCRIPT_FILENAME を揃える |
||
| 373 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
||
| 374 | fastcgi_param DOCUMENT_ROOT $document_root; |
||
| 375 | |||
| 376 | fastcgi_intercept_errors on; |
||
| 377 | fastcgi_ignore_client_abort off; |
||
| 378 | fastcgi_connect_timeout 60; |
||
| 379 | fastcgi_send_timeout 180; |
||
| 380 | fastcgi_read_timeout 180; |
||
| 381 | fastcgi_buffer_size 128k; |
||
| 382 | fastcgi_buffers 4 256k; |
||
| 383 | fastcgi_busy_buffers_size 256k; |
||
| 384 | fastcgi_temp_file_write_size 256k; |
||
| 385 | } |
||
| 386 | |||
| 387 | # 触らせたくないもの |
||
| 388 | location ~ ^/zabbix/(api\/|conf[^\.]|include|locale) { |
||
| 389 | deny all; |
||
| 390 | return 404; |
||
| 391 | } |
||
| 392 | |||
| 393 | location ~ ^/zabbix/vendor/ { |
||
| 394 | deny all; |
||
| 395 | return 404; |
||
| 396 | } |
||
| 397 | |||
| 398 | location ~ /\.ht { |
||
| 399 | deny all; |
||
| 400 | } |
||
| 401 | } |
||
| 402 | sudo ln -s /etc/nginx/sites-available/django /etc/nginx/sites-enabled/ |
||
| 403 | sudo nginx -t |
||
| 404 | |||
| 405 | 3 | Redmine Admin | .ssh/config |
| 406 | |||
| 407 | Host toyama-django |
||
| 408 | HostName 192.168.200.111 |
||
| 409 | User toyamadc |
||
| 410 | IdentityFile /Users/mizunuma/.ssh/id_ed25519 |
||
| 411 | IdentitiesOnly yes |
||
| 412 | PreferredAuthentications publickey |
||
| 413 | |||
| 414 | swap増加sudo rm /swapfile |
||
| 415 | sudo fallocate -l 8G /swapfile |
||
| 416 | sudo chmod 600 /swapfile |
||
| 417 | sudo mkswap /swapfile |
||
| 418 | sudo swapon /swapfile |
||
| 419 | sudo nano /etc/fstab |
||
| 420 | /swapfile none swap sw 0 0 |
||
| 421 | sudo swapoff -a |
||
| 422 | |||
| 423 | radiusインストール |
||
| 424 | sudo apt update |
||
| 425 | sudo apt upgrade -y |
||
| 426 | sudo apt install freeradius freeradius-utils -y |
||
| 427 | sudo systemctl enable freeradius |
||
| 428 | sudo systemctl start freeradius |
||
| 429 | sudo systemctl status freeradius |
||
| 430 | |||
| 431 | 証明書作成-> |
||
| 432 | |||
| 433 | sudo apt update |
||
| 434 | sudo apt install isc-dhcp-server -y |
||
| 435 | sudo nano /etc/default/isc-dhcp-server |
||
| 436 | NTERFACESv4="eth0" |
||
| 437 | INTERFACESv6="" |
||
| 438 | sudo nano /etc/dhcp/dhcpd.conf |
||
| 439 | option domain-name "local"; |
||
| 440 | option domain-name-servers 8.8.8.8, 1.1.1.1; |
||
| 441 | |||
| 442 | default-lease-time 600; |
||
| 443 | max-lease-time 7200; |
||
| 444 | |||
| 445 | authoritative; |
||
| 446 | |||
| 447 | subnet 192.168.10.0 netmask 255.255.255.0 { |
||
| 448 | range 192.168.10.100 192.168.10.200; |
||
| 449 | option routers 192.168.10.1; |
||
| 450 | option broadcast-address 192.168.10.255; |
||
| 451 | } |
||
| 452 | |||
| 453 | sudo nano /etc/netplan/00-installer-config.yaml |
||
| 454 | network: |
||
| 455 | version: 2 |
||
| 456 | ethernets: |
||
| 457 | eth0: |
||
| 458 | addresses: [192.168.10.1/24] |
||
| 459 | gateway4: 192.168.10.1 |
||
| 460 | nameservers: |
||
| 461 | addresses: [8.8.8.8,1.1.1.1] |
||
| 462 | |||
| 463 | sudo netplan apply |
||
| 464 | |||
| 465 | DHCP サーバを起動 |
||
| 466 | sudo systemctl restart isc-dhcp-server |
||
| 467 | sudo systemctl enable isc-dhcp-server |
||
| 468 | |||
| 469 | 状態確認: |
||
| 470 | sudo systemctl status isc-dhcp-server |
||
| 471 | |||
| 472 | エラーチェック |
||
| 473 | sudo journalctl -u isc-dhcp-server -f |