2017年10月30日月曜日

"-bash: 警告: setlocale: LC_CTYPE: ロケールを変更できません (UTF-8): そのようなファイルやディレクトリはありません"の対策方法

以下の表示内容が出た場合の対策を記載する。
----------------------表示内容------------------------------------------------------------------------
-bash: 警告: setlocale: LC_CTYPE: ロケールを変更できません (UTF-8): そのようなファイルやディレクトリはありません
---------------------------------------------------------------------------------------------------------


1)以下の文字コードに関するコマンドを入力する。
以後、警告のような表示が出なくなった。

# localectl set-locale LC_CTYPE=ja_JP.utf8

ntpクライアント導入と設定について

OS:Centos7.x
対象のntpサーバー:192.168.10.107


1)ntpクライアントをインストールする。
# yum -y install chrony

2)ntpdサービスは不要なので停止する。
# systemctl stop ntpd.service
# systemctl disable ntpd.service

3)chronyd.serviceを起動する。
# systemctl start chronyd.service
  

4)chrony.confの編集を行う。
# vi /etc/chrony.conf
==========chrony.conf =================
①以下をコメント化する
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

②対象のntpサーバーを追記する。
server 192.168.10.107 iburst

③ネットワーク範囲を指定する。
# Allow NTP client access from local network.

allow 192.168.10.0/24
====================================


5)chronyd.serviceを再起動する。
# systemctl restart chronyd.service


6)以下のコマンドを投入して、"^*"が表示されているば同期完了
# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
======================================================
^* xymon                         2   6   377    10  +2762ns[+7233ns] +/-   53ms

ntpサーバーの導入方法

  1)ntpサーバーのインストールを行う。
  # yum -y install ntp


  2)ntp.confの編集を行う。
  # vi /etc/ntp.conf
  -------ntp.conf----------------------------------
# 18行目: 時刻同期を許可する範囲を追記
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# 同期先のサーバーを変更する。
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
-----------------------------------------------

3)ntpのサービスの起動を行う

# systemctl start ntpd 
# systemctl enable ntpd 


4)firewallの設定を以下の通りに行う。
  # firewall-cmd --add-service=ntp --permanent 
  # firewall-cmd --reload 


  5)以下、コマンドを入力して結果が返ってくること

  # ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ntp.nict.jp     .NICT.           1 u   13   64    1   15.648   -0.441   0.492
 ntp1.jst.mfeed. 133.243.236.17   2 u   10   64    1   14.935    1.118   0.426
 ntp.jst.mfeed.a 133.243.236.17   2 u   20   64    0    0.000    0.000   0.000

ネットワークデバイスを稼働させるコマンド

ネットワークデバイスを稼働させるコマンドのなる。

#  nmcli c u enp03s


enp03s :ネットワークインタフェース名

tomcat 8 & java1.8のインストール方法

1)java1.8 インストールを行う
# yum search openjdk
# yum install java-1.8.0-openjdk


2)tomcatのユーザーを追加する
# useradd -s /sbin/nologin tomcat 

3)tomcat8をダウンロードする
(リンク切れでダウンロードができなくなる可能性も有り)
curl -O http://ftp.jaist.ac.jp/pub/apache/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz

# tar -xzvf ~/apache-tomcat-8.5.23.tar.gz
# mv ~/apache-tomcat-8.5.23 /opt
# chown -R tomcat:tomcat /opt/apache-tomcat-8.5.23

4)サービスの登録の登録を行う

#vi /etc/systemd/system/tomcat.service 
----------------tomcat.service------------------------------------------------------------------------------------
[Unit]
 Description=Apache Tomcat 8
 After=network.target

[Service]
 User=tomcat
 Group=tomcat
 Type=oneshot
 PIDFile=/opt/apache-tomcat-8.5.23/tomcat.pid
 RemainAfterExit=yes

 ExecStart=/opt/apache-tomcat-8.5.23/bin/startup.sh
 ExecStop=/opt/apache-tomcat-8.5.23/bin/shutdown.sh
 ExecReStart=/opt/apache-tomcat-8.5.23/bin/shutdown.sh;/opt/apache-tomcat-8.5.23/bin/startup.sh

[Install]
 WantedBy=multi-user.target

--------------------------------------------------------------------

