CentOS 7でkernel 5.0 が出たので上げてみた。

CentOS 7で稼働中のサーバーをkernel 5.0にアップデートしてみました。
使用したリポジトリはelrepo-kernel.repoです。

update前に現状確認

# uname -r
4.20.13-1.el7.elrepo.x86_64

リポジトリを念の為きれいにして

# yum clean all
読み込んだプラグイン:fastestmirror, langpacks
リポジトリーを清掃しています: base elrepo elrepo-kernel epel extras mariadb
...: nginx remi-php72 remi-safe skype-stable updates zabbix
...: zabbix-non-supported
Cleaning up list of fastest mirrors
Other repos take up 22 M of disk space (use --verbose for details)

改めて確認

# yum check-update
kernel-ml.x86_64 5.0.0-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.0.0-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.0.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.0.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.0.0-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.0.0-1.el7.elrepo elrepo-kernel

elrepo-kernel.repoで確かにkernel 5.0が来ております。
それではupdateします。
続きを読む "CentOS 7でkernel 5.0 が出たので上げてみた。"

ファイルシステムをXFSからext4に変換してみた。

CentosのデフォルトのファイルシステムはXFSだがext4に変換してみた。

現状は

# df -T | grep -i xfs
ファイルシス タイプ 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/centos-root xfs 34909540 12561500 22348040 36% /
/dev/sda1 xfs 508588 169916 338672 34% /boot
/dev/mapper/centos-home xfs 17041408 3049104 13992304 18% /home

このような感じ

fstransformというパッケージをつかうと出来るらしい

普通にYUMではいるのか?

# yum install fstransform
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 6.9 kB 00:00:00
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi-safe: ftp.riken.jp
* updates: ftp.iij.ad.jp
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
remi-safe | 3.0 kB 00:00:00
updates | 3.4 kB 00:00:00
epel/x86_64/primary_db FAILED
http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/repodata/dfe399fd78675260e7888081dd162479b2ecd1e9afe7e15f74c9c0fd5571dbf4-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
他のミラーを試します。
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

(1/3): epel/x86_64/updateinfo | 954 kB 00:00:00
(2/3): remi-safe/primary_db | 1.4 MB 00:00:00
(3/3): epel/x86_64/primary_db | 6.6 MB 00:00:00
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ fstransform.x86_64 0:0.9.3-1.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

=====================================================================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
=====================================================================================================================================================================
インストール中:
fstransform x86_64 0.9.3-1.el7 epel 130 k

トランザクションの要約
=====================================================================================================================================================================
インストール 1 パッケージ

総ダウンロード容量: 130 k
インストール容量: 362 k
Is this ok [y/d/N]: y
Downloading packages:
fstransform-0.9.3-1.el7.x86_64.rpm | 130 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : fstransform-0.9.3-1.el7.x86_64 1/1
検証中 : fstransform-0.9.3-1.el7.x86_64 1/1

インストール:
fstransform.x86_64 0:0.9.3-1.el7

完了しました!

インストールできました。

使い方はこんな感じ

fstransform {device} {target-file-system-type}

実際にやってみる。
対象は/homeの/dev/mapper/centos-homeを指定

