jmeter+influxdb+granfana+collectd監控cpu+mem+TPS


1.安裝grafana

#####gafana過期安裝包安裝報錯

Error unpacking rpm package grafana-5.1.4-1.x86_64
error: unpacking of archive failed on file /usr/sbin/grafana-cli;5e250e9c: cpio: read
Verifying : grafana-5.1.4-1.x86_64
原因安裝包損壞不是最新的
######下載官網最新的包:
####grafana installer
https://grafana.com/grafana/download

#####binary install
wget https://dl.grafana.com/oss/release/grafana-6.5.3.linux-amd64.tar.gz
tar -zxvf grafana-6.5.3.linux-amd64.tar.gz
#### grafana rpm install
sudo yum install initscripts urw-fonts wget
wget <rpm package url>
sudo rpm -Uvh <local rpm package>
安裝成功展示
warning: grafana-6.5.3-1.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 24098cb6: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:grafana-6.5.3-1 warning: /etc/init.d/grafana-server created as /etc/init.d/grafana-server.rpmnew
warning: /usr/lib/systemd/system/grafana-server.service created as /usr/lib/systemd/system/grafana-server.service.rpmnew
################################# [100%]
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
sudo /bin/systemctl start grafana-server.service
POSTTRANS: Running script.............


#### 啟動grafana,驗證服務已啟動
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
###啟動成功驗證
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2020-01-20 10:31:27 CST; 12s ago
Docs: http://docs.grafana.org
Main PID: 63048 (grafana-server)

###配置開機自啟動
sudo systemctl enable grafana-server.service

####防火牆開放grafana端口默認3000:
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
或者直接停掉防火牆:
systemctl stop firewalld


###web訪問grafana:
安裝主機ip:3000

###修改grafana 配置,Grafana有許多配置選項,您可以在.ini配置文件中指定或使用環境變量指定,
您必須重新啟動Grafana才能使所有配置更改生效。
官網doc文檔地址:https://grafana.com/docs/grafana/latest/installation/configuration/
vi /etc/grafana/grafana.ini
###ini注釋comment方法講解:
所有注釋以分號開頭,如果需要更改配置比如web頁面port ,
需要刪除行前面分號,更改為

###關於web login密碼賬號更改也是如此,需要重啟grafana才生效
37 # The http port to use
38 ;http_port = 3000
####web login
152 #################################### Security ####################################
153 [security]
154 # disable creation of admin user on first start of grafana
155 ;disable_initial_admin_creation = false
156
157 # default admin user, created on startup
158 ;admin_user = admin
159
160 # default admin password, can be changed before first start of grafana, or in profile settings
161 ;admin_password = admin

#####influxdb 啟動失敗問題解決,influxdb installer 配置路徑:

/etc/influxdb/influxdb.conf
#####啟用graphite配置########:
[[graphite]]
# Determines whether the graphite endpoint is enabled.
enabled = false
database = "graphite"
# retention-policy = ""
bind-address = ":2003"
protocol = "tcp"
consistency-level = "one"
http啟用:
### [http]
###
### Controls how the HTTP endpoints are configured. These are the primary
### mechanism for getting data into and out of InfluxDB.
###

[http]
# Determines whether HTTP endpoint is enabled.
enabled = true

# The bind address used by the HTTP service.
bind-address = ":8086"


#### 默認influxdb數據存放:meta元數據,data
/var/lib/influxdb/data
/var/lib/influxdb/meta

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
### [meta]
###
### Controls the parameters for the Raft consensus group that stores metadata
### about the InfluxDB cluster.
###

[meta]
# Where the metadata/raft database is stored
dir = "/var/lib/influxdb/meta"

# Automatically create a default retention policy when creating a database.
# retention-autocreate = true

# If log messages are printed for the meta service
# logging-enabled = true

###
### [data]
###
### Controls where the actual shard data for InfluxDB lives and how it is
### flushed from the WAL. "dir" may need to be changed to a suitable place
### for your system, but the WAL settings are an advanced configuration. The
### defaults should work for most systems.
###

[data]
# The directory where the TSM storage engine stores TSM files.
dir = "/var/lib/influxdb/data"

# The directory where the TSM storage engine stores WAL files.
wal-dir = "/var/lib/influxdb/wal"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#### influxdb log目錄:
啟動influxdb:systemctl start influxdb
查詢啟動狀態:systemctl status influxdb

