try to use filebeat.
ログファイルが出力されたら、filebeatを実行したコンソールに出力されるまで試してみました。
設定
# cat filebeat.yml | sed '/^ *#/d' | sed '/^$/d'
filebeat.prospectors:
- input_type: log
paths:
- /tmp/log/*.log
output.console:
pretty: false
ログ出力
# pwd /tmp/log # echo "test message" > test.log # ls -l total 4 -rw-r--r-- 1 root root 13 Jan 2 05:38 test.log # echo "test message2" >> test.log # ls -l total 4 -rw-r--r-- 1 root root 27 Jan 2 05:44 test.log #
起動して、コンソール出力された内容
# ./filebeat -c filebeat.yml
{"@timestamp":"2017-01-02T05:39:05.320Z","beat":{"hostname":"febbb71e5f22","name":"febbb71e5f22","version":"5.1.1"},"input_type":"log","message":"test message","offset":13,"source":"/tmp/log/test.log","type":"log"}
{"@timestamp":"2017-01-02T05:44:55.349Z","beat":{"hostname":"febbb71e5f22","name":"febbb71e5f22","version":"5.1.1"},"input_type":"log","message":"test message2","offset":27,"source":"/tmp/log/test.log","type":"log"}
docker run with '-d' option
[root@localhost ~]# docker run -d --name ansible centos:7 tail -f /dev/null 97f8213ed1883270d11067a24bc6f718e77c5918005d58206d6b569fc02e8e58 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 97f8213ed188 centos:7 "tail -f /dev/null" 2 seconds ago Up 1 seconds ansible [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 97f8213ed188 centos:7 "tail -f /dev/null" 6 seconds ago Up 5 seconds ansible [root@localhost ~]#
docker pull image
[root@localhost ~]# docker pull centos Using default tag: latest latest: Pulling from library/centos 45a2e645736c: Pull complete Digest: sha256:c577af3197aacedf79c5a204cd7f493c8e07ffbce7f88f7600bf19c688c38799 Status: Downloaded newer image for centos:latest [root@localhost ~]# docker pull centos:7 7: Pulling from library/centos Digest: sha256:c577af3197aacedf79c5a204cd7f493c8e07ffbce7f88f7600bf19c688c38799 Status: Downloaded newer image for centos:7 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos 7 67591570dd29 4 days ago 191.8 MB centos latest 67591570dd29 4 days ago 191.8 MB hello-world latest c54a2cc56cbb 5 months ago 1.848 kB [root@localhost ~]#
start docker (version 1.12.5)
[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker version
Client:
Version: 1.12.5
API version: 1.24
Go version: go1.6.4
Git commit: 7392c3b
Built: Fri Dec 16 02:23:59 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.5
API version: 1.24
Go version: go1.6.4
Git commit: 7392c3b
Built: Fri Dec 16 02:23:59 2016
OS/Arch: linux/amd64
[root@localhost ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[root@localhost ~]#
install docker in CentOS 7
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@localhost ~]# getenforce Enforcing [root@localhost ~]#
[root@localhost ~]# yum install docker-engine Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Resolving Dependencies --> Running transaction check ---> Package docker-engine.x86_64 0:1.12.5-1.el7.centos will be installed --> Processing Dependency: docker-engine-selinux >= 1.12.5-1.el7.centos for package: docker-engine-1.12.5-1.el7.centos.x86_64 --> Processing Dependency: libcgroup for package: docker-engine-1.12.5-1.el7.centos.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-engine-1.12.5-1.el7.centos.x86_64 --> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-1.12.5-1.el7.centos.x86_64 --> Running transaction check ---> Package docker-engine-selinux.noarch 0:1.12.5-1.el7.centos will be installed --> Processing Dependency: policycoreutils-python for package: docker-engine-selinux-1.12.5-1.el7.centos.noarch ---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed ---> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed ---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed --> Running transaction check ---> Package policycoreutils-python.x86_64 0:2.5-9.el7 will be installed --> Processing Dependency: policycoreutils = 2.5-9.el7 for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libsemanage-python >= 2.5-4 for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-9.el7.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-9.el7.x86_64 --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.6.5-3.el7 will be installed ---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.5-4.el7 will be installed ---> Package policycoreutils.x86_64 0:2.5-8.el7 will be updated ---> Package policycoreutils.x86_64 0:2.5-9.el7 will be an update ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================== Package Arch Version Repository Size =================================================================================================== Installing: docker-engine x86_64 1.12.5-1.el7.centos dockerrepo 19 M Installing for dependencies: audit-libs-python x86_64 2.6.5-3.el7 base 70 k checkpolicy x86_64 2.5-4.el7 base 290 k docker-engine-selinux noarch 1.12.5-1.el7.centos dockerrepo 28 k libcgroup x86_64 0.41-11.el7 base 65 k libseccomp x86_64 2.3.1-2.el7 base 56 k libsemanage-python x86_64 2.5-4.el7 base 103 k libtool-ltdl x86_64 2.4.2-21.el7_2 base 49 k policycoreutils-python x86_64 2.5-9.el7 updates 444 k python-IPy noarch 0.75-6.el7 base 32 k setools-libs x86_64 3.3.8-1.1.el7 base 612 k Updating for dependencies: policycoreutils x86_64 2.5-9.el7 updates 841 k Transaction Summary =================================================================================================== Install 1 Package (+10 Dependent packages) Upgrade ( 1 Dependent package) Total download size: 22 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. warning: /var/cache/yum/x86_64/7/base/packages/checkpolicy-2.5-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Public key for checkpolicy-2.5-4.el7.x86_64.rpm is not installed (1/12): checkpolicy-2.5-4.el7.x86_64.rpm | 290 kB 00:00:00 (2/12): audit-libs-python-2.6.5-3.el7.x86_64.rpm | 70 kB 00:00:00 (3/12): libcgroup-0.41-11.el7.x86_64.rpm | 65 kB 00:00:00 (4/12): libseccomp-2.3.1-2.el7.x86_64.rpm | 56 kB 00:00:00 (5/12): libsemanage-python-2.5-4.el7.x86_64.rpm | 103 kB 00:00:00 (6/12): libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm | 49 kB 00:00:00 (7/12): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 warning: /var/cache/yum/x86_64/7/dockerrepo/packages/docker-engine-selinux-1.12.5-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY Public key for docker-engine-selinux-1.12.5-1.el7.centos.noarch.rpm is not installed (8/12): docker-engine-selinux-1.12.5-1.el7.centos.noarch.rpm | 28 kB 00:00:00 Public key for policycoreutils-python-2.5-9.el7.x86_64.rpm is not installed (9/12): policycoreutils-python-2.5-9.el7.x86_64.rpm | 444 kB 00:00:00 (10/12): setools-libs-3.3.8-1.1.el7.x86_64.rpm | 612 kB 00:00:00 (11/12): policycoreutils-2.5-9.el7.x86_64.rpm | 841 kB 00:00:00 (12/12): docker-engine-1.12.5-1.el7.centos.x86_64.rpm | 19 MB 00:00:02 --------------------------------------------------------------------------------------------------- Total 7.4 MB/s | 22 MB 00:00:02 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-3.1611.el7.centos.x86_64 (@anaconda) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Is this ok [y/N]: y Retrieving key from https://yum.dockerproject.org/gpg Importing GPG key 0x2C52609D: Userid : "Docker Release Tool (releasedocker) <docker@docker.com>" Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d From : https://yum.dockerproject.org/gpg Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : policycoreutils-2.5-9.el7.x86_64 1/13 Installing : libcgroup-0.41-11.el7.x86_64 2/13 Installing : setools-libs-3.3.8-1.1.el7.x86_64 3/13 Installing : libsemanage-python-2.5-4.el7.x86_64 4/13 Installing : checkpolicy-2.5-4.el7.x86_64 5/13 Installing : python-IPy-0.75-6.el7.noarch 6/13 Installing : audit-libs-python-2.6.5-3.el7.x86_64 7/13 Installing : policycoreutils-python-2.5-9.el7.x86_64 8/13 Installing : docker-engine-selinux-1.12.5-1.el7.centos.noarch 9/13 Re-declaration of boolean virt_sandbox_use_fusefs Failed to create node Bad boolean declaration at /etc/selinux/targeted/tmp/modules/100/virt/cil:159 /usr/sbin/semodule: Failed! libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400. restorecon: lstat(/var/lib/docker) failed: No such file or directory warning: %post(docker-engine-selinux-1.12.5-1.el7.centos.noarch) scriptlet failed, exit status 255 Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.12.5-1.el7.centos.noarch Installing : libtool-ltdl-2.4.2-21.el7_2.x86_64 10/13 Installing : libseccomp-2.3.1-2.el7.x86_64 11/13 Installing : docker-engine-1.12.5-1.el7.centos.x86_64 12/13 Cleanup : policycoreutils-2.5-8.el7.x86_64 13/13 Verifying : libseccomp-2.3.1-2.el7.x86_64 1/13 Verifying : libtool-ltdl-2.4.2-21.el7_2.x86_64 2/13 Verifying : docker-engine-selinux-1.12.5-1.el7.centos.noarch 3/13 Verifying : audit-libs-python-2.6.5-3.el7.x86_64 4/13 Verifying : policycoreutils-python-2.5-9.el7.x86_64 5/13 Verifying : python-IPy-0.75-6.el7.noarch 6/13 Verifying : libcgroup-0.41-11.el7.x86_64 7/13 Verifying : docker-engine-1.12.5-1.el7.centos.x86_64 8/13 Verifying : checkpolicy-2.5-4.el7.x86_64 9/13 Verifying : libsemanage-python-2.5-4.el7.x86_64 10/13 Verifying : policycoreutils-2.5-9.el7.x86_64 11/13 Verifying : setools-libs-3.3.8-1.1.el7.x86_64 12/13 Verifying : policycoreutils-2.5-8.el7.x86_64 13/13 Installed: docker-engine.x86_64 0:1.12.5-1.el7.centos Dependency Installed: audit-libs-python.x86_64 0:2.6.5-3.el7 checkpolicy.x86_64 0:2.5-4.el7 docker-engine-selinux.noarch 0:1.12.5-1.el7.centos libcgroup.x86_64 0:0.41-11.el7 libseccomp.x86_64 0:2.3.1-2.el7 libsemanage-python.x86_64 0:2.5-4.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2 policycoreutils-python.x86_64 0:2.5-9.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-1.1.el7 Dependency Updated: policycoreutils.x86_64 0:2.5-9.el7 Complete! [root@localhost ~]#
remove '#' and empty lines
設定ファイルを確認する際に、コメント行などを表示しないようにする。
コメント行削除する場合には、sedで、
$ cat filename | sed -e '/^#.*$/d'
空行も削除するなら
$ sed -e 's/#.*$//' -e '/^$/d'
さらに以下を行うと、空行が2回続く場合に1行にまとめる。
$ cat filename | awk '{if ($0 != "" ){print $0; a=0;} else if($0 == "" && a == 0){print $0; a=1;} else {a=1}}'
After Installation, Verification StackStorm status.
Verify
なんか、いろいろFailedとか出てます。 OKなのかどうなのか微妙だ。。。
[root@stackstorm ~]# st2 --version
st2 2.0.0
[root@stackstorm ~]# st2 action list --pack=core
+-------------------+------+-----------------------------------+
| ref | pack | description |
+-------------------+------+-----------------------------------+
| core.announcement | core | Action that broadcasts the |
| | | announcement to all stream |
| | | consumers. |
| core.http | core | Action that performs an http |
| | | request. |
| core.local | core | Action that executes an arbitrary |
| | | Linux command on the localhost. |
| core.local_sudo | core | Action that executes an arbitrary |
| | | Linux command on the localhost. |
| core.noop | core | Action that does nothing |
| core.remote | core | Action to execute arbitrary linux |
| | | command remotely. |
| core.remote_sudo | core | Action to execute arbitrary linux |
| | | command remotely. |
| core.sendmail | core | This sends an email |
| core.windows_cmd | core | Action to execute arbitrary |
| | | Windows command remotely. |
+-------------------+------+-----------------------------------+
[root@stackstorm ~]# st2 run core.local -- date -R
.
id: 57e413d602ebd5155fd887a5
status: failed
parameters:
cmd: date -R
result:
failed: true
return_code: 1
stderr: 'sudo: sorry, you must have a tty to run sudo'
stdout: ''
succeeded: false
[root@stackstorm ~]# st2 execution list
+--------------------------+------------+--------------+---------------------+-----------------+---------------+
| id | action.ref | context.user | status | start_timestamp | end_timestamp |
+--------------------------+------------+--------------+---------------------+-----------------+---------------+
| 57e413d602ebd5155fd887a5 | core.local | stanley | failed (0s elapsed) | Thu, 22 Sep | Thu, 22 Sep |
| | | | | 2016 17:24:38 | 2016 17:24:38 |
| | | | | UTC | UTC |
+--------------------------+------------+--------------+---------------------+-----------------+---------------+
[root@stackstorm ~]# st2 run core.remote hosts='localhost' -- uname -a
..
id: 57e413e802ebd5155fd887a8
status: succeeded
parameters:
cmd: uname -a
hosts: localhost
result:
localhost:
failed: false
return_code: 0
stderr: ''
stdout: 'Linux stackstorm 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux'
succeeded: true
[root@stackstorm ~]# st2 run packs.install packs=st2
...................................
id: 57e413f602ebd5155fd887ab
action.ref: packs.install
parameters:
packs:
- st2
status: failed
error: sudo: sorry, you must have a tty to run sudo
traceback: None
failed_on: reload
start_timestamp: 2016-09-22T17:25:10.003137Z
end_timestamp: 2016-09-22T17:26:18.918321Z
+--------------------------+-------------------------+----------------+----------------+-----------------+
| id | status | task | action | start_timestamp |
+--------------------------+-------------------------+----------------+----------------+-----------------+
| 57e413f602ebd514c4a27e59 | succeeded (55s elapsed) | download | packs.download | Thu, 22 Sep |
| | | | | 2016 17:25:10 |
| | | | | UTC |
| 57e4142d02ebd514c4a27e5b | succeeded (1s elapsed) | virtualenv_pre | packs.virtuale | Thu, 22 Sep |
| | | run | nv_prerun | 2016 17:26:05 |
| | | | | UTC |
| 57e4142f02ebd514c4a27e5d | succeeded (10s elapsed) | setup_virtuale | packs.setup_vi | Thu, 22 Sep |
| | | nv | rtualenv | 2016 17:26:07 |
| | | | | UTC |
| 57e4143902ebd514c4a27e5f | failed (1s elapsed) | reload | packs.load | Thu, 22 Sep |
| | | | | 2016 17:26:17 |
| | | | | UTC |
+--------------------------+-------------------------+----------------+----------------+-----------------+
[root@stackstorm ~]#