grafana安装使用

安装

1
2
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2-1.x86_64.rpm 
sudo yum localinstall grafana-4.3.2-1.x86_64.rpm

配置文件

1
/etc/grafana/grafana.ini

启动

1
service grafana-server start

开机启动

1
sudo systemctl enable grafana-server.service

设置template依赖选择参数

1
2
$topic    SHOW TAG VALUES WITH KEY = "topic"    
$host SHOW TAG VALUES WITH KEY = "host" WHERE "topic" =~ /^$topic$/

pssh,pscp工具使用

pssh在多个主机上并行地运行命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-h 执行命令的远程主机列表,文件内容格式[user@]host[:port] 如 test@172.16.10.10:229
-H 执行命令主机,主机格式 user@ip:port
-l 远程机器的用户名
-p 一次最大允许多少连接
-P 执行时输出执行信息
-o 输出内容重定向到一个文件
-e 执行错误重定向到一个文件
-t 设置命令执行超时时间
-A 提示输入密码并且把密码传递给ssh(如果私钥也有密码也用这个参数)
-O 设置ssh一些选项
-x 设置ssh额外的一些参数,可以多个,不同参数间空格分开
-X 同-x,但是只能设置一个参数
-i 显示标准输出和标准错误在每台host执行完毕后

pssh -H stat@192.168.1.100:18822 -i -A "ls -l"

pscp

1
2
pscp -h ip文件 本地文件 远程目录
pscp -h hosts.txt -l root -r /tmp/i.txt /tmp

jmeter压测工具使用

安装

在官网下载压缩包,解压后进入文件夹即可

配置jmx

先在windows下执行 bin/jmeter.bat,
在图形界面下配置好参数,然后保存配置jmx文件

在linux上执行

1
2
3
4
# 启动执行server
bin/jmeter-server
# 执行压测任务
bin/jmeter -n -t metrics_interface/dcs.jmx -l report/metrics_interface.jtl.alpha -R127.0.0.1

参数说明

1
2
3
4
5
6
7
8
9
10
11
12
13
-n  This specifies JMeter is to run in non-gui mode
-t [name of JMX file that contains the Test Plan].
-l [name of JTL file to log sample results to].
-j [name of JMeter run log file].
-r Run the test in the servers specified by the JMeter property "remote_hosts"
-R [list of remote servers] Run the test in the specified remote servers
-g [path to CSV file] generate report dashboard only
-e generate report dashboard after load test
-o output folder where to generate the report dashboard after load test. Folder must not exist or be empty

The script also lets you specify the optional firewall/proxy server information:
-H [proxy server hostname or ip address]
-P [proxy server port]

influxdb安装

influxdb

1
2
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64.rpm
sudo yum localinstall influxdb-1.2.4.x86_64.rpm

chronograf

1
2
wget https://dl.influxdata.com/chronograf/releases/chronograf-1.3.2.1.x86_64.rpm
sudo yum localinstall chronograf-1.3.2.1.x86_64.rpm

influxdb配置文件

1
/etc/influxdb/influxdb.conf

命令

1
service influxdb start

创建数据保存策略

1
2
CREATE RETENTION POLICY "roll" ON "dc" DURATION 3d REPLICATION 1 DEFAULT
ALTER RETENTION POLICY "roll" ON "dc" DURATION 3d REPLICATION 1 SHARD DURATION 6h DEFAULT

常用命令

1
2
# 查看series
influx -port 10086 -database dc -execute 'show series'

python用gzip压缩string字符串,支持python2.6

压缩

1
2
3
4
5
6
7
def gzip_compress(buf, compresslevel=6):
out = StringIO.StringIO()
f = gzip.GzipFile(fileobj=out, mode="w", compresslevel=compresslevel)
f.write(buf)
f.close()
res = out.getvalue()
return res

解压缩

1
2
3
4
5
6
def gzip_decompress(buf):
obj = StringIO.StringIO(buf)
f = gzip.GzipFile(fileobj=obj)
result = f.read()
f.close()
return result

python编译安装

依赖

1
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel cyrus-sasl cyrus-sasl-devel

安装

1
2
3
4
tar zxvf Python-2.7.3.tgz
cd Python-2.7.3
./configure
make && make install

ambari安装

添加yum源

1
wget -nv http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.2.0/ambari.repo -O /etc/yum.repos.d/ambari.repo

安装

1
2
yum repolist
yum install ambari-server

配置

1
ambari-server setup

启动

1
ambari-server start

ssh免密码登录

生成公私密钥

1
2
3
ssh-keygen -t rsa
# 提示输入的话直接回车即可
# 生成的密钥在~/.ssh/,公钥:id_rsa.pub,私钥:id_rsa

将公钥设置到目标机器

1
2
3
4
# 添加公钥到authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 修改authorized_keys权限
chmod 600 ~/.ssh/authorized_keys