5)サービスの起動を行う
# systemctl enable tomcat
# systemctl start tomcat

2017年10月29日日曜日

DBフェイルオーバーテスト

db_router側でテストを実施:


■R/W接続
mysql -u app -p -h 127.0.0.1 -P 6446 -e "select @@hostname"
 ->DB1/BD2/DB3が順番に表示されるはず。



■□フェイルオーバーテスト(実施済み)■□
# for i in {0..29}
> do
> mysql -u app -p -h 127.0.0.1 -P 6446 -e "select @@hostname"
>sleep 1
>done

ネットワークトラブル対応( could not activate connectionが表示された場合)

ネットワークトラベル対応( could not activate connectionが表示された場合)


症状:dnsが使えない。
(ping www.google.comができないなど。)

1.nmcli connection modify eno1 connection.autoconnect Yesにしてるのが原因なので
以下のようにoffにする。


# nmcli connection modify eno1 connection.autoconnect no


2.systemctl restart networkを実施する

<参照先>

http://zacodesign.net/blog/?p=862

keepalived_複数VIP追加調査(メモ)

以下の"vip"の番号をユニークすれば複数のVIPを増やせる

# crm configure primitive vip2 ocf:heartbeat:IPaddr2 params ip="192.168.1.200" nic="enp0s3" cidr_netmask="24" op monitor interval="10s"

# crm configure primitive vip3 ocf:heartbeat:IPaddr2 params ip="192.168.1.210" nic="enp0s3" cidr_netmask="24" op monitor interval="10s"

virtulbox起動できないエラー対処方法

■イメージを起動させると以下のエラーが出てしまう。

The VM session was closed before any attempt to power it on.

<対処方法>
VirtualBoxのVMの設定より、起動時のストレージにある、CDROMだのFDだののチェックを
外したら読み込みだした!

Xymon Clientのインストール

1)レポジトリー編集を行う
# cat << "_EOF_" > /etc/yum.repos.d/xymon.repo


2)以下をそのまま貼り付ける。
----------------------------------------------------------------------------------
[xymon]
name=Terabithia RPM package for Xymon Monitor
baseurl=http://terabithia.org/rpms/xymon/el$releasever/$basearch/
gpgcheck=1
gpgkey=http://terabithia.org/rpms/RPM-GPG-KEY-JCLEAVER
enabled=1
_EOF_
----------------------------------------------------------------------------------

3)リポジトリーの追加を行う
yum install epel-release


4)Xymon(クライアント)のインストールを行う
# yum -y install xymon-client


5)コンフィグの設定を行う
①Xymon serverのIPを追加する

# vi /etc/xymon-client/xymonclient.cfg
---------------- xymonclient.cfg ---------------------
XYMONSERVERS="192.168.1.150"
----------------------------------------------------------

6)サービスを有効化にしておく

# systemctl enable xymonlaunch
# systemctl start xymonlaunch

Xymonサーバーの構築方法

■以下は、centos7でのXymonのインストール方法になる。


1)レポジトリー編集を行う
# cat << "_EOF_" > /etc/yum.repos.d/xymon.repo


2)以下をそのまま貼り付ける。
----------------------------------------------------------------------------------
[xymon]
name=Terabithia RPM package for Xymon Monitor
baseurl=http://terabithia.org/rpms/xymon/el$releasever/$basearch/
gpgcheck=1
gpgkey=http://terabithia.org/rpms/RPM-GPG-KEY-JCLEAVER
enabled=1
_EOF_
----------------------------------------------------------------------------------

3)リポジトリーの追加を行う
yum install epel-release


4)Xymonのインストールを行う
# yum -y install xymon xymon-client


5) xymonserver.cfgにXymonのホスト名とIPを記載する。

# vi /etc/xymon/xymonserver.cfg
----------------- xymonserver.cfg ----------------------------------------
XYMONSERVERHOSTNAME="xymon"            
XYMONSERVERIP="192.168.1.150"
-------------------------------------------------------------------------------

6) hosts.cfgに”IPアドレス、監視対象のホスト名、監視項目”を記載する。

# vi /etc/xymon/hosts.cfg
------------------------------------ hosts.cfg ------------------------------------------------
192.168.1.150   Xymon     # bbd http://192.168.1.150/xymon/xymon.html
192.168.1.111   web02      # conn ssh cont=cont1;http://192.168.1.111/test.html
------------------------------------------------------------------------------------------------


