多段sshとvnc接続
タイトルがいい感じですが講義のメモです. OSの講義ではos.cr上にVMを立ち上げて,これをどうこうするのですが こいつには学外からは直接sshできず,一旦yomitan(shell.ie)を経由しなければなりません. 毎回ssh yomitanしてからも手ですが,面倒くさいから多段ssh(一部を踏み台にして,あたかも直接接続しているようにする) の設定を行います
参考サイトは此方
ローカルの設定はこんな感じです(~/.ssh/config)
Host yomitan HostName yomitan.ie.u-ryukyu.ac.jp port 22 IdentityFile ~/.ssh/ie_rsa User e1557** StrictHostKeyChecking no Host os.cr HostName os.cr.ie.u-ryukyu.ac.jp User e1557** IdentityFile ~/.ssh/ie_rsa ProxyCommand ssh -W %h:%p yomitan
これで
$ ssh os.cr
するとos.cr.に直接行きます.やったね.
さてここからですがos.cr上のVMにvnc接続を行います. これも学内ならなにも考えずにできますが,学外からでは先程の多段sshを使う必要があります
まずはvncポートを確認するために os.cr上で
$ ie-virsh vncdisplay 01
などをして,表示された番号に +5900 したものがVNCポートです. ちなみに defineした時にパスワードが自動出力されるのでメモっておきます
ここでmacで
$ssh -L 10024:localhost:5900(さっきの) -N os.cr
を行い Finder のGo->Connect ServerもしくはChicken of the VNCを利用し localhost:10024 にパスワードを付けて接続しましょう 上のコマンドの意味はos.crに10024で接続し,localhost(ここではos.crのこと)上の5900番ポートにssh ということです.(多分)
よっし! pic.twitter.com/HD0pxXvRur
— 八雲アナグラ (@AnaTofuZ) 2017年1月15日
な画面が出れば終了です.めでたしめでたし
ポッピンQ
普段まとめると言ってまとめてないので.
ポッピンQ見てきました.
サザンプレックスしかやってなかったので,98番で古島まで行ってそこから何故か徒歩で向かいました. 帰りのバスがある予定だったのですが,19:30上映なのを19:30終了と誤解し,帰りは友人(まめ君)に送ってもらいました. この場を借りて厚く御礼を申し上げます.
映画の内容はプリキュア+まどマギ+アイマス+インド映画でしたね.ダンスが多かったです. 3DCGなダンスはフレッシュプリキュア!以降のプリキュアで恒例となっているのですが,東映劇場作品だけあり ぬるぬると動きました.ポッピン族(マスコット的なキャラ)のダンスもあったのですが,綺麗でした.
ストーリーは王道.悪く言えばありがちなストーリーですね.まぁ悪くは無かったですが,近頃の「この世界の片隅に」とか「魔法少女まどか☆マギカ」ほどパンチの有るストーリーではなかったですね. ただメッセージは強く,特に自分や現実とどう向き合うかが主軸に置かれていると思います. キャラクターも可愛らしく,気力を回復するには良いアニメ映画でした.
パンフレットは売り切れていたのですが,入場者プレゼントもらいました.
入場者プレゼント貰った pic.twitter.com/vWS902dx3Y
— 八雲アナグラ (@AnaTofuZ) 2017年1月14日
映画の最後に,「魔法少女まどか☆マギカ 後編 永遠の物語」らしく次回作への予告(のようなもの)が入り終了でした. アニメ映画でやるのかな.地上波でやるのかはわかりませんが,新キャラもあるようで楽しみですね.
brewでいれたmysqlが壊れる件
講義でmysqlを使うのですが,ローカルなmacにbrewでinstallするまでは良いのですが
定期的に mysql -u root -p
すると正しいパスワードをいれても解決しない問題が出てきました.
具体的には
❯ mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
な感じですね. brew uninstall mysql
しても解決せず.四苦八苦していると
なblog記事が
この手順通りにやってもrm出来てないところがあって,そこは臨機応変にした. 以下作業ログ.
/v/empty ❯❯❯ sudo rm -rf /usr/local/var/mysql /v/empty ❯❯❯ brew uninstall mysql Uninstalling /usr/local/Cellar/mysql/5.7.16... (13,511 files, 439M) /v/empty ❯❯❯ brew cleanup Warning: Skipping boost: most recent version 1.63.0 not installed Warning: Skipping source-highlight: most recent version 3.1.8_4 not installed /v/empty ❯❯❯ brew update Already up-to-date. /v/empty ❯❯❯ brew install mysql ==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.16.el_capitan.bot Already downloaded: /Users/e155730/Library/Caches/Homebrew/mysql-5.7.16.el_capitan.bottle.1.tar.gz ==> Pouring mysql-5.7.16.el_capitan.bottle.1.tar.gz ==> Using the sandbox ==> /usr/local/Cellar/mysql/5.7.16/bin/mysqld --initialize-insecure --user=e1557 ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation To connect run: mysql -uroot To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start ==> Summary 🍺 /usr/local/Cellar/mysql/5.7.16: 13,511 files, 439M /v/empty ❯❯❯ mysqld --initialize --explicit_defaults_for_timestamp 2016-12-30T08:35:33.113558Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-12-30T08:35:33.113992Z 0 [ERROR] Aborting /v/empty ❯❯❯ ⏎ /v/empty ❯❯❯ sudo rm -rf /usr/local/var/mysql ⏎ /v/empty ❯❯❯ mysqld --initialize --explicit_defaults_for_timestamp 2016-12-30T08:36:03.921480Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive 2016-12-30T08:36:04.125426Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-12-30T08:36:04.157283Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-12-30T08:36:04.217534Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 003ca31c-ce6b-11e6-ab71-0e9de9b7da21. 2016-12-30T08:36:04.231309Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-12-30T08:36:04.827665Z 0 [Warning] CA certificate ca.pem is self signed. 2016-12-30T08:36:04.886195Z 1 [Note] A temporary password is generated for root@localhost: J/nhD5rss3yx
なのだが,どうもここの root@localhost:
以下に表示されるpasswordを覚えておく必要があるらしい
今回は
2016-12-30T08:36:04.886195Z 1 [Note] A temporary password is generated for root@localhost: J/nhD5rss3yx
であるので J/nhD5rss3yx
ですね
/v/empty ❯❯❯ mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) /v/empty ❯❯❯ mysql_secure_installation ⏎ Securing the MySQL server deployment. Enter password for user root: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) /v/empty ❯❯❯ mysql.server start ⏎ Starting MySQL . SUCCESS! /v/empty ❯❯❯ mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: Error: Access denied for user 'root'@'localhost' (using password: NO)
でさっきのパスワードをこれをした後に入力
/v/empty ❯❯❯ mysql_secure_installation ⏎ Securing the MySQL server deployment. Enter password for user root: (ここで入力する) The existing password for the user account root has expired. Please set a new password. New password: Sorry, you can't use an empty password here. New password: Re-enter new password: VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: n Using existing password for root. Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done! /v/empty ❯❯❯ mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) /v/empty ❯❯❯ mysql -u root ^p ⏎ ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) /v/empty ❯❯❯ mysql -u root -p ⏎ Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.16 Homebrew Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exit exit ^C mysql> exit; Bye
な感じで解決した
追記(2017/01/03)
かくとぅふ氏からコメントが
上のlogに追記しておくと人によってはクリーンインストールした際にrootでのログインの際にpassを設定していない場合にうまくログインできない場合があるみたいです. その場合passを変更しなきゃいけないのですが, http://qiita.com/ahaha0807_alg/items/7323a5d2dd365308cb94 を参考にすると幸せになれるみたいです.ほとんどがpasswordでの記述で自分のところのelcapitanではずっと ERROR 1054 (42S22): Unknown column 'Password' in 'field list' みたいなエラーはいていたんで.もしpass変更の際にひっかかるようであればこちらも参考にするとよいかと.
なるほど.パスワードカラムを変更する場合もある様です
UNIXという考え方
- 作者: Mike Gancarz,芳尾桂
- 出版社/メーカー: オーム社
- 発売日: 2001/02
- メディア: 単行本
- 購入: 40人 クリック: 498回
- この商品を含むブログ (143件) を見る
UNIXという考え方を読みました. しばらく本の解説や文章を書いてないので上手く纏まってないですが…
nal先生のサイトにあったオススメ書籍だったので前々から気になっていました. 琉大図書館の蔵書になったので,借りて3章ほど.その後購入して帰省のバスで読了しました.
版が変わってないこともあり,中に書かれている情報としては大分古い (CDROMが最新の環境と書かれている)ですが,bassとなっているUNIX思想は今でも通じると思います.
中では「small is Beautiful」な UNIX思想やUNIXの定理についての解説がなされています. UNIX思想の解説本ではありますが,UNIXの歴史を解説した本という側面も強く,歴史好きとしてはそういった面でも面白かったです. ただし所謂コマンドの解説本では無いので,実用的なTipsを求めている方にはオススメできないかもしれません.
本文中では「C言語よりシェルスクリプトの方が移植性が高い」と再三提唱されていました. 自分としてはシェルスクリプトの方が移植性低いと認識していたので思わぬ発見でした. 筆者が「アセンブラが~」などと再三言っているので,おそらくそこまで言語の種類自信も無かった時代だったからだとも思いますが…
かなり進化したアーキテクチャ,Linuxからこの世界に入ったので温故知新な勉強になりました. 言語に頼らず小さい処理が出来るプログラムこそUNIXの美徳は教訓ですね.
Fedora24でLinuxのkernelをbuildする
さて作業レポート. dockerの課題を先にやれと言われそうだが….
とりあえずKVMにあげてからの話.
まずLinuxのkernelを kernel.orgから持ってくる. …のだが,hostの都合で今回は4.8.6を使う
vmで
$wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.6.tar.xz
バージョンは適当に変えよう. 落としてきたのはtar.xzファイルであるので解凍して展開する.
$tar Jxfv linux-4.9.tar.xz
(この展開している時スーパーハカー感あってすごく楽しい)
あとは公式サイトに書いてある通りにやっていく
$ dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign $ dnf install ncurses-devel
はずなのだが…?
これで通るはずだが,何故か1つずつやっていかないとinstall出来なかった….
しかし pesign-rh-test-certs
は無いらしい.おいおい.
でめでたくbuild出来ると思いきや openssl/bio.h: No such file or directoryなエラーがmakeしてると出る. なので
dnf install openssl-devel
を行う必要がある.
履歴によると実際に僕がやったのはこの辺
22 | install openssl-devel | 2016-12-24 18:34 | Install | 8 21 | install pesign | 2016-12-24 18:27 | Install | 3 20 | install fedora-packager | 2016-12-24 18:23 | Install | 86 19 | install kernel-devel | 2016-12-24 18:17 | Install | 1 18 | install zlib-devel | 2016-12-24 17:07 | Install | 1 17 | update | 2016-12-24 16:48 | E, I, U | 86 EE 16 | install ncurses-devel | 2016-12-24 16:42 | Install | 2
ここまで行くと多分build出来るので
$make clean $make mrproper
して設定を消去(ゴミ削除)して
$make menuconfig
する.kernel debugにチェックをいれないといけないが,実はデフォルトで入っている.そのままsaveして
$ make >& ers & $ disown %m exit
あたりすれば大丈夫らしい.
心配ならtmuxをinstallして起動した状態で
$ make >& ers &
を行えばバックグラウンドでmakeが行われていく筈. logはersに入っているのでmoreとかで確認すると1~2時間くらいでbuild出来ている.
続いて
make modules_install
とするのだがエラーが出る. どうも
dnf install elfutils-libelf-devel
しないとダメらしい.
あとは
make install
すればokなのだが,この後gdbで追う様の設定が結構キツイ.それはまた次回で
(追記 2017/01/15)
kernelのbuildで失敗することが多くなり(具体的には make manuconfigが出来ない)
色々試したのですが
dnf reinstall ncurses-devel
したら解決しました.コンパイラでマクロが読めてなかったのは,このライブラリ群が破損していたからだそうです.
VirtualBoxを使って(気合で)Fedora24のパーティションを拡張する
わりと辛かったのでメモ
講義でqcow2な形式を拡張して,LinuxのKarnelをbuildする必要があったのだが,root権限が使えない一般ユーザーなので 自分で出来るVirtualBoxでやってみる. 気合と書いてるのはその為.
なぜVirtualBoxを使わないといけないのか
どうもVirtualBoxで初期に振ったHDD容量以外は
fdisk /dev/sda
しても降ることが出来ないらしい….今回は2時間くらいそこで悩んだ
VirtualBoxでの操作
まずは拡張したいVirtualBoxのイメージをCloneしておく. 右クリックでClone押せば出来るっぽい.(なぜかCloneする時のアイコンが羊です) それで拡張する為に一旦shut downしておく.
ターミナル上での操作
まずはローカルで ~/VirtualBox VMs
にcd.
続いて容量の確認
$ VBoxManage showhdinfo anagura.vdi UUID: 4e7f002a-a846-4880-a960-c59912501cd0 Parent UUID: base State: created Type: normal (base) Location: /Users/e155730/VirtualBox VMs/anagura/anagura.vdi Storage format: VDI Format variant: dynamic default Capacity: 50000 MBytes Size on disk: 4898 MBytes Encryption: disabled In use by VMs: anagura (UUID: c4dfd1e7-5ebd-44d6-abb3-c12a3494529d)
ここの Capacityが問題.今回はやった後なんでわりとでかいが,8Gb程度になってるはず. さて変換 30Gほどあれば良いか
$ VBoxManage modifyhd clone-disk1.vdi --resize 30720 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
多分確認すれば増えている筈.
実際に反映させていく
さてこれでHDDを物理的に増やした(仮想的だけど)ので,それを実際にマシン側に反映させていく.
とりあえず先程反映させたVMを起動,rootあたりで入っておく.(一応suとかしてrootになっとく)
まずは今現在のパーティション環境を確認したいので
$ fdisk /dev/sda fdisk (util-linux 2.28.2) へようこそ。 ここで設定した内容は、書き込みコマンドを実行するまでメモリのみに保持されます。 書き込みコマンドを使用する際は、注意して実行してください。 コマンド (m でヘルプ):
な画面を表示させる.ここで確認はpだからおもむろにpを押すと
デバイス 起動 開始位置 最後から セクタ サイズ Id タイプ /dev/sda1 * 2048 1026047 1024000 500M 83 Linux /dev/sda2 1026048 16777215 15751168 7.5G 8e Linux LVM
な画面が表示される. これは後々使うのでメモっておいてください
ここでsda2の方を拡張するのでsda2を消す.(先の段階でサイズが直ってたら変更する必要ない) fdisk内でdを選択
コマンド (m でヘルプ): d パーティション番号 (1,2, 既定値 2): 2 パーティション 2 を削除しました
な感じで削除. 続いて サイズ変更fdisk内でnを選択して作る この時 開始位置を最初の通りに設定する こと.多分デフォルトでそうなってる. 終了位置を書かれてるMAXに設定して,再びp をすると大きくなっている.
ここでファイルに反映させるので必ずwを推して書き込ませること.
で,実際に反映させる.
$pvresize /dev/sda2 Physical volume "/dev/sda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
さて変更されているか.
$ pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name fedora_401 PV Size 48.34 GiB / not usable 2.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 12374 Free PE 10452 Allocated PE 1922 PV UUID QmA0cN-CnqX-2nFy-2FoX-JFh0-cWhP-V51KUs
やっためう!! さて続いては論理的に拡張
今回は /dev/mapper/fedora(fedora_401)-root
に対して行う
$ lvextend -l +100%FREE /dev/mapper/fedora_401-root Size of logical volume fedora_401/root changed from 6.71 GiB (1717 extents) to 47.54 GiB (12169 extents). Logical volume root successfully resized.
確認しとく
[root@401]/home/anagura# lvdisplay --- Logical volume --- LV Path /dev/fedora_401/swap LV Name swap VG Name fedora_401 LV UUID RyM5Tj-qGQN-PM13-gMUo-Uy7R-SdDd-4Id4Yt LV Write Access read/write LV Creation host, time 401.pc.ie.u-ryukyu.ac.jp, 2016-10-14 20:13:39 +0900 LV Status available # open 2 LV Size 820.00 MiB Current LE 205 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Path /dev/fedora_401/root LV Name root VG Name fedora_401 LV UUID LJZan7-IpRp-7ssR-0BbZ-rovN-LcLz-7QMzpR LV Write Access read/write LV Creation host, time 401.pc.ie.u-ryukyu.ac.jp, 2016-10-14 20:13:39 +0900 LV Status available # open 1 LV Size 47.54 GiB Current LE 12169 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
おーけー.
ここで resize2fs /dev/mapper/fedora_401-root
したさはあるが,これは古いらしく
$xfs_growfs /dev/mapper/fedora_401-root meta-data=/dev/mapper/fedora_401-root isize=512 agcount=4, agsize=439552 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1 spinodes=0 data = bsize=4096 blocks=1758208, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 1758208 to 12461056
で行う.
$ df -h ファイルシス サイズ 使用 残り 使用% マウント位置 devtmpfs 359M 0 359M 0% /dev tmpfs 371M 0 371M 0% /dev/shm tmpfs 371M 584K 370M 1% /run tmpfs 371M 0 371M 0% /sys/fs/cgroup /dev/mapper/fedora_401-root 48G 3.8G 44G 8% / tmpfs 371M 8.0K 371M 1% /tmp /dev/sda1 477M 155M 293M 35% /boot tmpfs 75M 0 75M 0% /run/user/1000
無事変更されてる.良かった.
この辺参考にすると良い? qiita.com