# fstransform /dev/mapper/centos-home ext4
fstransform: starting version 0.9.3, checking environment
fstransform: checking for which... '/usr/bin/which'
fstransform: checking for expr... '/usr/bin/expr'
fstransform: checking for id... '/usr/bin/id'
fstransform: parsing command line arguments
fstransform: checking for stat... '/usr/bin/stat'
fstransform: checking for mkfifo... '/usr/bin/mkfifo'
fstransform: checking for blockdev... '/usr/sbin/blockdev'
fstransform: checking for losetup... '/usr/sbin/losetup'
fstransform: checking for fsck... '/usr/sbin/fsck'
fstransform: checking for mkfs... '/usr/sbin/mkfs'
fstransform: checking for mount... '/usr/bin/mount'
fstransform: checking for umount... '/usr/bin/umount'
fstransform: checking for mkdir... '/usr/bin/mkdir'
fstransform: checking for rmdir... '/usr/bin/rmdir'
fstransform: checking for rm... '/usr/bin/rm'
fstransform: checking for dd... '/usr/bin/dd'
fstransform: checking for sync... '/usr/bin/sync'
fstransform: checking for fsmove... '/usr/sbin/fsmove'
fstransform: checking for fsremap... '/usr/sbin/fsremap'
fstransform: checking for fsck(source file-system)... '/usr/sbin/fsck'
fstransform: checking for fsck(target file-system)... '/usr/sbin/fsck'
fstransform: looking for optional commands
fstransform: checking for sleep... '/usr/bin/sleep'
fstransform: checking for date... '/usr/bin/date'
14:27:38 fstransform: environment check passed.
14:27:38 fstransform: saving output of this execution into /var/tmp/fstransform/fstransform.log.101625
14:27:38 fstransform: preparing to transform device '/dev/mapper/centos-home' to file-system type 'ext4'
14:27:38 fstransform: device is mounted at '/home' with file-system type 'xfs'
14:27:38 fstransform: device raw size = 17460887552 bytes
14:27:38 fstransform: creating sparse loop file '/home/.fstransform.loop.101625' inside device '/dev/mapper/centos-home'...
14:27:38 dd: 1+0 レコード入力
14:27:38 dd: 1+0 レコード出力
14:27:38 dd: 1 バイト (1 B) コピーされました、 0.000236563 秒、 4.2 kB/秒
14:27:38 fstransform: device file-system block size = 4096 bytes
14:27:38 fstransform: device usable size = 17460887552 bytes
14:27:38 dd: 1+0 レコード入力
14:27:38 dd: 1+0 レコード出力
14:27:38 dd: 1 バイト (1 B) コピーされました、 0.000208061 秒、 4.8 kB/秒
14:27:39 fstransform: connected loop device '/dev/loop0' to file '/home/.fstransform.loop.101625'
14:27:39 fstransform: formatting loop device '/dev/loop0' with file-system type 'ext4'...
14:27:40 fstransform: mounting loop device '/dev/loop0' on '/tmp/fstransform.loop.101625' ...
14:27:41 fstransform: loop device '/dev/loop0' mounted successfully.
14:27:41 fstransform: preliminary steps completed, now comes the delicate part:
14:27:41 fstransform: fstransform will move '/dev/mapper/centos-home' contents into the loop file.

警告文がでて/dev/mapper/centos-home /dev/loop0がいっぱいになるとデーターを失うと言ってる感じ
ですが容量には余裕が有るのでENTERで続行

14:27:41 fstransform: WARNING: THIS IS IMPORTANT! if either the original device '/dev/mapper/centos-home'
or the loop device '/dev/loop0' become FULL,

YOU WILL LOSE YOUR DATA !

fstransform checks for enough available space,
in any case it is recommended to open another terminal, type
watch df /dev/mapper/centos-home /dev/loop0
and check that both the original device '/dev/mapper/centos-home'
and the loop device '/dev/loop0' are NOT becoming full.
if one of them is becoming full (or both),
you MUST stop fstransform with CTRL+C or equivalent.

