ラベル Amazon Linux AMI の投稿を表示しています。 すべての投稿を表示
ラベル Amazon Linux AMI の投稿を表示しています。 すべての投稿を表示

2017-02-14

MySQLでユーザーに設定したパスワードが効かなくて嵌った件

Amazon Linuxでyumを使ってMySQL56をインストールし起動し、データベースとユーザーを作成して
ログインしてみると設定したパスワードでログインできないではありませんか(;゜〇゜)

mysql> create database mydb character set utf8;
mysql> grant all on mydb.* to user identified by 'xxxxx';

$ mysql -u user -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'user '@'localhost' (using password: YES)

ところが、パスワードなしでログインを試みるとは入れてしまいましたΣ(゜д゜;)

プロセスを確認してみると指定したユーザーでログインしています。

$ mysql -u user
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.6.35 MySQL Community Server (GPL)

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> show processlist;
+----+-----------+-----------+------+---------+------+-------+------------------+
| Id | User  | Host      | db   | Command | Time | State | Info  |
+----+-----------+-----------+------+---------+------+-------+------------------+
| 28 | user      | localhost | NULL | Query   |    0 | init  | show processlist |
+----+-----------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

ユーザーテーブルどーなってるか確認してみるとユーザー名なし、パスワードなしの登録が入っていました

あやしいです(;一_一)

mysql> select user,host from user;
+-----------+------------------+-------------------------------------------+
| user     | host        | password       |
+-----------+------------------+-------------------------------------------+
| user      | %         | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| root     | 127.0.0.1        |                                           |
| root     | ::1        |                                           |
|     | ip-xxx-xx-xx-xxx |                                           |
| root     | ip-xxx-xx-xx-xxx |                                           |
|     | localhost        |                                           |
| root     | localhost        |                                           |
+-----------+------------------+-------------------------------------------+

mysql> select host from user where user="";
+------------------+
| host     |
+------------------+
| ip-xxx-xx-xx-xxx |
| localhost    |
+------------------+
2 rows in set (0.00 sec)

怪しいので消してしまいましょうヽ(´ー`)/
mysql> delete from user where user="";
Query OK, 2 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

そしたら、次の通り入れました!ヾ(*・∀・)ノ"
$ mysql -u user -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.6.35 MySQL Community Server (GPL)

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> 

2016-02-08

Amazon LinuxにtcpflowをインストールしてHTTPリクエスト&レスポンスをキャプチャして覗いてみる

http://apt.sw.be/redhat/el7/en/x86_64/rpmforge/RPMS/ からtcpflowの最新rpmパッケージを探してインストール

# yum install `curl -s http://apt.sw.be/redhat/el7/en/x86_64/rpmforge/RPMS/|grep -o '"tcpflow[^"]*'|sed 's|"|http://apt.sw.be/redhat/el7/en/x86_64/rpmforge/RPMS/|'`

Dependencies Resolved

======================================================================================================================================
 Package   Arch   Version    Repository      Size
======================================================================================================================================
Installing:
 tcpflow   x86_64   0.21-1.2.el7.rf   /tcpflow-0.21-1.2.el7.rf.x86_64    61 k

Transaction Summary
======================================================================================================================================
Install  1 Package
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tcpflow-0.21-1.2.el7.rf.x86_64             1/1 
  Verifying  : tcpflow-0.21-1.2.el7.rf.x86_64             1/1 

Installed:
  tcpflow.x86_64 0:0.21-1.2.el7.rf                  

Complete!

eth0の80番ポートのパケットを試しにキャプチャ
※-cでコンソール出力,-sで表示できない文字を.で表示
ELBからのヘルスチェックのリクエスト&レスポンスが取得されました。

# tcpflow -cs -i eth0 port 80
tcpflow[6577]: listening on eth0
010.000.012.250.26633-010.000.022.012.00080: GET / HTTP/1.1
host: 10.0.22.12
User-Agent: ELB-HealthChecker/1.0
Accept: */*
Connection: keep-alive

010.000.022.012.00080-010.000.012.250.26633: HTTP/1.1 200 OK
Date: Mon, 08 Feb 2016 03:34:19 GMT
Server: Apache
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive


manpage
# man tcpflow
tcpflow(1)

NAME
       tcpflow - TCP flow recorder

SYNOPSIS
       tcpflow [-chpsv] [-b max_bytes] [-d debug_level] [-f max_fds] [-i iface] [-r file] [expression]

DESCRIPTION
       tcpflow is a program that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis or debugging.  A program like tcpdump(4) shows a summary of pack‐
       ets seen on the wire, but usually doesn't store the data that's actually being transmitted.  In contrast, tcpflow reconstructs the actual data streams and stores each flow in a separate file for later analysis.  tcpflow
       understands TCP sequence numbers and will correctly reconstruct data streams regardless of retransmissions or out-of-order delivery.

       tcpflow stores all captured data in files that have names of the form
     192.168.101.102.02345-010.011.012.013.45103
       where the contents of the above file would be data transmitted from host 192.168.101.102 port 2345, to host 10.11.12.13 port 45103.

OPTIONS
       -b     Max bytes per flow.  Capture no more than max_bytes bytes per flow.  Any data captured for a flow beyond max_bytes from the first byte captured will be discarded.  The default is to store an unlimited number of bytes
       per flow.

       -c     Console print.  Print the contents of packets to stdout as they are received, without storing any captured data to files (implies -s ).

       -d     Debug level.  Set the level of debugging messages printed to stderr to debug_level.  Higher numbers produce more messages.  -d 0 causes completely silent operation.  -d 1 , the default, produces minimal status mes‐
       sages.  -d 10 produces verbose output equivalent to -v . Numbers higher than 10 can produce a large amount of debugging information useful only to developers.

       -f     Max file descriptors used.  Limit the number of file descriptors used by tcpflow to max_fds.  Higher numbers use more system resources, but usually perform better.  If the underlying operating system supports the
       setrlimit() system call, the OS will be asked to enforce the requested limit.  The default is for tcpflow to use the maximum number of file descriptors allowed by the OS.  The -v option will report how many file
       descriptors tcpflow is using.

       -h     Help.  Print usage information and exit.

       -i     Interface name.  Capture packets from the network interface named iface. If no interface is specified with -i , a reasonable default will be used by libpcap automatically.

       -p     No promiscuous mode.  Normally, tcpflow attempts to put the network interface into promiscuous mode before capturing packets.  The -p option tells tcpflow not to put the interface into promiscuous mode.  Note that it
       might already be in promiscuous mode for some other reason.

       -r     Read from file.  Read packets from file, which was created using the -w option of tcpdump(1).  Standard input is used if file is ``-''.  Note that for this option to be useful, tcpdump's -s option should be used to
       set the snaplen to the MTU of the interface (e.g., 1500) while capturing packets.

       -s     Strip non-printables.  Convert all non-printable characters to the "." character before printing packets to the console or storing them to a file.

       -v     Verbose operation.  Verbosely describe tcpflow's operation.  Equivalent to -d 10 .

2016-02-04

Amazon Linuxで無料のウイルススキャン実施

オープンソースなantivirus engineであるClamAVが利用できます。

■インストール
# yum install clamav

■設定
# vi /etc/freshclam.conf
Example  表記をコメントアウト

■定義ファイル更新
freshclam

■スキャン実行
clamscan --exclude-dir="/sys/" -r -i /

※以下のようなエラーが出るので、回避策として/sys/を除外しています
LibClamAV Warning: fmap_readpage: pread fail: asked for 4085 bytes @ offset 11, got 0

2015-09-29

Amazon Linuxにrsyslog v8をインストール

# vi /etc/yum.repos.d/rsyslog.repo
----
[rsyslog_v8]
name=Adiscon CentOS-$releasever - local packages for $basearch
baseurl=http://rpms.adiscon.com/v8-stable/epel-7/$basearch
enabled=0
gpgcheck=0
gpgkey=http://rpms.adiscon.com/RPM-GPG-KEY-Adiscon
protect=1
----
# /usr/bin/yum install rsyslog --enablerepo=rsyslog_v8 --setopt=rsyslog_v8.priority=1

=======================================================================================================
 Package        Arch        Version     Repository        Size
=======================================================================================================
Updating:
 rsyslog        x86_64        8.13.0-1.el7    rsyslog_v8       627 k
Installing for dependencies:
 json-c         x86_64        0.11-6.8.amzn1    amzn-main        31 k
 libestr        x86_64        0.1.10-1.el7    rsyslog_v8       9.3 k
 libgt         x86_64        0.3.11-1.el7    rsyslog_v8        58 k
 libksi         x86_64        3.2.2.0-1.el7    rsyslog_v8        96 k
 liblogging        x86_64        1.0.5-1.el7    rsyslog_v8        25 k

Transaction Summary
=======================================================================================================
Install      ( 5 Dependent packages)
Upgrade  1 Package

Total download size: 846 k
Is this ok [y/d/N]: y

これで行けましたヾ(*・∀・)ノ”

2012-07-25

make: command not found on Amazon Linux

デフォルトだと開発ツールが入っていないので
yum groupinstall "Development Tools"
yum groupinstall "Development Libraries"
とやってインストールしてあげる必要があるみたいです。

2010-10-15

Amazon Linux AMI 64bitにmuninインストール

yum install cpan httpd

wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/csbuild:/Apache/openSUSE_10.3/x86_64/libdbi0-0.8.3-9.1.x86_64.rpm
rpm -ivH libdbi0-0.8.3-9.1.x86_64.rpm

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm  
rpm -ivH rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
vi /etc/yum.repos.d/rpmforge.repo    ---> enabled=0に編集

yum --enablerepo=rpmforge install munin

cpan > install HTML::Template

mkdir /usr/lib/perl5/vendor_perl/5.10.0/
cp -p /usr/lib/perl5/vendor_perl/5.8.8/Munin.pm /usr/lib/perl5/vendor_perl/5.10.0/Munin.pm
cp -pr /usr/lib64/perl5/vendor_perl/5.8.8 /usr/lib64/perl5/vendor_perl/5.10.0

wget http://neo.fsr.jp:8888/data_box/RRDs.so -O /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/RRDs/RRDs.so

service httpd start

2010-10-08

Amazon Linux AMIにmuninを導入

デフォルトのリポジトリではyumでmuninが見つからないので、rootになってrpmforgeのリポジトリを追加
sudo su -
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -ivH rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
vi /etc/yum.repos.d/rpmforge.repo
デフォルトではRPMforge リポジトリを有効にしないように
enabled = 0
に編集する。
rpmforgeを有効にしてmuninとmunin-nodeをインストール
yum --enablerepo=rpmforge install munin munin-node
とこんなこと言われる・・・
--> Finished Dependency Resolution
Error: Package: rrdtool-1.4.4-1.el5.rf.x86_64 (rpmforge)
           Requires: libdbi.so.0()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
言われるままに--skip-brokenオプションをくっつけてリトライ。
yum --enablerepo=rpmforge --skip-broken install munin munin-node
お?うまくいった?(・・;
munin-nodeを再起動してみるとなにやらエラーが・・・
# service munin-node restart
Stopping Munin Node agents: cat: /var/run/munin/munin-node.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
                                                           [FAILED]
Starting Munin Node: Can't locate Net/Server/Fork.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/local/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl) at /usr/sbin/munin-node line 130.
BEGIN failed--compilation aborted at /usr/sbin/munin-node line 130.
                                                           [  OK  ]
Net/Server/Fork.pmが見つからねーぞってことなのでcpanでインストール
# cpan install Net::Server::Fork
-bash: cpan: command not found
デフォルトでは入ってないらしい・・・てことでcpanのインストールから
yum install cpan
cpanを起動
cpan
なんか色々でてくるけどとりあえずyesで答えておく。
そして、Net::Server::Forkをインストール
cpan[1]> install Net::Server::Fork
(中略)
t/Port_Configuration.t .... Can't locate Test/More.pm in @INC (@INC contains: /root/.cpan/build/Net-Server-0.99-I0aiCB/blib/lib /root/.cpan/build/Net-Server-0.99-I0aiCB/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/local/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/share/perl5 /usr/lib64/perl5 /usr/share/perl5 /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/local/lib/perl5/site_perl/5.10.0 /usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl .) at t/Port_Configuration.t line 13.
BEGIN failed--compilation aborted at t/Port_Configuration.t line 13.
t/Port_Configuration.t .... Dubious, test returned 2 (wstat 512, 0x200)
(中略)
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 RHANDOM/Net-Server-0.99.tar.gz               : make_test NO
Test/More.pmが足りないらしい・・・
てことでまずはTest::Moreからインストール
cpan[2]> install Test::More
cpan[3]> install Net::Server::Fork
無事入ったようなので、munin-nodeの再起動をリトライ
# service munin-node restart
Stopping Munin Node agents: cat: /var/run/munin/munin-node.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
                                                           [FAILED]
Starting Munin Node:                                       [  OK  ]
なんかエラーでたけど、さっきと違う模様。
プロセスIDのファイルが作られてなかったようですね。
もう一度やったらうまくいきました。
# service munin-node restart
Stopping Munin Node agents:                                [  OK  ]
Starting Munin Node:                                       [  OK  ]

2010-10-07

Amazon Linux AMIでrootになるには?

  Amazon Linux AMIを試してみた。

いつものようにインスタンスを起動して
ssh -i keypair root@ec2-xxx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com
でログインしようとすると
Please login as the ec2-user user rather than root user.
と怒られてしまう。
rootではなくec2-userでログインしてねってことなので、言われるままに、ec2-userでログイン

ssh -i keypair ec2-user@ec2-xxx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com
ec2-userにはsudo権限があって特にパスワードを求められるわけでもないので
sudo su -
でrootになれる。