Apache DDoS 対応
数日〜数週間ごとにWebサーバにアクセスできなくなる事象が発生しており、 OS再起動で暫定対応していたが、 あらためて、真面目に調査してみた。
OOM Killer によって Apacheが停止している。
# grep "Out of memory" messages* | grep "Aug 17 12:" | head messages:Aug 17 12:31:33 hoge kernel: Out of memory: Kill process 1187 (java) score 89 or sacrifice child messages:Aug 17 12:31:55 hoge kernel: Out of memory: Kill process 12921 (httpd) score 26 or sacrifice child messages:Aug 17 12:32:05 hoge kernel: Out of memory: Kill process 29707 (httpd) score 25 or sacrifice child messages:Aug 17 12:32:16 hoge kernel: Out of memory: Kill process 12924 (httpd) score 24 or sacrifice child messages:Aug 17 12:32:28 hoge kernel: Out of memory: Kill process 18440 (httpd) score 24 or sacrifice child messages:Aug 17 12:32:42 hoge kernel: Out of memory: Kill process 12922 (httpd) score 23 or sacrifice child messages:Aug 17 12:32:54 hoge kernel: Out of memory: Kill process 29706 (httpd) score 23 or sacrifice child messages:Aug 17 12:33:12 hoge kernel: Out of memory: Kill process 12920 (httpd) score 22 or sacrifice child messages:Aug 17 12:33:21 hoge kernel: Out of memory: Kill process 12926 (httpd) score 22 or sacrifice child messages:Aug 17 12:33:41 hoge kernel: Out of memory: Kill process 29705 (httpd) score 22 or sacrifice child
Apache のアクセスログを確認すると、特定IPアドレスからのアクセスが大量にあることが見て取れる。
# cat access_log | grep 202.215.15.8 | awk '{print $4}' | grep "17/Aug/2015:12:1" | wc -l 452
ググるとコレくさい
http://itpro.nikkeibp.co.jp/article/NEWS/20110831/367976/
CentOS のデフォルトの yum リポジトリで取得できる Apache だとバージョンが低いらしい。 ということで、yum リポジトリを追加して対応。
アップデート前の Apache のバージョンを確認
# httpd -v Server version: Apache/2.2.15 (Unix) Server built: Oct 16 2014 14:48:21
centalt リポジトリを追加します。
# rpm -Uvh http://mirror.sysadminguide.net/centalt/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
baseurlを書き換えます。
# vi /etc/yum.repos.d/centalt.repo -baseurl=http://centos.alt.ru/repository/centos/6/$basearch/ +baseurl=http://mirror.sysadminguide.net/centalt/repository/centos/6/$basearch/
yum を一旦初期化
# yum clean all
Apache をアップデートします。
# yum update httpd httpd-devel 読み込んだプラグイン:fastestmirror, security 更新処理の設定をしています Determining fastest mirrors epel/metalink | 3.0 kB 00:00 * base: ftp.tsukuba.wide.ad.jp * epel: ftp.kddilabs.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp CentALT | 2.9 kB 00:00 CentALT/primary_db | 200 kB 00:00 base | 3.7 kB 00:00 base/primary_db | 4.6 MB 00:00 elasticsearch-1.3 | 951 B 00:00 elasticsearch-1.3/primary | 1.9 kB 00:00 elasticsearch-1.3 10/10 epel | 4.4 kB 00:00 epel/primary_db | 6.7 MB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 26 kB 00:00 mondorescue | 1.3 kB 00:00 mondorescue/primary | 41 kB 00:01 mondorescue 165/165 updates | 3.4 kB 00:00 updates/primary_db | 1.3 MB 00:00 パッケージ httpd-devel は利用できますが、インストールしませんでした。 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> Package httpd.x86_64 0:2.2.15-39.el6.centos will be 更新 ---> Package httpd.x86_64 0:2.2.27-1.el6 will be an update --> 依存性の処理をしています: httpd-tools = 2.2.27-1.el6 のパッケージ: httpd-2.2.27-1.el6.x86_64 --> トランザクションの確認を実行しています。 ---> Package httpd-tools.x86_64 0:2.2.15-39.el6.centos will be 更新 ---> Package httpd-tools.x86_64 0:2.2.27-1.el6 will be an update --> 依存性解決を終了しました。 依存性を解決しました ====================================================================================================================== パッケージ アーキテクチャ バージョン リポジトリー 容量 ====================================================================================================================== 更新: httpd x86_64 2.2.27-1.el6 CentALT 887 k 依存性関連での更新をします。: httpd-tools x86_64 2.2.27-1.el6 CentALT 62 k トランザクションの要約 ====================================================================================================================== アップグレード 2 パッケージ 総ダウンロード容量: 950 k これでいいですか? [y/N]y パッケージをダウンロードしています: (1/2): httpd-2.2.27-1.el6.x86_64.rpm | 887 kB 00:01 (2/2): httpd-tools-2.2.27-1.el6.x86_64.rpm | 62 kB 00:00 ---------------------------------------------------------------------------------------------------------------------- 合計 536 kB/s | 950 kB 00:01 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています 警告: RPMDB は yum 以外で変更されました。 更新 : httpd-tools-2.2.27-1.el6.x86_64 1/4 更新 : httpd-2.2.27-1.el6.x86_64 2/4 警告: /etc/httpd/conf/httpd.conf は /etc/httpd/conf/httpd.conf.rpmnew として作成されました。 整理中 : httpd-2.2.15-39.el6.centos.x86_64 3/4 整理中 : httpd-tools-2.2.15-39.el6.centos.x86_64 4/4 Verifying : httpd-tools-2.2.27-1.el6.x86_64 1/4 Verifying : httpd-2.2.27-1.el6.x86_64 2/4 Verifying : httpd-2.2.15-39.el6.centos.x86_64 3/4 Verifying : httpd-tools-2.2.15-39.el6.centos.x86_64 4/4 更新: httpd.x86_64 0:2.2.27-1.el6 依存性を更新しました: httpd-tools.x86_64 0:2.2.27-1.el6 完了しました!
httpd プロセスが /etc/init.d/httpd
コマンドで落とせない状態となってしまっていたので、
OSごとreboot
で再起動
# /etc/init.d/httpd restart httpd を停止中: [失敗] httpd を起動中: [Tue Aug 18 01:38:29 2015] [warn] module proxy_ajp_module is already loaded, skipping (98)Address already in use: make_sock: could not bind to address [::]:80 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs # reboot
無事に Apache のアップデートが完了しました。
# httpd -v Server version: Apache/2.2.27 (Unix) Server built: Apr 9 2014 22:08:12
今後のことを考えて、スワップも作成しておく。
1GBのスワップ用のファイルを作成
# dd if=/dev/zero of=/var/tmp/swap0 bs=1024 count=1048576
作成したスワップ用ファイルの属性を変更
# mkswap /var/tmp/swap0
# swapon /var/tmp/swap0
設定されたことを確認
# cat /proc/swaps Filename Type Size Used Priority /dev/vda2 partition 2097148 68440 -1 /var/tmp/swap0 file 1048572 0 -2
OSを再起動した時に適用されるよう、fstabに追記
# vi /etc/fstab +/var/tmp/swap0 none swap defaults 0 0
あとは、しばらく様子見ですかね。
初心者が Arduino ボードを触ってみた
電子工作すらまともにやったことのない私ですが、 Arduino ボードを購入して触ってみました。
Arduino ボードは、ATmega をベースに作られたマイコンボードです。 最近、Arduino 互換の製品が増えてきていることもあり、試してみることにしました。
Arduino ボードは種類がいくつもありますが、今回は、一番メジャーなArduino UNO
を使用します。
Arduino UNO は、公式サイトに以下のとおり記載されています。
Microcontroller | ATmega328P |
---|---|
Operating Voltage | 5V |
Input Voltage (recommended) | 7-12V |
Input Voltage (limit) | 6-20V |
Digital I/O Pins | 14 (of which 6 provide PWM output) |
PWM Digital I/O Pins | 6 |
Analog Input Pins | 6 |
DC Current per I/O Pin | 20 mA |
DC Current for 3.3V Pin | 50 mA |
Flash Memory | 32 KB (ATmega328P)of which 0.5 KB used by bootloader |
SRAM | 2 KB (ATmega328P) |
EEPROM | 1 KB (ATmega328P) |
Clock Speed | 16 MHz |
Length | 68.6 mm |
Width | 53.4 mm |
Weight | 25 g |
今回はIRレシーバを使用し、リモコンを受信テストをしてみます。
配線
配線は、いろいろネットで調べたり、試したりしながら、以下のようにしました。
コーディング
Arduino 公式アプリを使用して、以下の通りコーディングを行いました。
IR受信には、別途ライブラリが必要とのことで、以下のサイトからダウンロードして、配置してます。
https://github.com/z3t0/Arduino-IRremote
#include <IRremote.h> int RECV_PIN = 11; int LED_PIN = 3; IRrecv irrecv(RECV_PIN); IRsend irsend; decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); pinMode(LED_PIN, OUTPUT); } void storeCode(decode_results *results) { String rcvCode = String(results->value,HEX); Serial.print("0x" + rcvCode + ": "); switch(results->value) { case 0xe730e916: Serial.println("ON!"); digitalWrite(LED_PIN, HIGH); delay(300); digitalWrite(LED_PIN, LOW); break; case 0xe730d12e: Serial.println("OFF!"); digitalWrite(LED_PIN, HIGH); delay(300); digitalWrite(LED_PIN, LOW); break; default: Serial.println("OTHERS.."); } } void loop() { if (irrecv.decode(&results)) { storeCode(&results); irrecv.resume(); } }
アプリから検証とアップロードを行えば、使用可能となります。
テスト
早速試してみると、リモコンを操作したタイミングで、無事にLEDが付きました。
シリアルモニタを開くと、以下の通り、16進数の受信コードと
押したボタンごとの状態表示(ON
・OFF
・OTHERS
の文字列)が表示されることも確認できました。
所感
若干、電圧とか気になりますが、動作したので、一旦気にしない〜
やっていて感じましたが、ITのシステム構築と似てますね。
H/W(各電子パーツ)を購入して、LAN(銅線)引いて、アプリ開発(コーディング)..w
次回は、乾電池使ったりとか、DCモータの制御とか、やろうかなぁ..
余談
ちなみにライブラリに付属してるサンプルアプリで2進数でコードが見れます。
このあたりの記事を見ましたが...電子工作が嫌いになりそうだったので見るのやめましたw
http://cranberrytree.blogspot.jp/2012/11/arduino2.html
http://elm-chan.org/docs/ir_format.html
最終的にコード解析は、ライブラリ付属のIRrecordを使用しました。
/* * IRrecord: record and play back IR signals as a minimal * An IR detector/demodulator must be connected to the input RECV_PIN. * An IR LED must be connected to the output PWM pin 3. * A button must be connected to the input BUTTON_PIN; this is the * send button. * A visible LED can be connected to STATUS_PIN to provide status. * * The logic is: * If the button is pressed, send the IR code. * If an IR code is received, record it. * * Version 0.11 September, 2009 * Copyright 2009 Ken Shirriff * http://arcfn.com */ #include <IRremote.h> int RECV_PIN = 11; int BUTTON_PIN = 12; int STATUS_PIN = 13; IRrecv irrecv(RECV_PIN); IRsend irsend; decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver pinMode(BUTTON_PIN, INPUT); pinMode(STATUS_PIN, OUTPUT); } // Storage for the recorded code int codeType = -1; // The type of code unsigned long codeValue; // The code value if not raw unsigned int rawCodes[RAWBUF]; // The durations if raw int codeLen; // The length of the code int toggle = 0; // The RC5/6 toggle state // Stores the code for later playback // Most of this code is just logging void storeCode(decode_results *results) { codeType = results->decode_type; int count = results->rawlen; if (codeType == UNKNOWN) { Serial.println("Received unknown code, saving as raw"); codeLen = results->rawlen - 1; // To store raw codes: // Drop first value (gap) // Convert from ticks to microseconds // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion for (int i = 1; i <= codeLen; i++) { if (i % 2) { // Mark rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; Serial.print(" m"); } else { // Space rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; Serial.print(" s"); } Serial.print(rawCodes[i - 1], DEC); } Serial.println(""); } else { if (codeType == NEC) { Serial.print("Received NEC: "); if (results->value == REPEAT) { // Don't record a NEC repeat value as that's useless. Serial.println("repeat; ignoring."); return; } } else if (codeType == SONY) { Serial.print("Received SONY: "); } else if (codeType == RC5) { Serial.print("Received RC5: "); } else if (codeType == RC6) { Serial.print("Received RC6: "); } else { Serial.print("Unexpected codeType "); Serial.print(codeType, DEC); Serial.println(""); } Serial.println(results->value, HEX); codeValue = results->value; codeLen = results->bits; } } void sendCode(int repeat) { if (codeType == NEC) { if (repeat) { irsend.sendNEC(REPEAT, codeLen); Serial.println("Sent NEC repeat"); } else { irsend.sendNEC(codeValue, codeLen); Serial.print("Sent NEC "); Serial.println(codeValue, HEX); } } else if (codeType == SONY) { irsend.sendSony(codeValue, codeLen); Serial.print("Sent Sony "); Serial.println(codeValue, HEX); } else if (codeType == RC5 || codeType == RC6) { if (!repeat) { // Flip the toggle bit for a new button press toggle = 1 - toggle; } // Put the toggle bit into the code to send codeValue = codeValue & ~(1 << (codeLen - 1)); codeValue = codeValue | (toggle << (codeLen - 1)); if (codeType == RC5) { Serial.print("Sent RC5 "); Serial.println(codeValue, HEX); irsend.sendRC5(codeValue, codeLen); } else { irsend.sendRC6(codeValue, codeLen); Serial.print("Sent RC6 "); Serial.println(codeValue, HEX);a } } else if (codeType == UNKNOWN /* i.e. raw */) { // Assume 38 KHza irsend.sendRaw(rawCodes, codeLen, 38); Serial.println("Sent raw"); } } int lastButtonState; void loop() { // If button pressed, send the code. int buttonState = digitalRead(BUTTON_PIN); if (lastButtonState == HIGH && buttonState == LOW) { Serial.println("Released"); irrecv.enableIRIn(); // Re-enable receiver } if (buttonState) { Serial.println("Pressed, sending"); digitalWrite(STATUS_PIN, HIGH); sendCode(lastButtonState == buttonState); digitalWrite(STATUS_PIN, LOW); delay(50); // Wait a bit between retransmissions } else if (irrecv.decode(&results)) { digitalWrite(STATUS_PIN, HIGH); storeCode(&results); irrecv.resume(); // resume receiver digitalWrite(STATUS_PIN, LOW); } lastButtonState = buttonState; }
MySQL 5.5 で mysqld_multi とMaster-Slave 構成を試す
環境
実行手順
MySQL インストール
$ sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum リポジトリの定義ファイルを開き、5.5をインストールするように以下の通り編集。
$ sudo vi /etc/yum.repos.d/mysql-community.repo @@ -16,7 +16,7 @@ [mysql55-community] name=MySQL 5.5 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/ -enabled=0 +enabled=1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql @@ -24,7 +24,7 @@ [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ -enabled=1 +enabled=0 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
$ sudo yum -y install mysql mysql-devel mysql-server mysql-utilities
mysql 5.5 がインストールされたことを確認。
$ mysql --version mysql Ver 14.14 Distrib 5.5.45, for Linux (x86_64) using readline 5.1
mysqld_multi を適用
ユーザ作成
$ sudo adduser user1
それぞれのディレクトリに対して初期化処理を行います。
$ sudo mysql_install_db --datadir=/data/user1m $ sudo mysql_install_db --datadir=/data/user1s
$ sudo vi /etc/my.cnf
@@ -25,7 +25,32 @@ # Recommended in standard MySQL setup #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES +user = mysql ### `datadir`で設定したユーザを指定します。 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid + +[mysqld_multi] +mysqld = /usr/bin/mysqld_safe +mysqladmin = /usr/bin/mysqladmin +user = admin +password = hoge + +[mysqld1] +port = 50001 +datadir = /data/user1 +pid-file = /data/user1m/mysql.pid +socket = /data/user1m/mysql.sock +user = user1 +general_log = ON +general-log-file = /var/log/mysqld/user1.log + +[mysqld2] +port = 50002 +datadir = /data/user1s +pid-file = /data/user1s/mysql.pid +socket = /data/user1s/mysql.sock +user = user1 +general_log = ON +general-log-file = /var/log/mysqld/user2.log
ディレクトリ作成
$ sudo mkdir -p /data/user1m $ sudo chown -R mysql:mysql /data/user1m $ sudo mkdir -p /data/user1s $ sudo chown -R mysql:mysql /data/user1s
一台ずつ起動
$ sudo mysqld_multi start 1 $ sudo mysqld_multi start 2
ちなみにmysql_multi start
と後述のmysql_multi stop
の引数は、
以下の通り指定することもできます。
<なし>: 全台
1,3: 1と3
1-3: 1〜3
起動を確認します。
$ sudo mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running
停止してみます。
$ sudo mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running
停止できていないことが確認できるかと思います。
$ sudo mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running
ログを確認してみるとわかりますが、
my.cnf
ファイルのmysqld_multi
セクションで設定したユーザに対して権限が与えられていないことによるものです。
$ sudo tail /var/lib/mysql/mysqld_multi.log ... /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'admin'@'localhost' (using password: YES)' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'admin'@'localhost' (using password: YES)'
mysql を停止できるように権限を付与しましょう。
$ sudo mysql --socket=/data/user1m/mysql.sock -u root
mysql> SELECT user,host FROM mysql.user; +------+-----------------+ | user | host | +------+-----------------+ | root | 127.0.0.1 | | root | ::1 | | | ip-172-31-1-225 | | root | ip-172-31-1-225 | | | localhost | | root | localhost | +------+-----------------+ 6 rows in set (0.00 sec) mysql> TRUNCATE TABLE mysql.user; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY 'hoge' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'hoge' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO 'admin'@'localhost.localdomain' IDENTIFIED BY 'hoge' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; mysql> SELECT user,host FROM mysql.user; +-------+-----------------------+ | user | host | +-------+-----------------------+ | admin | 127.0.0.1 | | admin | localhost | | admin | localhost.localdomain | +-------+-----------------------+ 3 rows in set (0.00 sec)
同様に2のほうでも作業を行います。
これで mysql を停止できるようになりました。
$ sudo mysqld_multi stop
$ sudo mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
レプリケーション用のユーザ作成
# mysql -uadmin -phoge --socket=/data/user1/mysql.sock -e "GRANT REPLICATION SLAVE ON *.* TO 'repusr'@'%';"
mysqldumpによるデータコピー
READ LOCK
mysql> FLUSH TABLES WITH READ LOCK;
MASTER POSITION の確認
# mysql -uadmin -phoge --socket=/data/user1m/mysql.sock -e "SHOW MASTER STATUSG" *************************** 1. row *************************** File: mysql-bin.000002 Position: 749 Binlog_Do_DB: Binlog_Ignore_DB:
ダンプ作成
# mysqldump -uadmin -phoge --socket=/data/user1m/mysql.sock --all-databases > dump1.sql -- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
LOCK を解除
# mysql -uadmin -phoge --socket=/data/user1m/mysql.sock -e "UNLOCK TABLE ;"
ダンプをインポート
# mysql -uadmin -phoge --socket=/data/user1s/mysql.sock < dump1.sql
Slave側でマスタの設定
# mysql -uadmin -phoge --socket=/data/user1s/mysql.sock << EOF CHANGE MASTER TO MASTER_HOST = '127.0.0.1', MASTER_USER = 'repusr', MASTER_PORT = 50001, MASTER_LOG_FILE = 'mysql-bin.000002', MASTER_LOG_POS = 749; EOF
# mysql -uadmin -phoge --socket=/data/user1s/mysql.sock -e "START SLAVE;"
# mysql -uadmin -phoge --socket=/data/user1s/mysql.sock -e "SHOW SLAVE STATUSG" *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 127.0.0.1 Master_User: repusr Master_Port: 50001 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 107 Relay_Log_File: mysql-relay.000002 Relay_Log_Pos: 253 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 107 Relay_Log_Space: 405 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1
マスター側のデータを確認します。
# mysql -uadmin -phoge --socket=/data/user1m/mysql.sock test -e "SELECT * from table1;" +------+-------+ | col1 | col2 | +------+-------+ | 1 | one | | 2 | two | | 3 | three | +------+-------+
スレーブ側に反映しているか確認します。
# mysql -uadmin -phoge --socket=/data/user1s/mysql.sock test -e "SELECT * from table1;" +------+-------+ | col1 | col2 | +------+-------+ | 1 | one | | 2 | two | | 3 | three | +------+-------+
JobSchedulerが使えるのかどうか試すために試しにインストールしてみた件 (4)
素人による素人のためのJobSchedulerインストール手順 前準備編の第2回を始めていきます。
前回の記事でタダなのにJP1とかHPSoftwareみたいなことできまっせということが少しだけ分かった
ちょっとだけ気力が回復したので。
しんどいけど…インストールに必要となるVNCコンソールをAWS上のRHEL7にぶっこんでみましょうか。
とかいいつつ、導入するのはVNCコンソールじゃあないんですわ。
インストールするのはxrdpってやつですわ。
どうやって入れるかっていうと…
(1)ホスト名設定
# vi /etc/hostname test-scheduler # vi /etc/hosts … 127.0.0.1 test-scheduler … … # vi /etc/cloud/cloud.cfg … - update_hostname … ここを「#」でコメントアウト …
(2)SELinux 無効化
# vi /etc/sysconfig/selinux SELINUX=disabled # setenforce 0 # getenforce Permissive
(3)ファイアウォール無効化
# systemctl status firewalld # service firewalld stop # systemctl disable firewalld
ここ要注意ですわ。個人的にわけわかんなくて結構ハマったんで。
RHEL7(CentOS7)からコマンド体系が変わっとるんですよね。
そして、iptablesじゃあなくてfirewalldっていう名前になっとるなんて…
わいぐらいの雑魚はchkconfigとかserviceコマンドで門前払いに会いましたわ。
ええ、そりゃあ辛かったですよ。
俺が必死こいて記事を書いている隣で隣のカップルがエロ話している位ね。
※ちなみにfirewalldを無効化する理由は皆さんご存じの通り、AWS上ではセキュリティタグとか
なんとやらでファイアウォールのサービスは既に起動しているからです。
二重ブロックとなってしまうため、こちらはオフってるわけですわ。
(4)GUI系の設定
# yum grouplist # yum -y groupinstall 'Server with GUI'
(5)tigervnc
結局入れるんか~い。
っていうのもxrdpでvncサーバーのプロセスを使用するからっていう理由らしいですが…
# yum -y install tigervnc-server # cp /lib/systemd/system/vncserver\@.service /etc/systemd/system/vncserver@\:1.service # vi /etc/systemd/system/vncserver@\:1.service ↓この行の <USER> を書き換え PIDFile=/home/ec2-user/.vnc/%H%i.pid ↓この行の <USER> を書き換え、「-geometry 1024x768」を挿入 ExecStart=/sbin/runuser -l ec2-user -c "/usr/bin/vncserver -geometry 1024x768 %i" # vi /etc/sysconfig/vncservers VNCSERVERS="1:root" … 追加 VNCSERVERARGS[1]="-geometry 1024x768" … 追加 # vncpasswd … root ユーザの VNC パスワード設定(今回は使わないので適当で良い) # vncpasswd ec2-user … ec2-user ユーザの VNC パスワード設定(今回は使わないので適当で良い) # chkconfig vncserver@:1 on # service vncserver@:1 start
(6)xrdpのインストール
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm # rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm # yum -y install xrdp # chkconfig xrdp on # service xrdp start
(7)rootユーザーのパスワード設定
まぁ、vncの設定で指定したユーザーならrootである必要はないですわ。
※後日書きますがJobSchedulerのインストールはrootユーザーじゃあできないんでね。
# passwd
(8)リモート接続テスト
上手くいくとね、こんなんが出まっせ。
(9)注意事項
これでJobSchdulerをインストールするためのGUI環境が整いました!!
っていう風に安心したらあきまへん。
実は上記の設定だと再起動したらまたfirewalldが有効になっとるわけですわ。
なんで、次回起動時にはこいつを打つのを忘れずに。
※誰か解決して~
service firewalld stop
後は初歩的な注意事項でrunlevelをmulti-user.targetにしといて下さいね。
RHEL7からはrunlevelの概念が変わっているのでそこも要注意っと。
※あえて書きませんよ説明文は…なぜってもう実は心が折れているからですよ。
【参考】
https://access.redhat.com/ja/node/1379593
(systemd を従来の init と比較する)
相変わらずエロ話は花が咲いておりますよ。
ふ~ん、いいもん俺は明日、美味しいものでも食べに行きますから…
じゃあね、みんな、おやすみなさい。
JobSchedulerが使えるのかどうか試すために試しにインストールしてみた件 (3)
引き続き、引き続きJobSchedulerのインストール方法を書いてみますよ。
じゃあ、手順を書きますか…
しまった…忘れとったわ。
JobSchedulerの構成ってもんに関して書き忘れてたわ。
StandAlone構成の簡易図以下に示しときます。
(なんか使ってる言葉が変みたいで投稿のところどころで赤線が入ってますわ)
何だろう、上の図を見てとりあえず思うのは以下のことだな。
(1)RDBMS上にジョブの実行履歴を残せること
(2)EngineとJOC(ジョブ実行用コンソール)はサーバ上に配備
(3)へぇ、ジョブの定義(JOE:エディターね)とか実行履歴ダッシュボード(JID)とかはクライアントの端末で見れるってわけか
こんなんもありまっせと。
まぁ、いわゆるJP1とかHPと同じやつですわ。
ジョブ管理の親玉がいて、子分で僕らからお金をとろうってわけですね。
■JobScheduler Engine インストール手順
uname -r
実行結果:
3.10.0-229.el7.x86_64
バージョンが2.4以上なら動きまっせと。
(2)RedHatのバージョン確認
less /etc/redhat-release
実行結果:
Red Hat Enterprise Linux Server release 7.1 (Maipo)
まぁ、だからどうしたってことなんですがね。
(3)AmazonEC2上でのRHEL用のyumを有効化する
yum-config-manager --enable rhui-lb
実行結果:
Loaded plugins: amazon-id, rhui-lb
はい、有効になりましたっと。
(4)yum起動テスト
①ミラーリストから一番応答が早いミラーを自動選択するプラグインをインストール
yum install yum-fastestmirror
実行結果:
Loaded plugins: amazon-id, rhui-lb rhui-REGION-client-config-server-7 | 2.9 kB 00:00:00 rhui-REGION-rhel-server-releases | 3.7 kB 00:00:00 rhui-REGION-rhel-server-rh-common | 1.9 kB 00:00:00 (1/4): rhui-REGION-client-config-server-7/x86_64/primary_db | 4.3 kB 00:00:00 (2/4): rhui-REGION-rhel-server-rh-common/7Server/x86_64/primary | 30 kB 00:00:00 (3/4): rhui-REGION-rhel-server-rh-common/7Server/x86_64/updateinfo | 11 kB 00:00:00 (4/4): rhui-REGION-rhel-server-releases/7Server/x86_64/primary_db | 13 MB 00:00:01 (1/2): rhui-REGION-rhel-server-releases/7Server/x86_64/group_gz | 133 kB 00:00:00 (2/2): rhui-REGION-rhel-server-releases/7Server/x86_64/updateinfo | 585 kB 00:00:00 rhui-REGION-rhel-server-rh-common 131/131 No package yum-fastestmirror available. Error: Nothing to do
②古いヘッダなどを全てクリア
yum clean all
実行結果:
Loaded plugins: amazon-id, rhui-lb Cleaning repos: rhui-REGION-client-config-server-7 rhui-REGION-rhel-server-releases : rhui-REGION-rhel-server-rh-common Cleaning up everything
③インストール済パッケージをアップデート
yum update
実行結果:
Transaction Summary =================================================================================================== Install 1 Package (+1 Dependent package) Upgrade 47 Packages Total download size: 84 M Is this ok [y/d/N]: y ~ 省略 ~ Complete!
省略?まぁいんじゃない
④依存ライブラリのインストール
yum install -y ld-linux.so.2 libz.so.1
実行結果:
=================================================================================================== Package Arch Version Repository Size =================================================================================================== Installing: glibc i686 2.17-78.el7 rhui-REGION-rhel-server-releases 4.2 M zlib i686 1.2.7-13.el7 rhui-REGION-rhel-server-releases 90 k Installing for dependencies: nss-softokn-freebl i686 3.16.2.3-9.el7 rhui-REGION-rhel-server-releases 187 k Transaction Summary =================================================================================================== Install 2 Packages (+1 Dependent package) Total download size: 4.4 M Installed size: 15 M Downloading packages: (1/3): nss-softokn-freebl-3.16.2.3-9.el7.i686.rpm | 187 kB 00:00:00 (2/3): zlib-1.2.7-13.el7.i686.rpm | 90 kB 00:00:00 (3/3): glibc-2.17-78.el7.i686.rpm | 4.2 MB 00:00:00 --------------------------------------------------------------------------------------------------- Total 6.1 MB/s | 4.4 MB 00:00:00 Complete!
ここはねぇ、後にしよう…
はい、何か疲れたから今日はここまでね。
何かカップルがイチャついて、大変なんで心が折れないうちに帰るよ。