啟動失敗:
: Failed to start InfluxDB is an open-source, distributed, time series database.

tail -n 20 /var/log/messages 分析失敗原因,查找到用戶權限拒絕:
run: open server: open tsdb store: mkdir /var/lib/influxdb/data/_internal/_series: permission denied

#### 查詢influxdb: 使用查詢命令rpm -ql influxdb
/usr/lib/influxdb/scripts/influxdb.service
/var/lib/influxdb
/var/log/influxdb
####
ls -l -d influxdb
cd /var/lib/
chown -R influxdb:influxdb influxdb

#### influxdb 集成安裝collectd 監控cpu,mem,disk
###yum 安裝collectd:org:https://collectd.org/download.shtml
<<python 模塊偽代碼https://www.jianshu.com/p/a05da23150fb>>
####### collectd安裝使用,官網地址:https://collectd.org/download.shtml

方法一yum安裝:
yum install epel-release–y
yum install -y collectd
###修改配置:

vi /etc/collectd.conf

 

修改配置
vi /etc/collectd.conf

         確保以下幾項的注釋(#)是去掉的

             Hostname    "192.168.1.126"      此處改為安裝collectd的機器IP地址

             LoadPlugin cpu

             LoadPlugin memory

             LoadPlugin network

             LoadPlugin swap

            <Plugin cpu>

                    ReportByCpu true

                    ReportByState true

                    ValuesPercentage true   此處啟用cpu的使用率,5.7.*以上才有,低版本的不支持百分百

           </Plugin>

           <Plugin network>

                   <Server "192.168.1.222" "25826"> 此處指定將collectd收集的數據發送到的influxdb地址和influxdb conf里collectd配置的端口

                 #           Interface "enp0s31f6"   通過ifconfig獲取網卡的名稱

                  </Server>

          </Plugin>


啟動:
systemctl start collectd.service
systemctl status collectd.service

● collectd.service - Collectd statistics daemon
Loaded: loaded (/usr/lib/systemd/system/collectd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2020-01-20 17:11:49 CST; 23s ago
Docs: man:collectd(1)
man:collectd.conf(5)
Main PID: 6968 (collectd)
Tasks: 11
CGroup: /system.slice/collectd.service
└─6968 /usr/sbin/collectd


方法二:源碼安裝:
wget https://storage.googleapis.com/collectd-tarballs/collectd-5.9.2.tar.bz2
tar -xvf collectd-5.9.2.tar.bz2
mkdir -p /data/project/collectd_dir/datas
## compile c,collectd C 語言寫的一個系統性能采集工具
./configure -prefix=/data/project/collectd_dir/datas
### install by datas dir
make all install prefix=/data/project/collectd_dir/datas
find / -name collectd.conf 查詢安裝的目錄:
/data/project/collectd_dir/datas/etc/collectd.conf


####
Hostname "192.168.110.151"
#FQDNLookup true
#BaseDir "/var/lib/collectd"
#PIDFile "/var/run/collectd.pid"
#PluginDir "/usr/lib64/collectd"
#TypesDB "/usr/share/collectd/types.db"

####influxdb 安裝,官網地址https://v2.docs.influxdata.com/v2.0/get-started/

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

環境變量:vi  /etc/profile

## influx env
export INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf


systemctl start influxdb
[root@hostuser1 project]# influx
Connected to http://localhost:8086 version 1.6.4
InfluxDB shell version: 1.6.4
> create database collectd
> use collectd
Using database collectd
> show databases
name: databases
name
----
_internal
jmeter
collectd
###influxdb的數據量一多,會非常影響性能,可以設置只保留5天的數據
>create retention policy "5_days" on collectd duration 5d replication 1 default
> show retention policies on collectd
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 0s 168h0m0s 1 true
>
show measurements

### 檢查連接tcp 25826連接情況:
ss -tuln
udp UNCONN 0 0 [::]:25826 [::]:*
udp UNCONN 0 0 [::1]:323 [::]:*
tcp LISTEN 0 128 *:111 *:*

#####collectd dashboard模板
https://grafana.com/grafana/dashboards/10179

### JMETER >ADD>Listener>BackendListener

 

 

####TPS

 

 

####cpu,mem


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM