Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active January 14, 2016 03:33
Show Gist options
  • Save tkuchiki/63c739852e499a765a41 to your computer and use it in GitHub Desktop.
Save tkuchiki/63c739852e499a765a41 to your computer and use it in GitHub Desktop.
CentOS6 で norikra(+ listener-mackerel) を動かす

build

docker build -t norikra/listener .

run

mkdir /var/lib/norikra
docker run -d -p 26578:26578 -p 26571:26571 -v /var/lib/norikra/:/var/lib/norikra/ -v /var/log/norikra:/var/log/norikra -t norikra/listener
FROM centos:centos6
WORKDIR /usr/local
RUN yum update -y && yum install -y java-1.7.0-openjdk tar
RUN curl -L https://s3.amazonaws.com/jruby.org/downloads/9.0.4.0/jruby-bin-9.0.4.0.tar.gz | tar zxf -
ENV PATH /usr/local/jruby-9.0.4.0/bin:$PATH
RUN gem install norikra --no-ri --no-rdoc
RUN gem install norikra-listener-mackerel --no-ri --no-rdoc
RUN gem install norikra-udf-percentile --no-ri --no-rdoc
VOLUME ["/var/lib/norikra", "/var/log/norikra"]
EXPOSE 26571 26578
CMD ["norikra", "start", "--stats=/var/lib/norikra/stats.json", "--dump-stat-interval=60", "--logdir=/var/log/norikra"]

install

yum groupinstall -y "Development Tools"
yum install -y openssl-devel
curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh
chkconfig td-agent on
/opt/td-agent/embedded/bin/fluent-gem install fluent-plugin-norikra --no-document

config

/etc/td-agent/td-agent.conf

<source>
  type forward
  port 24224
</source>

<match nginx.access>
  type copy
  <store>
    type norikra
    norikra localhost:26571
    target_string nginx_access
    # remove_tag_prefix nginx.access.status_count
    # target_map_tag ture
  </store>
</match>

start

service td-agent start
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format ltsv 'host:$remote_addr\t'
'user:$remote_user\t'
'time:$time_iso8601\t'
'method:$request_method\t'
'uri:$request_uri\t'
'protocol:$server_protocol\t'
'status:$status\t'
'size:$body_bytes_sent\t'
'request_time:$request_time\t'
'apptime:$upstream_response_time\t'
'upstream_addr:$upstream_addr\t'
'referer:$http_referer\t'
'user_agent:$http_user_agent\t'
'vhost:$host\t';
access_log /var/log/nginx/access.log ltsv;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
index index.html index.htm;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

install

yum install -y nginx
chkconfig nginx on
# deploy nginx.conf
service nginx start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment