Translate

2015年9月15日火曜日

CloudStack上のCentOSサーバの/をデータボリュームを使って拡張する

CloudStack上にデータディスクオファリングをSmall 30GBで構築したCentOSサーバインスタンスが1つある。

当然、30GBのデータディスク上に/が作成される。

OSのセットアップでデフォルトでディスクをきると、ボリュームグループ centos の論理ボリューム /dev/centos/root/ が作成される。

このインスタンスを一旦テンプレート化する。

で、このテンプレートでインスタンスを作るとルートボリュームは30GBのままだ。

ここで、インスタンスを作るときのデータディスクオファリングで別途Middile 60GBをチェックしても、起動したCentOSサーバ上は30GBのままだ。

この60GBは外付けHDD(物理ボリューム名/dev/vda)として別途追加されてる。

/dev/vdaは、当然まだなにもパーティションが切られていない状態となる。

なので / のディスクサイズを増やす場合は、通常のHDDを追加する手順で増やせば良い。



[root@harahara dev]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x000a6440

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/mapper/centos-root: 28.5 GB, 28462546944 bytes, 55590912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

[root@harahara dev]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x3047076a.

コマンド (m でヘルプ): p

Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x3047076a

デバイス ブート      始点        終点     ブロック   Id  システム

コマンド (m でヘルプ): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
パーティション番号 (1-4, default 1): (Enter)
最初 sector (2048-125829119, 初期値 2048):
(Enter)
初期値 2048 を使います
Last sector, +sectors or +size{K,M,G} (2048-125829119, 初期値 125829119):
(Enter)
初期値 125829119 を使います
Partition 1 of type Linux and of size 60 GiB is set

