1.4设置开机启动
chkconfig nginx on
/etc/init.d/nginx start
-----------------------------------------------------------------------
访问nginx页面
AB压测工具
yum install httpd-tools -y
ab -n10000 -c1
-----------------------------------------------------------------------
2、安装及配置logstash
2.1安装完Java后,检测
yum install -y java
java -version
java version "1.7.0_99"
OpenJDK Runtime Environment (rhel-2.6.5.1.el6-x86_64 u99-b00)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
2.3安装logstash
rpm -ivh logstash-2.4.0.noarch.rpm
2.4基本的输入输出
/opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{} }'
Settings: Default pipeline workers: 1
Pipeline main started
e^Hhehe
2017-02-25T07:00:46.494Z ops-nginx01 hehe
test
\2017-02-25T07:00:57.475Z ops-nginx01 test
test
2017-02-25T07:01:02.499Z ops-nginx01 \test
2.5使用rubydebug详细输出
/opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{ codec => rubydebug} }'
Settings: Default pipeline workers: 1
Pipeline main started
hehe2017 # 输入 hehe2017
{
{
"message" => "hehe2017", # 输入的信息
"@version" => "1", # 版本
"@timestamp" => "2017-02-25T07:03:06.332Z", # 时间
"host" => "ops-nginx01" # 存放的主机节点
}
2.6检测语法是否有错
/opt/logstash/bin/logstash -f json.conf --configtest
Configuration OK
json格式显示内容
[root@ops-nginx01 conf.d]# /opt/logstash/bin/logstash -f json.conf
Settings: Default pipeline workers: 1
Pipeline main started
{
"@timestamp" => "2017-02-25T10:37:42.000Z",
"@version" => "1",
"client" => "172.16.8.4",
"url" => "/index.html",
"status" => "200",
"domain" => "172.16.8.201",
"host" => "172.16.8.201",
"size" => 3698,
"responsetime" => 0.0,
"referer" => "-",
"ua" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0",
"path" => "/var/log/nginx/access.log"
}
{
"@timestamp" => "2017-02-25T10:37:42.000Z",
"@version" => "1",
"client" => "172.16.8.4",
"url" => "/nginx-logo.png",
"status" => "200",
"domain" => "172.16.8.201",
"host" => "172.16.8.201",
"size" => 368,
"responsetime" => 0.0,
"referer" => "http://172.16.8.201/",
"ua" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0",
"path" => "/var/log/nginx/access.log"
}
2.7修改配置文件,将数据输出到Redis:
cat logstash.conf
input {
file {
path => ["/var/log/nginx/access.log"]
type => "nginx_log"
start_position => "beginning"
}
}
output {
redis {
host => "172.16.8.204"
key => 'logstash-redis'
data_type => 'list'
}
}
3、redis安装及配置
3.1安装所需包
yum install wget gcc gcc-c++ -y
3.2下载软件包
wget
3.3解压安装
cd/usr/local/src/
tar -xvf redis-3.0.7.tar.gz
redis-3.0.7
make
mkdir -p /usr/local/redis/{conf,bin}
cd utils/
cp mkrelease.sh /usr/local/redis/bin/
cd ../src
cp redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/
创建数据存放目录
mkdir -pv /data/redis/db
mkdir -pv /data/log/redis
dir ./ 修改为dir /data/redis/db/
vim +192 redis.conf
grep -n '^[a-Z]' redis.conf
42:daemonize no
46:pidfile /var/run/redis.pid
50:port 6379
59:tcp-backlog 511
79:timeout 0
95:tcp-keepalive 0
103:loglevel notice
108:logfile ""
123:databases 16
147:save 900 1
148:save 300 10
149:save 60 10000
164:stop-writes-on-bgsave-error yes
170:rdbcompression yes
179:rdbchecksum yes
182:dbfilename dump.rdb
192:dir /data/redis/db/
230:slave-serve-stale-data yes
246:slave-read-only yes
277:repl-diskless-sync no
289:repl-diskless-sync-delay 5
322:repl-disable-tcp-nodelay no
359:slave-priority 100
509:appendonly no
513:appendfilename "appendonly.aof"
539:appendfsync everysec
561:no-appendfsync-on-rewrite no
580:auto-aof-rewrite-percentage 100
581:auto-aof-rewrite-min-size 64mb
605:aof-load-truncated yes
623:lua-time-limit 5000
751:slowlog-log-slower-than 10000
755:slowlog-max-len 128
776:latency-monitor-threshold 0
822:notify-keyspace-events ""
829:hash-max-ziplist-entries 512
830:hash-max-ziplist-value 64
835:list-max-ziplist-entries 512
836:list-max-ziplist-value 64
843:set-max-intset-entries 512
848:zset-max-ziplist-entries 128
849:zset-max-ziplist-value 64
863:hll-sparse-max-bytes 3000
883:activerehashing yes
918:client-output-buffer-limit normal 0 0 0
919:client-output-buffer-limit slave 256mb 64mb 60
920:client-output-buffer-limit pubsub 32mb 8mb 60
937:hz 10
943:aof-rewrite-incremental-fsync yes
3.4启动redis服务
nohup /usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf &
3.5查看redis进程是否存在
ps -ef | grep redis
root 5000 1611 0 14:42 pts/0 00:00:00 /usr/local/redis/bin/redis-server *:6379
root 5004 1611 0 14:42 pts/0 00:00:00 grep redis
3.6查看redis默认6379端口
netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:38879 0.0.0.0:* LISTEN 1174/rpc.statd
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 5000/redis-server *
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1152/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1396/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1229/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1475/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1609/sshd
tcp 0 0 :::32799 :::* LISTEN 1174/rpc.statd
tcp 0 0 :::6379 :::* LISTEN 5000/redis-server *
tcp 0 0 :::111 :::* LISTEN 1152/rpcbind
tcp 0 0 :::22 :::* LISTEN 1396/sshd
tcp 0 0 ::1:631 :::* LISTEN 1229/cupsd
tcp 0 0 ::1:25 :::* LISTEN 1475/master
tcp 0 0 ::1:6010 :::* LISTEN 1609/sshd
4、安装配置logstash server
4.1JAVA及logstash安装配置
yum -y install java
java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
rpm -ivh logstash-2.4.0.noarch.rpm
4.2语法检查
/opt/logstash/bin/logstash -f ./logstash_server.conf --configtest
4.3配置文件
cat logstash_server.conf
input {
redis {
port => "6379"
host => "172.16.8.204"
data_type => "list"
key => "logstash-redis"
type => "redis-input"
}
}
output {
elasticsearch {
hosts => "172.16.8.206"
index => "nginx-log-%{+YYYY.MM.dd}"