LVMでWARNINGが消えない時


サブホストのバックアップサーバーにあるバックアップ用の2TBのSSDがお亡くなりなった。(メーカーは Fanxiang)なので、SSDを買い、一通りの設定が終わり、サーバーは正常に戻ったが、lvscanでエラーが出る
# lvscan
前略
WARNING: Couldn’t find device with uuid vsZVRp-k7ZT-LnIB-ERqo-Quab-jLVL-wlJI1r.
WARNING: Couldn’t find device with uuid 7SSlBe-KJ2r-bDyZ-DVz7-mUKU-wTxf-W9wq5c.
WARNING: VG Restore7 is missing PV vsZVRp-k7ZT-LnIB-ERqo-Quab-jLVL-wlJI1r (last written to [unknown]).
WARNING: VG Restore7 is missing PV 7SSlBe-KJ2r-bDyZ-DVz7-mUKU-wTxf-W9wq5c (last written to /dev/sdd5).
後略
これは死んだSSDの記録が残っている為だ。(本来はSSDを外す前に lvremove 等をやらないといけないが、忘れた)なので、これを消す
# vgreduce –removemissing Restore7  最後はVG名、ハイフォンは二つだよ
前略
Wrote out consistent volume group Restore7.
と表示され、lvscanでエラーが出なくなった。

後日談:壊れた(と思った)2TBのSSDを後日、まったく別のホストに付けると何と正常に動作した!! 以前のホストで再起動やらをやってもダメ出し、xfs_repair だとディスクはビジーだと言われ、補修できなかったんだけど。暑さのせい??

 

カテゴリー: その他 | コメントする

どうしてもデーターベースに保存できないカラムがある

これには随分手を焼いた。
原因は cotrollerにある
def tour_params
 params.require(:tour).permit(
  :s_no, :ref_no, :inp_icg, :agt_code, :agt_name, :agt_icg, :arr, :dep,
  :night, :flight, :htl_code, :tour, :no_pax,:meal, :pax_type, :rooming, :book_date,   :unit_price,
  :usd_total, :tts, :jpy_ttl, :net, :received, :invoice_date,:name, :room_type,   :remarks, :conf_no,
  :look, :jtb_ac, :course_no, :cancel_flag, :xxl_date
 )
end
カンマとセミコロン(, ;)の間にあるスペースが全角のスペースになっている所が有った。すべて半角スペースにすると解決した。
なので他にも有る可能性が有るので全角スペースをチェックする事にした。まずはripgrepをインストールする
$ sudo dnf install ripgrep
で、railsのhomeに行き
$ rg -n –pcre2 ‘\x{3000}’
これで全角スペースがある所を表示してくれる
app/views/agents/index.html.erb
5:<h1>Agents     <%= link_to “New agent”, new_agent_path %></h1>
など、私はAgentsと New agentの間を開けたかったので、わざと全角スペースをいれてある(半角だと一つしか入れてくれない)

 

カテゴリー: Rails 初心者の犯したエラー | コメントする

undefined method `total_pages’ for nil:NilClass

gemでkaminariを追記し、bundleなどを行い設定を入れたが、どうしても上のエラーが出る。随分設定を見直したが原因が分からず。
原因:index.html.erbの最後に記入した <%= paginate @hotels %> のホテルの所が大文字の @Hotels になっていた。これも初歩的ミス!

未だに、railsの設定ヨリも規約、のこの規約が理解出来ていない。
hotel hotels Hotel Hotels @hotels @hotel これらの違いをしっかり理解せねば!

カテゴリー: Rails 初心者の犯したエラー | コメントする

Gem もろもろ

* インストールされているか調べる
$ bunde list |grep  調べたいgem

* gemを削除する
$ bundle exec gem uninstall 削除したいgem

カテゴリー: Ruby on railsに挑戦(almalinux9) | コメントする

13:WEBサーバーをapacheにする

現時点ではdevelopment modeだが、production mode ではapacheを使うつもりだ。ただ作っているアプリのカラムが30以上もあり、WEBの表示を画面全体で見たいので、先にapacheで見れるようにするために gemのpassengerを入れて、apacheで表示出きるようにする。(注:railsアプリの公開は社内だけにし、テレワークの社員はVPNで社内ネットワークに入り、ローカルIPアドレス:3000でアクセス出来るようにするので、暗号化はしていない)まずはGemfile にpassengerを入れる
[fuji@rails8 TourData]$ gedit Gemfile
前略
# gem “image_processing”, “~> 1.2”
gem “spring-commands-rspec”
gem “passenger”     ← これを追記

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem “debug”, platforms: %i[ mri windows ], require: “debug/prelude”
後略
で、お決まりの
[fuji@rails8 TourData]$ bundle
apacheにpassengerをインストールするがその前にhomeデレクトリーを第三者が実行出来るようにしておく。
[fuji@rails8 TourData]$ chmod o+x/home/fuji
[fuji@rails8 TourData]$ passenger-install-apache2-modules


This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort. Enterをオス
Which languages are you interested in?

Use <space> to select.
If the menu doesn't display correctly, press '!'

 ‣ ⬢  Ruby     Rubyに三角が付いているのを確認後 Enter
   ⬡  Python
   ⬢  Node.js

色々足りないものが表示されたが記録が無くなっているので、何が不足していたかは思い出せないが、ともかくyum install …….などと言ってくれるのでその通りにインストールし、再度
[fuji@rails8 TourData]$ passenger-install-apache2-modules
で、最後の方で
Almost there!
Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /home/fuji/.rbenv/versions/3.2.9/lib/ruby/gems/3.2.0/gems/passenger-6.0.27/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
 PassengerRoot /home/fuji/.rbenv/versions/3.2.9/lib/ruby/gems/3.2.0/gems/passenger-6.0.27
 PassengerDefaultRuby /home/fuji/.rbenv/versions/3.2.9/bin/ruby
</IfModule>

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing.

——————————————–
Validating installation…
* Checking whether this Passenger install is in PATH… ✓
* Checking whether there are no other Passenger installations… ✓
* Checking whether Apache is installed… ✓
* Checking whether the Passenger module is correctly configured in Apache… (!)

You did not specify ‘LoadModule passenger_module’ in any of your Apache
configuration files. Please paste the configuration snippet that this
installer printed earlier, into one of your Apache configuration files, such
as /etc/httpd/conf/httpd.conf.

Detected 0 error(s), 1 warning(s).
Press ENTER to continue.

——————————————–
Deploying a web application

To learn how to deploy a web app on Passenger, please follow the deployment
guide:

https://www.phusionpassenger.com/library/deploy/apache/deploy/

Enjoy Phusion Passenger, a product of Phusion® (www.phusion.nl) 🙂
https://www.phusionpassenger.com

Passenger® is a registered trademark of Asynchronous B.V.

Checking whether the Passenger module is correctly configured in Apache… (!) だけがエラーになっている。当たり前だ、インストールしただけなので設定は終わっていない。
まずはpassenger module をロードするがこれは
[root@rails8 ~]# gedit /etc/httpd/conf.modules.d/00-rails.conf
LoadModule passenger_module /home/fuji/.rbenv/versions/3.2.9/lib/ruby/gems/3.2.0/gems/passenger-6.0.27/buildout/apache2/mod_passenger.so
PassengerEnabled on
<IfModule mod_passenger.c>
 PassengerRoot /home/fuji/.rbenv/versions/3.2.9/lib/ruby/gems/3.2.0/gems/passenger-6.0.27
 PassengerDefaultRuby /home/fuji/.rbenv/versions/3.2.9/bin/ruby
</IfModule>
と設定を新規に作った。次はdocument rootなどの設定だが、これは新規に
[root@rails8 ~]# gedit /etc/httpd/conf.d/rails.conf
DocumentRoot “/Rails/TourData/public”

<Directory “/Rails/TourData/public”>
 AllowOverride None
 # Allow open access:
 Require all granted
</Directory>
そしてapacheを再起動
[root@rails8 ~]# systemctl restart httpd
[root@rails8 ~]# systemctl status httpd
で起動を確認
次にpassengerの起動
[fuji@rails8 TourData]$ passenger start –environment development
でpassengerはスタートしたが、その端末に
Started GET “/metrics” for 127.0.0.1 at 2025-08-30 16:49:25 +0900
ActionController::RoutingError (No route matches [GET] “/metrics”):
でもブラウザで http://IP アドレス:3000にアクセスするとapacheでアクセス出来る

カテゴリー: Ruby on railsに挑戦(almalinux9) | コメントする

12:ツアーデーターを作る

先走って、ログインから作ったが、本当はこっちを先に作るべきだった。
[fuji@rails8 TourData]$ rails g scaffold Tour ref_no:string conf_no:string agt_name:string look:string jtb_ac:string course_no:string flight:string arr:date dep:date hotel:string name:text no_pax:integer room_type:text meal:string night:integer remarks:text pax_type:string rooming:string unit_price:float usd_total:float tts_date:date tts:float jpy_ttl:integer net:float received:date book_date:date invoice_date:date s_no:integer inp_icg:string agt_code:string agt_icg:string htl_code:string
記入途中

カテゴリー: Ruby on railsに挑戦(almalinux9) | コメントする

CentOS 7 運用時の色んなメモ

apache 設定チェック : apachectl configtest
apache ロードされているmoduleを表示:httpd -M

postfix 設定チェック : postfix check
postfix 設定表示         : postconf   変更した部分のみの表示:postconf -n

dovecot設定表示        :doveconf -n
                                   問題無ければ、デフォルトと異なる設定だけが出力されます。
                                   設定項目名にミスがあれば、エラーが表示されます。
                                   但し、設定項目の内容のチェックまではされないようです。
                                  設定項目があっていれば、指定したファイルが存在しなくてもエラーにはなりません。
spamassasin 設定チェック : spamassassin –lint  (– は見にくいが: ハイフォンが二つ)

sambaマウント: mount.cifs -o username=moriyama,password=xxxxx (記号は\をつける) //192.168.xx.xx/it /IT

ddの進捗情報 :dd status=progress if=xxxx…… of=xxxx…..
ネットワーク越しのdd(ローカルからローカル):コピー先のホストで
nc -l 12345 | dd of=/dev/Kvm/web5
12345は両ホストで使用していないポートなら何でもいい。
コピー元のホストに移って
dd status=progress if=/dev/Kvm/web4 | nc 192.168.xx.xx 12345
IPはコピー先のIP、最後の数字はポートNoで

ネットワーク越しのdd(リモートからローカル):ssh -p xxx username@ip or domain sudo dd status=progress  if=/dev/xxx…. |dd of=/dev/xxx….
defaultのポートなら -p xxxはいらない。dd を sudo でパスワードなしでやるには visudo で設定が必用(参照:https://qiita.com/RyodoTanaka/items/e9b15d579d17651650b7

rsync       : rsync -av –exclude-from=/root/exclude1 –password-file=/etc/rsync.passwd rsync://root@192.168.xx.xx/webdata /webdata
      dry-runは -n
      外からは:rsync -av -e ‘ssh -p xxx -i .ssh/id_rsa’ –exclude-from=/root/exclude1 –password-file=/etc/rsync.passwd rsync://root@グローバルIP/webdata /webdata

letsencrypt で cert file を更新したらDRBDのSECONDARYにも設定が必要
初めて行う時は /etc/rsyncd.conf に追記が必要
[letsencrypt]
path = /etc/letsencrypt
authusers = root
secrets file = /etc/rsyncd.secrets
read only =no
追記したらrsyncdを再起動して設定を有効にする。
# systemctl restart rsyncd
そしてコピー
# rsync -av –exclude-from=/root/exclude1 –password-file=/etc/rsyncd.passwd rsync://root@192.168.0.55/letsencrypt /test3
で /test3に出来た必要なファイルを /etc/letsencrypt にコピー
letsebcrypt でcertificatesで有効期限を表示
# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Found the following certs:
Certificate Name: aarah.info-0001
Serial Number: 4dd777ec388a651d72423d6df2c9ae24460
Key Type: RSA
Domains: aarah.info inpac.jp inpactours.jp kinryo.net opengarden.info www.aarah.info www.inpac.jp www.inpactours.jp www.kinryo.net www.opengarden.info
Expiry Date: 2023-04-12 07:32:50+00:00 (VALID: 78 days)
Certificate Path: /etc/letsencrypt/live/aarah.info-0001/fullchain.pem
Private Key Path: /etc/letsencrypt/live/aarah.info-0001/privkey.pem
Certificate Name: kinryokai.net
Serial Number: 4040193692d1e64b9ec8639985a7943a43f
Key Type: RSA
Domains: kinryokai.net mail.kinryokai.net www.kinryokai.net
Expiry Date: 2023-04-12 07:33:20+00:00 (VALID: 78 days)
Certificate Path: /etc/letsencrypt/live/kinryokai.net/fullchain.pem
Private Key Path: /etc/letsencrypt/live/kinryokai.net/privkey.pem
Certificate Name: mail.kinryo.net
Serial Number: 32edf706664cd2ce65b156a10cbedd55168
Key Type: RSA
Domains: mail.kinryo.net
Expiry Date: 2023-03-21 08:17:31+00:00 (VALID: 56 days)
Certificate Path: /etc/letsencrypt/live/mail.kinryo.net/fullchain.pem
Private Key Path: /etc/letsencrypt/live/mail.kinryo.net/privkey.pem

vsftp 設定チェック :  vsftpd /etc/vsftpd/vsftpd.conf

ポート指定の疎通確認  :
LINUX:  nc -vz ドメイン(IP)ポート番号
Winows powershallから: test-netcpnnection IPアドレス -port ポート番号

ssh接続               :ssh -i 秘密鍵のパス リモートユーザー@リモートサーバーのホスト名

空ポートの確認 :ss -nat 又は-nau   # t=tcp, u=udp

virbr0の停止
    # virsh net-destroy default,   再起動後も止める:# virsh net-autostart default –disable
    Almalinux 8以上  # systemctl disable libvirtd 但し仮想化が動いていれば出来無いので上の行の様にして止める
 

mail.kinryokai.netだけのcertbot 更新  : certbot certonly –webroot -w /webdata/public/kinryokai -d  mail.kinryokai.net

bacula conf のチェック    https://www.kinryo.net/?p=2510

samba mount    mount.cifs //192.168.xx.xx/yyyy /zzz -o user=name

SSH経由でVNC(CentOS7)
  まずSSHで接続:# ssh -p ポート番号 ユーザ@IP かドメイン -L 12345(このポートは任意):IP かドメイン: サーバのVNCポート
  新しいターミナルを開け
  # vncviewer
  ウィンドウが開くので、localhost:12345

lvextend で領域を増やしたら(xfsの場合)
  sudo xfs_growfs マウントポイント(xfsはマウントしたまま出来る)で領域を増やす

ポートが空いているか調べる
  $ netstat -an |grep ポート番号
  このポートを閉じる時
  $ lsof -i:ポート番号     PIDの番号がいる
  $ kill PIDの番号

grep -A オプション
  直後の3行が表示され
  ABCD 検索した文字
  EFG
  HI
  JKL

php-fpm の再起動
       私はphp56とphp74をインストールしているので、
       # systemctl restart php56-php-fpm
       # systemctl restart php74-php-fpm

wordpressをブラウザからアップデート(FTP不使用)
  wp-config.php のdefine(‘WP_DEBUG’,false); の次に
  define(‘FS_METHOD’,’direct’); を追記

mariadb IDを10,000からスターとする
  ALTER TABEL テーブル名 AUTO_INREMENT=10000;

カテゴリー: Linux運用時のメモ | コメントする

mariadbでdateのカラムにnullを認める mariadb Ver 15.1 Distrib 10.5.27

まずは現在の状況をチェック
MariaDB [(none)]> SELECT @@SESSION.sql_mode;
前略
|STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,
NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
あれー、NO_ZERO_IN DATE もNO_ZERO_DATE も入っていない。
これがDATEカラムにnullが認められないが、入っていないのでSTRICT_TRANS_TABLESだけを削除する

MariaDB [(none)]> SET SESSION sql_mode = ‘ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
うんで、再度チェック
MariaDB [(none)]>
SELECT @@SESSION.sql_mode;
| ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,
NO_ENGINE_SUBSTITUTION |
STRICT_TRANS_TABLESを取ると、NO_ZERO_IN DATE や NO_ZERO_DATEが入っていても、ワーニングを出し、データーは保存されるようだ。

でも、実際にdateカラムが””(空白)になっているデーターをインポートするとエラーになってしまう。(原因は不明、sql_modeでは表示されないが、どうもNO_ZERO_IN DATE や NO_ZERO_DATEがデフォルトで有効になっているのかな?)
なので再度、NO_ENGINE_SUBSTITUTION だけを有効にして
MariaDB [(none)]> SET SESSION sql_mode = ‘NO_ENGINE_SUBSTITUTION’;
で、再度インポート
MariaDB [(none)]>
LOAD DATA INFILE ファイルのパス INTO テーブル名 FIELDS TERMINATED BY ‘\T’ IGNORE 1 ROWS
やっと、dateカラムが空白になっているファイルのインポートが出来た。

カテゴリー: Linux運用時のメモ | コメントする

11:ログイン機能をつける

基本方針:これから作るrailsアプリは社内の特定部署の社員しか使わないので、userのデーターベースは作りますが、大げさなgemやrails8から実装されたauthenticationなどは使わず、管理者が直接データーベースにアクセスし、ユーザー名とパスワードを作るようにし、アプリ側からはユーザーデーターの新規作成、編集、削除など一切作らないようにします。
まずはデーターベースの作成
[fuji@rails8 TourData]$ rails g model user name:string password_digest:string
invoke active_record
create db/migrate/20250820061510_create_users.rb
create app/models/user.rb
invoke test_unit
create test/models/user_test.rb
create test/fixtures/users.yml
[fuji@rails8 TourData]$ rails db:migrate
== 20250820061510 CreateUsers: migrating ======================================
— create_table(:users)
-> 0.0873s
== 20250820061510 CreateUsers: migrated (0.0875s) =
password_digestに注意してください。これは平文でパスワードを入れると、データーベースには暗号化した文字列が入るようになる。
そのためにGEMが必要になるので
[fuji@rails8 TourData]$ gedit Gemfile

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem “image_processing”, “~> 1.2”
gem “spring-commands-rspec” → これは前に入れた
gem “bcrypt”           → これを追記
group :development, :test do0
でお約束の
[fuji@rails8 TourData]$ bundle

で最初にtestユーザーでも作っておく、railsコンソールで作るがその前にusers.rbを設定しておく
[fuji@rails8 TourData]$ gedit app/models/user.rb
class User < ApplicationRecord
   has_secure_password              → これを追記
   validates :name, prsence: true, uniqueness: true → これを追記
end

railsのコンソールから直接ユーザーを作る
[fuji@rails8 TourData]$ rails c
tour-data(dev)> User.new( name: ‘ユーザー名’, password: ‘パスワード’, password_confirmation: ‘パスワード’).save
TRANSACTION (0.2ms) BEGIN /*application=’TouData’*/
User Create (1.0ms) INSERT INTO `users` (`name`, `password_digest`, `created_at`, `updated_at`) VALUES
後略
そしてデーターベースにログインし、ユーザーが出来ているか確認した。

ログイン画面を作るが、rails ではセッションを使うので
[fuji@rails8 TourData]$ rails g controller Sessions new
create app/controllers/sessions_controller.rb
  route get “sessions/new”
  invoke erb
  create app/views/sessions
後略
routeの変更するがログイン画面を/loginにしたいので
[fuji@rails8 TourData]$ gedit config/routes.rb
Rails.application.routes.draw do
 #get “sessions/new”       コメントアウトし
 get “/login”, to: “sessions/new”    ここから
post “/login”, to: “sessions#create”    ↓
    delete ‘/logout’, to: ‘sessions#destroy’ ここまで追記
後略
テンプレートを作る
[fuji@rails8 TourData]$ gedit /app/views/sessions.new.html.erb
<h1>* LOG IN *</h1>
<%= form_for(:session, url: login_path) do |f| %>
<%= f.label :name %>
<%= f.email_field :name %><br><br>
<%= f.label :password %>
<%= f.password_field :password %><br><br>
<%= f.submit “Log in” %>
<% end %>

カテゴリー: Ruby on railsに挑戦(almalinux9) | コメントする

10:下準備

springを入れます(これはプリローダーでアプリをバックグランドで走らせてままに出来、rails generate やrake コマンドの起動が早くなるとの事)Gemfileに追記する
[fuji@rails8 TourData]$ gedit Gemfile
前略
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem “image_processing”, “~> 1.2”
gem ‘spring-commands-rspec’ → これを追記
group :development, :test do

[fuji@rails8 TourData]$ bundle
[fuji@rails8 TourData]$ spring binstub rspec
スプリングが走っているかチェック
[fuji@rails8 TourData]$ spring status
Spring is not running.
なので
[fuji@rails8 TourData]$ spring start
[fuji@rails8 TourData]$ spring status
Spring is running:
140726 spring server | TourData | started 9 secs ago

JavaScriptを圧縮するためにnode.jsを入れますがどのバージョンがあるか調べます。
[fuji@rails8 TourData]$ sudo dnf module list nodejs
前略
nodejs 18 common [d], development, minimal, s2i Javascript runtime
nodejs 20 common [d], development, minimal, s2i Javascript runtime
nodejs 22 common [d], development, minimal, s2i Javascript runtime
後略
なので、22を入れます
[fuji@rails8 TourData]$ sudo dnf module -y install nodejs:22/common

 

カテゴリー: Ruby on railsに挑戦(almalinux9) | コメントする