コマンド (m でヘルプ): t
Selected partition 1
Hex code (type L to list all codes): L

 0  空              24  NEC DOS         81  Minix / 古い Li bf  Solaris       
 1  FAT12           27  Hidden NTFS Win 82  Linux スワップ  c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 隠し C: ド c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux 拡張領域  c7  Syrinx        
 5  拡張領域        41  PPC PReP Boot   86  NTFS ボリューム da  非 FS データ  
 6  FAT16           42  SFS             87  NTFS ボリューム db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux プレーン  de  Dell ユーティリ
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt        
 9  AIX ブート可能  4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access    
 a  OS/2 ブートマネ 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O       
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor     
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad ハ eb  BeOS fs       
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT           
 f  W95 拡張領域 (L 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC 
11  隠し FAT12      56  Golden Bow      a8  Darwin UFS      f1  SpeedStor     
12  Compaq 診断     5c  Priam Edisk     a9  NetBSD          f4  SpeedStor     
14  隠し FAT16 <32M 61  SpeedStor       ab  Darwin ブート   f2  DOS セカンダリ
16  隠し FAT16      63  GNU HURD または af  HFS / HFS+      fb  VMware VMFS   
17  隠し HPFS/NTFS  64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI スワップ   fd  Linux raid 自動
1b  隠し W95 FAT32  70  DiskSecure Mult bb  隠し Boot Wizar fe  LANstep       
1c  隠し W95 FAT32  75  PC/IX           be  Solaris ブート  ff  BBT           
1e  隠し W95 FAT16  80  古い Minix    
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

コマンド (m でヘルプ): p

Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x3047076a

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/vda1            2048   125829119    62913536   8e  Linux LVM

コマンド (m でヘルプ): w
パーティションテーブルは変更されました!

ioctl() を呼び出してパーティションテーブルを再読込みします。
ディスクを同期しています。
[root@harahara dev]# sfdisk -l /dev/vda

ディスク /dev/vda: シリンダ数 124830、ヘッド数 16、63 セクタ/トラック
sfdisk: 警告: パーティションテーブルは C/H/S=*/8/39 として作成されたようです
  (124830/16/63 のかわりに)。
このリストは、そのジオメトリと見なします。

Units: cylinders of 159744 bytes, blocks of 1024 bytes, counting from 0

デバイス ブート 始点    終点 #シリンダ #ブロック  Id  システム
/dev/vda1          6+ 403298- 403292-  62913536   8e  Linux LVM
sfdisk:                 開始: (c,h,s) 期待値 (6,4,21)  (2,0,33) を発見

sfdisk:                 終点: (c,h,s) 期待値 (1023,7,39)  (926,7,39) を発見

/dev/vda2          0       -       0          0    0  空
/dev/vda3          0       -       0          0    0  空
/dev/vda4          0       -       0          0    0  空

[root@harahara dev]# pvcreate /dev/vda1
  Physical volume "/dev/vda1" successfully created
[root@harahara dev]# pvdisplay /dev/vda1
  "/dev/vda1" is a new physical volume of "60.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vda1
  VG Name              
  PV Size               60.00 GiB
  Allocatable           NO
  PE Size               0  
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               ARBrev-hdcQ-G8AI-wHug-7bVa-mbWV-O1JF1o
  
[root@harahara dev]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               29.51 GiB
  PE Size               4.00 MiB
  Total PE              7554
  Alloc PE / Size       7554 / 29.51 GiB
  Free  PE / Size       0 / 0  
  VG UUID               KkEah7-mBBq-6CHl-P8Pt-9sL5-MImr-33FL11
  
[root@harahara dev]# vgextend centos /dev/vda1
  Volume group "centos" successfully extended
[root@harahara dev]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               89.50 GiB
  PE Size               4.00 MiB
  Total PE              22913
  Alloc PE / Size       7554 / 29.51 GiB
  Free  PE / Size       15359 / 60.00 GiB
  VG UUID               KkEah7-mBBq-6CHl-P8Pt-9sL5-MImr-33FL11
  
[root@harahara dev]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                HtdSmz-eYJ4-WOge-cBpU-1WkF-x7rw-J58Ty6
  LV Write Access        read/write
  LV Creation host, time harahara, 2015-08-25 11:49:48 +0900
  LV Status              available
  # open                 2
  LV Size                3.00 GiB
  Current LE             768
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
  
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                GQgsjt-uIf2-8Y6Y-KJZm-s6Xu-OJW2-l85y6R
  LV Write Access        read/write
  LV Creation host, time harahara, 2015-08-25 11:49:48 +0900
  LV Status              available
  # open                 1
  LV Size                26.51 GiB
  Current LE             6786
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
  
[root@harahara dev]# vgdisplay centos
  --- Volume group ---
  VG Name               centos
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               89.50 GiB
  PE Size               4.00 MiB
  Total PE              22913
  Alloc PE / Size       7554 / 29.51 GiB
  Free  PE / Size       15359 / 60.00 GiB
  VG UUID               KkEah7-mBBq-6CHl-P8Pt-9sL5-MImr-33FL11
  

[root@harahara dev]# lvextend -L 86.5G /dev/centos/root
  Size of logical volume centos/root changed from 26.51 GiB (6786 extents) to 86.50 GiB (22144 extents).
  Logical volume root successfully resized

[root@harahara dev]# xfs_growfs/                                                           
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1737216 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=6948864, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=3393, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 6948864 to 22675456
[root@harahara dev]# df -k
ファイルシス            1K-ブロック    使用   使用可 使用% マウント位置
/dev/mapper/centos-root    90688252 3913528 86774724    5% /
devtmpfs                    1932004       0  1932004    0% /dev
tmpfs                       1941424       4  1941420    1% /dev/shm
tmpfs                       1941424    8584  1932840    1% /run
tmpfs                       1941424       0  1941424    0% /sys/fs/cgroup
/dev/sda1                    508588  147940   360648   30% /boot
[root@harahara dev]#

2015年9月10日木曜日

RedmineサーバのURLをルートではなく/redmineで運用する

Redmineサーバをインストールする手順では本家でもルートURLにインストールする方法だけ書かれている。

でもredmine, jenkins, subversion(WebDAV), roundcube..といった機能を1つのサーバで立ち上げたい場合は、どうしても/redmineとかのURLで立ち上げたい。


いろいろためしてみたところ、以下の方法でうまく言った。

/opt/redmine 以下に Redmine3.1.xがインストールされている場合は、以下のように設定ファイルを書き換えれば良い。



/etc/httpd/conf.d/redmine.conf

LoadModule passenger_module /usr/lib64/ruby/gems/2.2.0/gems/passenger-5.0.16/buildout/apache2/mod_passenger.so

        PassengerRoot /usr/lib64/ruby/gems/2.2.0/gems/passenger-5.0.16
        PassengerDefaultRuby /usr/bin/ruby

RailsBaseURI    /redmine

        # This relaxes Apache security settings.
        AllowOverride all
        # MultiViews must be turned off.
        Options -MultiViews
        Options -Indexes
        #Options Indexes ExecCGI FollowSymLinks
        # Uncomment this if you're on Apache >= 2.4:
        Require all granted


そして/etc/httpd/conf/httpd.confDocumentRoot/var/www/htmlの場合は、

ln -s /var/www/html/redmine /opt/redmine/public
を実行し、systemctl restart httpdすれば/redmineでRedmineが上がるようになった。



既存アプリケーションをK8s上でコンテナ化して動かす場合の設計注意事項メモ

既存アプリをK8sなどのコンテナにして動かすには、どこを注意すればいいか..ちょっと調べたときの注意事項をメモにした。   1. The Twelve Factors (日本語訳からの転記) コードベース   バージョン管理されている1つのコードベースと複数のデプロイ 依存関係 ...