LoginSignup
2
2

More than 5 years have passed since last update.

Linux software RAID上にProxmox VEをインストールする

Last updated at Posted at 2018-12-03

はじめに

フリーで使える仮想アプライアンスのProxmox VEは、ZFSのRAIDのみをサポートしてる。Linux software RAIDはサポート外のためまとまった資料がない。
また、Proxmox VEは仮想マシンのKVM(Qemu)に加えて、コンテナにLXCを採用しているが、一般的に使われているコンテナ技術であるDockerもインストールした。
以下は、参考にしたサイト

ベースのDebianのインストール

CDROMイメージよりインストールする。
ディスクは/dev/sda,sdbで、/root:32GB、/home:800GB、残りを仮想マシン専用ディスク領域とする。コンテナのイメージは/homeに保存する。スワップ領域は作成しない。

  • Language: 日本語
  • Location: 日本
  • Keyboard: 日本語
  • Hostname: pve
  • Domain name: local
  • Root password:
  • Full name: <作成するユーザ名>
  • Username: <作成するアカウント名>
  • User password:
  • Partitioning:
    • "戻る"からシェルを立ち上げて、パーティションを削除する。必要に応じて以下のコマンドを使う、 mount/umount lvdisplay/lvremove vgdisplay/vgremove pgdisplay/pgremove mdadm --detail --scan/mdmadm --stop
    • 面倒な場合には、まとめて、 dd bs=1G count=1 if=/dev/zero of=/dev/sda dd bs=1G count=1 if=/dev/zero of=/dev/sdb で、パーティション情報の削除する(こちらがおすすめ)
    • メニューに戻り、RAID1を作成する。
    • LVM(ディスク全体)を選択。
    • "戻る"からシェルを立ち上げて、パーティションの修正する。
#swapを消す
lvremove /dev/pve-vg/swap
#/rootを消して32GBで再設定
lvremove /dev/pve-vg/root
lvcreate -L 32G -n root pve-vg
#1T残して、/homeを作成
lvcreate -L 800G -n home pve-vg

メニーに戻って、作成したパーティションのマウントポイントやラベルを修正

  • ソフトウェア
    • SSHサーバのみを選択
  • GRUBブートローダインストール
    • 再起動の前に、”戻る"で、RAIDの2つ目のディスクにもインストールする (後で grub-install /dev/sdb 等を実行しても可)

再起動後の設定

# localeをCに
update-locale LANG=C.UTF-8
LANG=C

# 必要なツールをインストール
apt-get install -y man-db less sudo net-tools tmux unzip

# ネットワーク設定
vi /etc/network/interfaces #固定IPの設定
auto enp4s0
iface enp4s0 inet static
    address 192.168.0.100
    network 192.168.0.0
    netmask 255.255.255.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 1.1.1.1 1.0.0.1
vi /etc/hosts #IPアドレスを修正
systemctl restart networking.service

# ssh設定
cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.org
vi /etc/ssh/sshd_config
PasswordAuthentication yes
PermitRootLogin yes
systemctl reload ssh

#####
PCからssh public keyのコピー `ssh-copy-id -i .ssh/id_ed25519.pub root@192.168.0.100`
#####

mv /etc/ssh/sshd_config.org /etc/ssh/sshd_config
systemctl reload ssh

Proxmoxのインストール

echo "deb http://download.proxmox.com/debian/pve stretch pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
wget http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-5.x.gpg
apt update && apt dist-upgrade
apt-get install proxmox-ve postfix open-iscsi
(Postfixの設定は、Local onlyを選択)

# 商用版のレポジトリを除く
mkdir /root/config.bak
mv /etc/apt/sources.list.d/pve-enterprise.list /root/config.bak/pve-enterprise.list.bak

# ネットワーク設定
vi /etc/network/interfaces
iface enp4s0 inet manual
auto vmbr0
iface vmbr0 inet static
    address  192.168.0.100
    netmask  255.255.255.0
    gateway  192.168.0.1
    bridge-ports enp4s0
    bridge-stp off
    bridge-fd 0
    dns-nameservers 1.1.1.1 1.0.0.1

# VM用ディスク領域
lvcreate --thin -l 100%FREE pve-vg/thin

#####
Webインターフェースから使用するディスクの設定 (データセンター > ストレージ)
  local (/var/lib/vz)    : ISOイメージ, コンテナテンプレート
  lvm-thin (pve-vg/thin) : ディスクイメージ, コンテナ
#####

# LXCの保存先 /var/lib/vz を /home に移動 & シンボリックリンク
# Proxmox VEのサービスを止める必要があるが、どれを止めれば良いか分からないのでシングルモードで作業
telinit 1
cp -a /var/lib/vz /home
rm -r /var/lib/vz
ln -s /home/vz /var/lib/vz
telinit 5

# Docker & Docker-compose
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
apt-get install -y python-pip
pip install docker-compose

# 保存先を/home/dockerに変更
systemctl stop docker
mkdir /root/config.bak
cp -a /etc/systemd/system/multi-user.target.wants/docker.service /root/config.bak/docker.service.bak
vi /etc/systemd/system/multi-user.target.wants/docker.service
    ExecStart=/usr/bin/dockerd -H unix:// -g /home/docker
systemctl daemon-reload 
systemctl start docker

設定が全て完了したら、もう一度再起動して、きちんと動くか確認。

なぜZFSを使わないのか?

ZFSでRAIDを組んでインストールした際、約30秒おきにディスクアクセスがあり、自宅サーバーとしてはアクセス音が大きすぎたため。ただし、設定の問題かもしれない。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2