7) analysis.cfgに監視対象のホストからXymonに送られたCPU,ディスク,メモリ
プロセスの情報を記載する。

# vi /etc/xymon/analysis.cfg
------------------------------------ analysis.cfg --------------------------------------------------
HOST=192.168.1.111
        LOAD    4.5 5.0
        CLOCK 15 red
        DISK    * 75 80
        MEMPHYS 100 101
        MEMSWAP 15 20
        MEMACT  100 101
        PROC httpd TRACK=httpd
        PROC master
        PROC crond
        PROC sshd
        PORT LOCAL=%[.:]22$ STATE=LISTEN "TEXT=SSH listen" 
        PORT LOCAL=%[.:]22$ STATE=ESTABLISHED MIN=0 MAX=5 TRACK=ssh "TEXT=SSH established" 
        PORT LOCAL=%[.:]25$ STATE=LISTEN "TEXT=smtp listen" 
        PORT LOCAL=%[.:]80$ STATE=LISTEN "TEXT=http listen" 
        PORT LOCAL=%[.:]80$ STATE=ESTABLISHED MIN=0 MAX=100 TRACK=http "TEXT=http established"
        LOG /var/log/messages %(kernel.*error) IGNORE=%(ERST|GHES) COLOR=red
        LOG /var/log/messages %(kernel.*warn) IGNORE=%(ERST|GHES) COLOR=red
        LOG /var/log/messages %(panic|halt) COLOR=red
 -------------------------------------------------------------------------------------------------------------


7)アラートメールの通知先とアラートに関するルールを記述する。

# vi /etc/xymon/alerts.cfg
-------------------------------- alerts.cfg----------------------------------------------------------
HOST=web02
MAIL test@gmail.com SERVICE=conn COLOR=red DURATION>5 REPEAT=5m RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=cpu,disk,memory COLOR=red DURATION>10 REPEAT=1d RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=ssh COLOR=red DURATION>5 REPEAT=1d RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=http,cont1,cont2 COLOR=red DURATION>5 REPEAT=5m RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=procs,ports COLOR=red DURATION>10 REPEAT=5m RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=idslog,maillog COLOR=red REPEAT=1d FORMAT=plain
MAIL test@gmail.com SERVICE=cronjob COLOR=red DURATION>5 REPEAT=5m RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=cronjob COLOR=yellow DURATION>10 REPEAT=1d RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=cronjob COLOR=yellow DURATION>10 REPEAT=1d RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=msgs COLOR=red REPEAT=1d FORMAT=plain
MAIL test@gmail.com SERVICE=cacert COLOR=red DURATION>5 REPEAT=1d RECOVERED FORMAT=plain
MAIL test@gmail.com SERVICE=* EXSERVICE=inode,files COLOR=purple RECOVERED REPEAT=1d FORMAT=plain
-----------------------------------------------------------------------------------------------------

8)Xymon管理者用のアカウントとパスワードの作成を行う

# htpasswd -c /etc/xymon/xymonpasswd test_xymon
# New password: test_xymon
# Re-type new password: test_xymon


9)httpdサービスを起動させる
# systemctl start httpd
# systemctl enable httpd

10)Xymonサービスを起動させる
# systemctl start xymon
# systemctl enable xymon

11) Xymonのアラートメール送信に必要ミドルウェアをインストールする。

# yum -y install nmh



□■Postfixの設定□■

1)main.cf にpostfixの設定値を入力する。

vi /etc/postfix/main.cf
------------------------ main.cf ---------------------------------
myhostname = Xymon.dpstest.local
mydomain = dpstest.local
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 
mynetworks = 127.0.0.0/8,192.168.1.0/24
home_mailbox = Maildir/     
------------------------------------------------------------------------

2)piostfixの再起動を行う
# systemctl restart postfix
# systemctl enable postfix


Lambda + SSM Run Commandで、数十台のEC2のuserdata結果を一括確認する

コードを1枚貼って、テストイベントを実行するだけで、 全台の確認結果が返ってくる手順です。 [ゴール] Nameタグが web-* / api-* / batch-* のEC2すべてに確認コマンドを流し、 NGの台だけ を結果に表示します。確認対象のuserdata(Ubu...