2018年5月7日月曜日

lxc のインストール (Centos7)


何となくなんですけど、LXCを使ってみることにしました。
稼働しているLinux がCentOS7だけなので、CentOSに。 
rpm パッケージは無いようなので、ソースからインストールしてみした。

■準備
以下をインストールしておかないと、怖いよ~
yum install  libacl-devel libcap-devel dnsmasq squashfs-tools libtool

■ LXC のインストール
バージョン3.0.0は1ヶ月前にリリースされたばかり。とりあえず、最新に乗ってみる。
https://github.com/lxc/lxc のREADME に書かれている通りにやってみる。
(っていうか、普通にconfigure, makeです)
autogen.sh の実行で libtoolize がないとエラーが出たのでインストール
(yum install libtool)
インストール先は/opt

# ./autogen.sh
# ./configure --prefix=/opt/lxc-3.0.0
# make && sudo make install

# cd /opt
# ln -s lxc-3.0.0 lxc

/opt/lxc/bin をパスに追加しておく

# systemctl start lxc-net
# systemctl start lxc

■ コンテナ作成
fedora28 が使いたかったけどまだないようなのでfedora27にしました。
# lxc-create -t lxc-download fed27
(fed27 はコンテナ名。なんでもいい)

# lxc-start fed27
lxc-start fed27 20180506133710.205 ERROR    lxc_utils - utils.c:run_command:2250 - failed to exec command
lxc-start fed27 20180506133710.206 ERROR    lxc_network - network.c:lxc_ovs_attach_bridge:1890 - Failed to attach "lxcbr0" to openvswitch bridge "veth7JIGEE": lxc-start: fed27: utils.c: run_command: 2250
lxc-start fed27 20180506133710.206 ERROR    lxc_network - network.c:instantiate_veth:194 - Failed to attach "veth7JIGEE" to bridge "lxcbr0": Operation not permitted
lxc-start fed27 20180506133710.217 ERROR    lxc_network - network.c:lxc_create_network_priv:2436 - Failed to create network device
lxc-start fed27 20180506133710.217 ERROR    lxc_start - start.c:lxc_spawn:1545 - Failed to create the network
lxc-start fed27 20180506133710.217 ERROR    lxc_start - start.c:__lxc_start:1866 - Failed to spawn container "fed27"

エラーが出て失敗。
ここをみて、ifcfg-lxcbr0 を追加、ifup lxcbr0 で上のエラーはクリアー。
https://unix.stackexchange.com/questions/179353/failed-to-attach-veth87vsij-to-the-bridge-virbr0-no-such-device
(実際は、systemctl start lxc-net を実行する前に lxc-start を実行したからいけなかったのかもしれない)

あらためて
# lxc-start fed27
別のエラー発生!
lxc-start fed27 20180506135716.874 ERROR    lxc_conf - conf.c:setup_caps:2404 - unknown capability mac_admin
lxc-start fed27 20180506135716.874 ERROR    lxc_conf - conf.c:lxc_setup:3475 - Failed to drop capabilities
lxc-start fed27 20180506135716.874 ERROR    lxc_start - start.c:do_start:1198 - Failed to setup container "fed27"
lxc-start fed27 20180506135716.874 ERROR    lxc_sync - sync.c:__sync_wait:57 - An error occurred in another process (expected sequence number 5)
lxc-start fed27 20180506135716.887 ERROR    lxc_start - start.c:__lxc_start:1866 - Failed to spawn container "fed27"

# yum install libcap-devel
もう一度 make, make install をやり直す。

あらためて
# lxc-start fed27
エラー? フリーズ?
systemd 234 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN default-hierarchy=hybrid)
Detected virtualization lxc.
Detected architecture x86-64.

Welcome to Fedora 27 (Twenty Seven)!

Set hostname to <fed27>.
Cannot determine cgroup we are running in: No medium found
Failed to allocate manager object: No medium found
[!!!!!!] Failed to allocate manager object, freezing.
Freezing execution.

