jQuery select部品の操作
<select id="day_of_week"> <option value="0">日曜日</option> <option value="1">月曜日</option> <option value="2">火曜日</option> <option value="3">水曜日</option> <option value="4">木曜日</option> <option value="5">金曜日</option> <option value="6">土曜日</option> </select>
月曜日を選択済みにする
$('#day_of_week').val(1).prop('selected',true);
選択済みの項目名を取得する
var dayOfWeek = $('#day_of_week option:selected').text();
Vagrant 'Timed out while waiting for the machine to boot. '
Vagrant で、'Timed out while waiting for the machine to boot. ' というエラーが発生
Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'bento/centos-7.1'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'bento/centos-7.1' is up to date... ==> default: Setting the name of the VM: vagrant_default_1463022558517_66485 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
下記の方法で解決しました。
ホストマシンのBIOS設定で
Security -> Virtualization
'Virtualization technology'を Enabled に変更する*1
SELinuxの設定
tarコマンドの負荷を減らしたい cstreamを使ってみた
今回やりたいこと
tarコマンドを使って、深夜にバックアップを行っているのですが、
バックアップ中にCPU使用率が上昇しアラートが上がってしまい困っています。
これを、なんとかしたい‥
前提として、負荷制御に関するいろいろ
負荷制御する 〜cstream以外の方法
CPU負荷とI/O負荷は違います。
今回制御したいのは、CPU負荷です。
sleepしながらゆっくり実行とかの方法もあるようです。 が、
CPU使用率を下げる目的でSleep(0)を呼び出すのは正しくない気がします。
とのこと。*1
nice(プロセスの優先度を指定するコマンド)を使う方法もありますが、
深夜に実行してるバッチの負荷を下げる目的なので、
今回の目的にはあまり効果がないかもです。
ちなみにI/O負荷を下げる目的では、
ioniceを使ったりする、らしい。*2
負荷を確認する方法いろいろ
下記の記事参考にさせていただきました。
Linuxサーバの負荷や使用率を調査するコマンドと手順 | EasyRamble
TOPコマンドを使いこなしてTOPを狙う。 - コンピュータクワガタ
負荷制御する 〜cstreamについて
cstreamは、ファイルシステムのキャッシュを使わずに書き込んだり、 書き込みの帯域を制限できたり デバイスへの書き込み処理の際にごにょごにょしてくれるもののようです。
です。*3
その他、下記の記事参考にさせていただきました。
tarコマンドを負荷制御(bwlimit指定)して実行する方法 - SHANON Engineer's Blog
大量データを「cstream」で捌く! | ADMAGE blog ―技術者目線のアドテク知識発信ブログ―
Postgresフルバックアップ時の負荷を下げたい | 東京うぇ部
実際に行ったインストール方法、使い方などは、以下の通りです。
本題、cstreamを使って負荷制御
環境
CentOS Linux release 7.0.1406 (Core)
x86_64
cstreamのインストール
rpmでインストール
$ wget http://pkgs.repoforge.org/cstream/cstream-3.1.0-1.el6.rf.x86_64.rpm
$ sudo rpm -ivh cstream-3.1.0-1.el6.rf.x86_64.rpm
yumでインストール
rpmforge-releaseダウンロード
$ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
RPMforgeリポジトリインストール
$ sudo rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
ダウンロードしたファイルを削除
$ sudo rm -f rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
rpmforge-releaseアップデート
$ sudo yum -y update rpmforge-release
cstreamインストール
ただinstallするだけだと、el7のrpmが存在しないためインストールできません。
$ sudo yum -y install cstream
読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * rpmforge: ftp.riken.jp * updates: ftp.riken.jp パッケージ cstream は利用できません。 エラー: 何もしません
el7のrpmが存在しないため、el6を利用できるよう、下記を追加
$ sudo vi /etc/yum.repos.d/rpmforge.repo
[rpmforge-el6] name = RHEL $releasever - RPMforge.net - dag baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge enabled = 0 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1
インストール
(※yumで負荷の上がる華奢なサーバーなのでniceを使いました。)*4
$ sudo nice -n 19 yum -y install cstream --enablerepo=rpmforge-el6
cstreamを使ってtarのスループットを1MB/secに制御
制御前の処理内容
tar cvzf backup.zip \ -C /var \ www/data/config/ \ www/data/logs/ \ www/html/upload
1MB/secに制御
BW=1 tar cvzf - \ -C /var/ \ www/data/config/ \ www/data/logs/ \ www/html/upload \ | cstream -t $((${BW}*1024*1024)) > \ backup.zip
これでCPU負荷下げることできました。 終わり。
yum RPMforgeリポジトリインストール
環境
CentOS Linux release 7.0.1406 (Core) x86_64
リポジトリダウンロード
$ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
リポジトリインストール
$ sudo rpm -ihv rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
インストールできたか確認
$ sudo rpm -qa | grep rpmforge rpmforge-release-0.5.3-1.el7.rf.x86_64
$ cd /etc/yum.repos.d $ ll -rw-r--r--. 1 root root 1612 7月 4 2014 CentOS-Base.repo -rw-r--r--. 1 root root 640 7月 4 2014 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 1331 7月 4 2014 CentOS-Sources.repo -rw-r--r--. 1 root root 156 7月 4 2014 CentOS-Vault.repo -rw-r--r--. 1 root root 739 6月 12 2014 mirrors-rpmforge -rw-r--r--. 1 root root 717 6月 12 2014 mirrors-rpmforge-extras -rw-r--r--. 1 root root 728 6月 12 2014 mirrors-rpmforge-testing -rw-r--r--. 1 root root 1128 6月 12 2014 rpmforge.repo
$ cat rpmforge.repo
[rpmforge] name = RHEL $releasever - RPMforge.net - dag baseurl = http://apt.sw.be/redhat/el7/en/$basearch/rpmforge mirrorlist = http://mirrorlist.repoforge.org/el7/mirrors-rpmforge #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge enabled = 1 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1
enabled = 1 なら利用可能
ファイル削除、アップデート
削除
$ sudo rm -f rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
アップデート
sudo yum -y update rpmforge-release
CentOS バージョン確認
tar 解凍・圧縮
圧縮
第2引数に絶対パスを指定すると警告されます。
$ tar cvzf /home/backup/src/archive \ /var/www/hoge/document/data/config/ \ /var/www/hoge/document/data/logs/ \ /var/www/hoge/document/html/upload tar: メンバ名から先頭の `/' を取り除きます
-Cオプションを使います。
$ tar cvzf /home/backup/src/archive \ -C /var/www/hoge \ document/data/config/ \ document/data/logs/ \ document/html/upload
解凍
$ tar xvf /home/backup/src/archive