this is your chance to quit.
press ENTER to continue, or CTRL+C to quit:
14:28:05 fstransform: moving '/dev/mapper/centos-home' contents into the loop file.
14:28:05 fstransform: this may take a long time, please be patient...
14:28:09 fsmove: progress: 5.0% done, 2.8 gigabytes still to move
14:28:18 fsmove: progress: 10.0% done, 2.7 gigabytes still to move, estimated 2 minutes left
14:28:21 fsmove: progress: 15.0% done, 2.5 gigabytes still to move, estimated 1 minute and 50 seconds left
14:28:24 fsmove: progress: 20.0% done, 2.4 gigabytes still to move, estimated 1 minute and 40 seconds left
14:28:28 fsmove: progress: 25.0% done, 2.2 gigabytes still to move, estimated 1 minute and 25 seconds left
14:28:35 fsmove: progress: 30.0% done, 2.1 gigabytes still to move, estimated 1 minute and 20 seconds left
14:28:49 fsmove: progress: 35.0% done, 1.9 gigabytes still to move, estimated 1 minute and 25 seconds left
14:28:52 fsmove: progress: 40.0% done, 1.8 gigabytes still to move, estimated 1 minute and 20 seconds left
14:28:59 fsmove: progress: 45.0% done, 1.6 gigabytes still to move, estimated 1 minute and 10 seconds left
14:29:01 fsmove: progress: 50.0% done, 1.5 gigabytes still to move, estimated 1 minute and 5 seconds left
14:29:04 fsmove: progress: 55.0% done, 1.3 gigabytes still to move, estimated 60 seconds left
14:29:04 fsmove: move() skipped `/home/.fstransform.loop.101625', matches exclude list
14:29:04 fsmove: job completed.
14:29:04 fstransform: unmounting and running '/usr/sbin/fsck' (disk check) on loop file '/home/.fstransform.loop.101625'
14:29:06 fsck: fsck from util-linux 2.23.2
14:29:07 fsck: /dev/loop0: 5960/1066864 files (1.9% non-contiguous), 547472/4262912 blocks
14:29:07 fstransform: disconnected loop device '/dev/loop0' from file '/home/.fstransform.loop.101625'
14:29:07 fstransform: unmounting device '/dev/mapper/centos-home' before disk check
14:29:07 fstransform: running '/usr/sbin/fsck' (disk check) on device '/dev/mapper/centos-home'
14:29:07 fsck: fsck from util-linux 2.23.2
14:29:07 fsck: /sbin/fsck.xfs: XFS file system.
14:29:07 fstransform: mounting again device '/dev/mapper/centos-home' read-only
14:29:07 fstransform: launching '/usr/sbin/fsremap' in simulated mode
14:29:07 fsremap: starting job 1, persistence data and logs are in '/var/tmp/fstransform/fsremap.job.1'
14:29:07 fsremap: if this job is interrupted, for example by a power failure,
14:29:07 fsremap: you CAN RESUME it with: /usr/sbin/fsremap -n -q --resume-job=1 -- /dev/mapper/centos-home
14:29:07 fsremap: analysis completed: 1.80 gigabytes must be relocated
14:29:07 fsremap: allocated 823.62 megabytes RAM as memory buffer
14:29:07 fsremap: primary-storage is 230.00 megabytes, initialized and mmapped() to contiguous RAM
14:29:07 fsremap: (simulated) starting in-place remapping. this may take a LONG time ...
14:29:07 fsremap: (simulated) progress: 6.3% done, 1.8 gigabytes still to relocate
14:29:07 fsremap: (simulated) progress: 38.3% done, 1.2 gigabytes still to relocate
14:29:07 fsremap: (simulated) progress: 61.8% done, 816.8 megabytes still to relocate
14:29:07 fsremap: (simulated) progress: 79.6% done, 489.4 megabytes still to relocate
14:29:07 fsremap: (simulated) progress: 94.1% done, 217.2 megabytes still to relocate
14:29:07 fsremap: (simulated) clearing 14.47 gigabytes free-space from device ...
14:29:07 fsremap: (simulated) job completed.
14:29:07 fstransform: launching '/usr/sbin/fsremap' in REAL mode to perform in-place remapping.
14:29:07 fsremap: starting job 2, persistence data and logs are in '/var/tmp/fstransform/fsremap.job.2'
14:29:07 fsremap: if this job is interrupted, for example by a power failure,
14:29:07 fsremap: you CAN RESUME it with: /usr/sbin/fsremap -q --resume-job=2 -- /dev/mapper/centos-home
14:29:07 fsremap: analysis completed: 1.80 gigabytes must be relocated
14:29:08 fsremap: allocated 823.57 megabytes RAM as memory buffer
14:29:08 fsremap: primary-storage is 230.00 megabytes, initialized and mmapped() to contiguous RAM
14:29:08 fsremap: successfully unmounted device '/dev/mapper/centos-home'
14:29:08 fsremap: everything ready for in-place remapping, this is your LAST chance to quit.
14:29:08 fsremap: WARN: press ENTER to proceed, or CTRL+C to quit

14:29:15 fsremap: starting in-place remapping. this may take a LONG time ...
14:29:22 fsremap: progress: 6.3% done, 1.8 gigabytes still to relocate
14:29:48 fsremap: progress: 38.3% done, 1.2 gigabytes still to relocate, estimated 50 seconds left
14:30:06 fsremap: progress: 61.8% done, 816.8 megabytes still to relocate, estimated 30 seconds left
14:30:23 fsremap: progress: 79.6% done, 489.4 megabytes still to relocate, estimated 15 seconds left
14:30:37 fsremap: progress: 94.1% done, 217.2 megabytes still to relocate, estimated 5 seconds left
14:30:42 fsremap: clearing 14.47 gigabytes free-space from device ...

14:35:57 fsremap: job completed.
14:35:58 fstransform: running again '/usr/sbin/fsck' (disk check) on device '/dev/mapper/centos-home'
14:35:58 fsck: fsck from util-linux 2.23.2
14:35:58 fsck: /sbin/fsck.xfs: XFS file system.
14:35:58 fstransform: mounting transformed device '/dev/mapper/centos-home'
14:35:58 fstransform: completed successfully. your new 'ext4' file-system is mounted at '/home'

なんか出来たっぽいのでreboot実行

/homeがマウントできないの・・・

fstransform
fstransform

パスワードを打ってメンテナンスモードで見てみる。

fstabがxfsのまま・・

fstransform
fstransform

このままでは当然無理なのでxfsに書き換えて再度rebootすると

# df -T | grep ext4
/dev/mapper/centos-home ext4 16652636 1790876 13992796 12% /home

無事に変換されました。
見た所データの消失も無いようです。

/homeを別パーティションに分けてる場合は簡単に済みましたが/bootや/だけの場合は
起動させるのにちょっと手を加える必要がありそうです。

goofysでs3をmountする。

goofysでEC2からs3をmountする。
作業は全てrootでやってます。

まずはaws configureでアカウント連携

# aws configure
AWS Access Key ID [None]: hogehogehogehogehoge
AWS Secret Access Key [None]: hagehagehagehagehagehgaehage
Default region name [None]: ap-northeast-1
Default output format [None]: json

s3のバケットが見えるか確認

# aws s3 ls
2018-07-31 02:44:55 hogehoge
2018-08-31 01:57:46 xxxxx-test
2018-08-22 07:23:27 hagehagehage

今回mountするのバケットはhogehoge

go関連のパッケージをインストール

# yum install golang fuse git
# go get github.com/kahing/goofys
# go install github.com/kahing/goofys

goのpathを通します。

# export GOPATH=$HOME/go

起動時にpathが通るように.bashrcにも記述

# vim /root/.bashrc
#最終行に適当に記載
export GOPATH=$HOME/go

確認

# go version
go version go1.9.4 linux/amd64
# echo $GOPATH
/root/go

mountするディレクトリを作ります。

# mkdir /mnt/s3

mountします。

# ./go/bin/goofys --region ap-northeast-1 --profile s3 hogehoge /mnt/s3

確認

# df -h | grep hogehoge
hogehoge 1.0P 0 1.0P 0% /mnt/s3

mountできました。
次は起動時に自動mount設定です。
fstabにこんな感じで書けばいいです。

# cat /etc/fstab | grep hogehoge
/root/go/bin/goofys#hogehoge /mnt/s3 fuse _netdev,allow_other,--file-mode=0666,--uid=500,--gid=500 0 0

rebootしてmountされているか確認して終了。

Nutanix上VMのmacアドレスを変更する。

Nutanix上に構築したVMのMACアドレス変更手順メモ

現在のVMのMACアドレスを確認

# nmcli device show eth0| grep HWADDR
GENERAL.HWADDR: 50:6B:8D:8C:CC:52

50:6b:8d:8c:cc:52が割当たっています。

次にCVM上から確認 acliを使います。

$ acli

vm.nic_get Centos7_test
192.168.200.101 {
ip_address: "192.168.200.101"
mac_addr: "50:6b:8d:8c:cc:52" ←確認
network_name: "vlan0"
network_uuid: "75c0ba81-ff8d-4aac-a854-c94586483b4b"
type: "kNormalNic"
vlan_mode: "kAccess"
}

vm.nic_deleteコマンドで一度VMからNICを削除します。

$ vm.nic_delete Centos7_test 50:6b:8d:8c:cc:52

つぎにvm.nic_createでVMを指定して変更したい任意のMACアドレスをNICに割り当てます。
今回は50:6b:8d:8c:cc:55を割り当てます。

$ vm.nic_create Centos7_test mac=50:6b:8d:8c:cc:55 network=vlan0 request_ip=false

acliで確認します。

vm.nic_get Centos7_test
50:6b:8d:8c:cc:55 {
mac_addr: "50:6b:8d:8c:cc:55" ←変更されている
network_name: "vlan0"
network_uuid: "75c0ba81-ff8d-4aac-a854-c94586483b4b"
type: "kNormalNic"
}

更にVMからも確認
変更確認

[root@cent7-test ~]# nmcli device show eth0| grep HWADDR
GENERAL.HWADDR: 50:6B:8D:8C:CC:55

おしまい

NutanixのCVM hostname変更

NutanixのCVMのhostnameをあとから変更するメモ

まずはhostnameを変えたいCVMにログイン
NTNX-aaaaa-CVMからNUTANIX-01-CVMに変えます。

Nutanix Controller VM
Last login: Fri Sep 11 20:05:23 2018
nutanix@NTNX-aaaaa-CVM:172.10.5.5:~$ /usr/local/nutanix/cluster/bin/change_cvm_hostname NUTANIX-01-CVM
Script must be run as root

nutanixユーザーでは実行できません。

sudoで実行

nutanix@NTNX-aaaaa-CVM:172.10.5.5:~$ sudo /usr/local/nutanix/cluster/bin/change_cvm_hostname NUTANIX-01-CVM
Changing hostname to NUTANIX-01-CVM. This will reboot the CVM. Do you want to proceed? (Y/N): y
2018-09-28 12:51:56 INFO hostname_utils.py:72 Did not find the local SVM hostname NUTANIX-01-CVM in the host look uptable /etc/hosts
2018-08-28 12:51:56 INFO hostname_utils.py:97 Found that the SVM hostname in /etc/sysconfig/network does not match NUTANIX-01-CVM
2018-08-28 12:51:56 INFO hostname_utils.py:137 Setting display name to NUTANIX-01-CVM
2018-08-28 12:51:56 INFO hostname_utils.py:156 Writing custom hostname marker
2018-08-28 12:51:56 INFO change_cvm_hostname:86 Forwarding storage traffic to another CVM

これで変更完了

ログにkernel: netlink: * bytes leftover after parsing attributes.が大量出力されていたので対処

/var/log/messagesに

Nov 14 10:37:32 hogehoge kernel: netlink: 4 bytes leftover after parsing attributes.
Nov 14 10:37:32 hogehoge kernel: netlink: 4 bytes leftover after parsing attributes.
Nov 14 10:37:32 hogehoge kernel: netlink: 4 bytes leftover after parsing attributes.

このような感じでkernelの警告ログが大量に出力されていた。
調べると無視して良いログなので出力しなくした。

*ちなみにOSはCentOS6系です。

# vim /etc/rsyslog.conf

rsyslog.confの先頭行に

:msg, contains, "bytes leftover after parsing attributes." ~

と記載するだけでよいらしい
rsyslogを再起動して終了

# /etc/rc.d/init.d/rsyslog restart
システムロガーを停止中: [ OK ]
システムロガーを起動中: [ OK ]

その後、該当のログは出力されなくなりました。

MariaDBでPlease run mysql_upgradeのエラーが大量に出ていた。

/var/log/messagesを見ると↓のログが大量に出力されていた。

Nov 21 22:16:01 base mysqld: 2018-11-21 22:16:01 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade
Nov 21 22:16:01 base mysqld: 2018-11-21 22:16:01 0 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade
Nov 21 22:16:01 base mysqld: 2018-11-21 22:16:01 0 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade

Please run mysql_upgradeと有るようにupgradeを実行すれば良いようだ。

何も考えずに実行

# mysql_upgrade
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
FATAL ERROR: Upgrade failed

ああ・・ユーザーとパスワードですね・・・。

再度実行

# mysql_upgrade -u root -p
Enter password:
Phase 1/7: Checking and upgrading mysql database
Processing databases

mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.gtid_slave_pos OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.roles_mapping OK
mysql.servers OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.transaction_registry OK
mysql.user OK
Phase 2/7: Installing used storage engines... Skipped
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
続きを読む "MariaDBでPlease run mysql_upgradeのエラーが大量に出ていた。"