色々調べてみたけれど、どうにもならない。。。
最後の苦しまぎれ.....  lxc を止めて、コンテナ作り直してみる。
# systemctl stop lxc
# systemctl start lxc
# lxc-destroy fed27
もう一度、コンテナ作って lxc-start したらエラーが消えましたwww
もうあきらめようと思っていましたよぉ ほんとに(涙

起動が早すぎて喜ぶひまもなかった。さすがコンテナ!
lxc-attach でコンテナfed27のターミナルに移れました。
(ssh でも入れたのかな?)
# cat /etc/redhat-release
Fedora release 27 (Twenty Seven)

力尽きたので、今日はこれでおしまい。
(GW最後の夜)

2017年3月7日火曜日

インストール後に割り当てたディスクサイズを変更@centos7


■ 現状の確認
df -hT
/dev/mapper/centos-root xfs 50G /
/dev/mapper/centos-home xfs 200G /

今回は以下のように変更したい
/ 200G (150G増やす)
/home 削除
また、ファイルフォーマットを確認しておく。
(残りの50Gは余力として残しておく)

■ 今回やること
LVMのパーティション変更
ファイルシステムxfs にもサイズ変更を反映

■ home をumount
(必要に応じてhome以下をバックアップ)
umount /dev/mapper/centos-home
/etc/fstab を編集
# /dev/mapper/centos-home <- コメントアウトしておく

■ centos-home を削除
lvremove /dev/mapper/centos-home
lvdisplay でcentos-homeが消えていることを確認

■ centos-root のサイズ拡張
lvextend -L +150G /dev/centos/root
 ファイルシステムのサイズ拡張
xfs_growfs /dev/mapper/centos-root

■ 現状の確認
df -hT
/dev/mapper/centos-root xfs       200G  4.6G  196G   3% /
/home は消えている


参考サイト
http://iwamocchan11.hatenadiary.jp/entry/2016/02/08/001020#インストール後に変更したい場合
(CentOS6 について書かれている。CentOS7 と違う点、LVM関連の出力、ファイルシステム ext4, xfs)
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/xfsgrow.html
XFS ファイルシステムのサイズの拡大 (xfs_growfsコマンド)

todo
 - lvdisplay, vgdisplay を調べる

2016年12月15日木曜日

systemd のservice に別名を付ける alias

サービス名にバージョン名が入ってほしくないので、
postgresql-9.6.service をpostgresql.service に変えられないかなと。。。

serviceに別名を付けるオプションがありました。
/usr/lib/systemd/system/postgresql-9.6.service の[Install]セクションに追加
[Install]
Alias=postgresql.service

service へのリンクを作り直します。
> systemctl daemon-reload
> systemctl disable postgresql.service
> systemctl enable postgresql.service
Created symlink from /etc/systemd/system/postgresql.service to /usr/lib/systemd/system/postgresql-9.6.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.6.service to /usr/lib/systemd/system/postgresql-9.6.service.

これで、postgresql.service という名前でsystemctl が利用できます。
> systemctl status postgresql.service
> systemctl status postgresql-9.6.service
どちらでも、内容は同じです。


2016年11月6日日曜日

pip v9.0.0 のエラー対処

pip をversion 9.0.0 にしたらエラーで困ってます

とりあえず、ダウングレードしておきます。

エラーメッセージ
>  File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distro.py", line 922, in _lsb_release_info
>    stdout, stderr = stdout.decode('ascii'), stderr.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 22: ordinal not in range(128)

まず、エラー個所を修正
/usr/local/lib/python3.4/site-packages/pip/_vendor/distro.py
の922行目を修正。
 stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')

次にダウングレード
pip install pip==8.1.1 --upgrade

しばらく、このバージョンで。

2016年10月7日金曜日

yum レポジトリ

超書きかけです。。。
https://ius.io/

todo
epel, postgres, nginx, mongo
(mariadbもいるかな?)

2016年8月12日金曜日

Babel のモジュール機能

今更ですが。。。
Babel 使ったら、モジュールの読み込みもいい塩梅に処理してくれるのかと思ってました。
テヘェ

やっぱり、みんなそう思うよね!
Do I need require js when I use babel?
http://stackoverflow.com/questions/31593694/do-i-need-require-js-when-i-use-babel

Rollup.jp は初めて知りました。
Rollup is a next-generation JavaScript module bundler.
かっこいいね!

2016年6月13日月曜日

npm のprefix指定

npm install -g
のグローバル指定でユーザーのホームディレクトリを指定する。
(nvmを使わずに、rpmなどで入れたnode, npm を使いたい場合などに... )

https://www.sitepoint.com/beginners-guide-node-package-manager/

npm config set prefix
で指定できる。(.npmrc に書き込まれる)