[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

[Cacti] memcache安装执行、cacti监控memcache实战

大家好,又见面了,我是全栈君。

简单介绍

Memcachedanga.com的一个项目,最早是为 LiveJournal 服务的。眼下全世界不少人使用这个缓存项目来构建自己大负载的站点,来分担数据库的压力。

Memcache官方站点:http://memcached.org/

 1,安装

下载地址: http://www.memcached.org/downloads,我们线上使用的比較稳定的版本号是1.4.15,假设官网找不到曾经的版本号了,能够去我的csdn资源里面下载此版本号,下载地址:

memcache1.4.15 :http://download.csdn.net/detail/mchdba/7562193

libevent2http://download.csdn.net/detail/mchdba/7562201

或者去官网下载最新的:

wget  http://memcached.org/latest

[root@localhost ~]#tar -xvf memcached-1.4.15.tar.gz

[root@localhost ~]# cd memcached-1.4.15

[root@localhost memcached-1.4.15]# ./configure && make && make test && sudo make install

……

checking for library containing clock_gettime… -lrt

checking for library containing socket… none required

checking for library containing gethostbyname… none required

checking for libevent directory… configure: error: libevent is required.  You can get it from http://www.monkey.org/~provos/libevent/

      If it’s already installed, specify its path using –with-libevent=/dir/

 

看到提示。须要先安装libevent包。lebevent主要用于socket的处理,

   wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

        tar -xvf libevent-2.0.21-stable.tar.gz

       cd libevent-2.0.21-stable

       ./configure  –prefix=/usr/local/libevent  

       make  

       make install  

 

#删除原来的文件夹,又一次解压缩进行编译安装

[root@localhost ~]#rm -rf /root/memcached-1.4.15/

[root@localhost ~]# tar -xvf memcached-1.4.15.tar.gz

[root@localhost ~]# cd /root/memcached-1.4.15/

[root@localhost memcached-1.4.15]# ./configure –with-libevent=/usr/local/libevent –prefix=/usr/local/memcache

[root@localhost memcached-1.4.15]# make

[root@localhost memcached-1.4.15]# make test

[root@localhost memcached-1.4.15]# make install

 

2,怎样执行memcache

/usr/local/bin/memcached -d -m 10  -u root -l 10.xx.xx.xx -p 12000 -c 1024 –P /tmp/memcached.pid

##  相关选项说明

-d   表示启动一个守护进程

-m   是分配给memcached使用的内存

-u   执行memcached的用户

-l     memcached监听的ip

-p    memcached监听的port

-c    memcache执行的最大并发连接数

-P    是设置memcachepid文件

 

[root@localhost ~]# /usr/local/memcache/bin/memcached -d -u nobody -m 1024 -t 64 -c 2048 -k -I 1M -L -l 127.0.0.1 -p11211 -P /var/memcached/memcached_11211.pid

Cannot enable large pages on this system

(There is no Linux support as of this version)

[root@localhost ~]#

Cannot enable large pages,启动命令不合适。换成例如以下

/usr/local/memcache/bin/memcached -d -m 1024 -u root -l 10.xx.xx.xx -p 11211 -c 2048 -P /var/memcached/memcached.pid

 

3,实现service启动停止以及查看状态

然后执行例如以下,载入到启动项:

chkconfig –add memcache  #注冊服务

chmod 700 memcache

chkconfig –level 345 memcache on  #指定服务在345级别执行

 

4,简单測试

[root@localhost ~]# telnet 127.0.0.1 11211

存一个简单的key1,值为123456

Trying 127.0.0.1…

Connected to 127.0.0.1.

Escape character is ‘^]’.

set key1 0 0 6

123456

STORED  #存储成功

quit

Connection closed by foreign host.

[root@localhost ~]# telnet 127.0.0.1 11211

去获取这个key1的值

Trying 127.0.0.1…

Connected to 127.0.0.1.

Escape character is ‘^]’.

get key1

VALUE key1 0 6

123456  #获取成功

END

 

5memcache的使用

有些是转载的,原文地址:http://blog.csdn.net/heiyeshuwu

 

6memcache性能监控

6.1,安装python插件

下载地址:http://download.csdn.net/detail/wufongming/1159646

tar -xvf python-memcached-latest.tar.gz

cd python-memcached-1.43

python setup.py install

 

执行上面的命令的时候出现例如以下错误

Traceback (most recent call last):

File “setup.py”, line 3, in ?

from setuptools import setup

ImportError: No module named setuptools

解决的方法:yum -y install python-setuptools

成功安装后再次 python setup.py install 安装就能够成功了。


6.2。下载安装插件

[root@squid-2 soft]# wget http://s1.dlnws.com/dealnews/developers/cacti-memcached-1.0.tar.gz

解压缩:

[root@squid-2 soft]# tar -xvf cacti-memcached-1.0.tar.gz

cacti-memcached-1.0/

cacti-memcached-1.0/cacti_memcached_host_template.xml

cacti-memcached-1.0/INSTALL

cacti-memcached-1.0/memcached.py

cacti-memcached-1.0/README

[root@squid-2 soft]#

 

将监控文件memcached.py拷贝到cactiscripts文件文件夹下

[root@squid-2 cacti-memcached-1.0]# pwd

/root/soft/cacti-memcached-1.0

[root@squid-2 cacti-memcached-1.0]# cp memcached.py /var/www/html/cacti/scripts/

[root@squid-2 cacti-memcached-1.0]#

 

赋予执行用户权限

[root@squid-2 cacti-memcached-1.0]# chown -R apache.apache /var/www/html/cacti/scripts/memcached.py

[root@squid-2 cacti-memcached-1.0]#

 

6.3,在cacti界面导入memcache模板文件

将解压缩的cacti_memcached_host_template.xml文件copy到本地E:\u\memcache,然后进入“console”,再进入“Import Templates”。再进入“选择文件”,选择E:\u\memcache下的cacti_memcached_host_template.xml文件。然后点击右下角的“Import”button。导入完后,会在Graph Templates看到memcache6项监控服务,例如以下图所看到的:

 [Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」


6.4,在界面加入memcache主机服务

进入“Devices”。点击右上角的“Add”button, 填写主机名称和主机ip地址,在“Host Template”下拉框里面选择“Memcached Server”选项,点击右下角的“Save”button创建memcache服务主机,例如以下图所看到的。

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

6.5。给memcache主机加入监控图

选择“Devices”,点击主机名称连接“xx.xx_memcache”,在新的界面中,点击右上角的“Create Graphs for this Host”,然后在新的页面中选择6Memcache监控选项,点击右下角的“Create”button,就创建好了memcache监控图,例如以下图所看到的:


[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

6.6,查看memcache监控图

       选择“monitor”。再选择右边的“Tree View”,再选择左边的memcache主机名称,就会在右边出现6个监控图,例如以下所看到的:

1 Memcached – Bytes Used

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」



(2)Memcached – Cache Hits and Misses

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」


 
 (3)Memcached – Current Connections
[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

(4)Memcached – Items Cached

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

(5)Memcached – Network Traffic (bits/sec)

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

 6Memcached – Requests/sec (get/set)

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

以上设置仅仅是针对默认port11211,可是当你的port不是11211,而是其它的port,比方我的是12000,这种话你就要对你的cactidata source做下小更改了,操作例如以下:

Console—Data Input Methods–Memcached – Statistics

找到Input String的值python /scripts/memcached.py

更改成:python /scripts/memcached.py p 12000

假设你是其它port的,仅仅要将port号更改成其它的值就能够了!

 

6.7,遇到的问题总结

1)有图出不来数据。显示为nan值,问题出在,没有安装 python-memcached-latest.tar.gz插件导致。安装完插件后,重新启动cacti服务,图上的数据显示出来了。

 

2)网卡监控流量选项选择不了,报错: This data query returned 0 rows, perhaps there was a problem executing this data query. You can run this data query in debug mode to get more information.

 解决方式例如以下:

a。第一种
打开默认的
/etc/snmp/snmpd.conf文件,更改例如以下配置:
  1
、查找下面字段:
      sec.name  source          community
com2sec notConfigUser  default       public
“comunity”字段改为你要设置的password.比方“public”. 

2、查找下面字段:
# Finally, grant the group read-only access to the systemview view.
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup “”      any       noauth    exact  all none none
将”systemview”字段改为all.

3、查找下面字段:
#           incl/excl subtree                          mask
#view all    included  .1                               80
将该行前面的”#”去掉.

然后重新启动snmpd服务,就OK了。

 

b,另外另一种办法例如以下:

例如以下:
编辑linux主机下的/etc/snmp/snmpd.conf文件
找到62行:
access  notConfigGroup “”      any       noauth    exact  systemview none none
改动成:(假设有#号。把#号去掉)
access  notConfigGroup “”      any       noauth    exact  mib2 none none

找到89行。把改行的#去掉:
#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
改动成:
view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc

重起snmpd服务,service snmpd restart

 


參考文章地址:

http://blog.chinaunix.net/uid-20639775-id-154601.html

https://code.google.com/p/memcached/wiki/NewStart

简单介绍

Memcachedanga.com的一个项目,最早是为 LiveJournal 服务的。眼下全世界不少人使用这个缓存项目来构建自己大负载的站点,来分担数据库的压力。Memcache官方站点:http://memcached.org/

 1,安装

下载地址: http://www.memcached.org/downloads,我们线上使用的比較稳定的版本号是1.4.15,假设官网找不到曾经的版本号了,能够去我的csdn资源里面下载此版本号。下载地址:

memcache1.4.15 :http://download.csdn.net/detail/mchdba/7562193

libevent2http://download.csdn.net/detail/mchdba/7562201

或者去官网下载最新的:

wget  http://memcached.org/latest

[root@localhost ~]#tar -xvf memcached-1.4.15.tar.gz

[root@localhost ~]# cd memcached-1.4.15

[root@localhost memcached-1.4.15]# ./configure && make && make test && sudo make install

……

checking for library containing clock_gettime… -lrt

checking for library containing socket… none required

checking for library containing gethostbyname… none required

checking for libevent directory… configure: error: libevent is required.  You can get it from http://www.monkey.org/~provos/libevent/

      If it’s already installed, specify its path using –with-libevent=/dir/

 

看到提示,须要先安装libevent包,lebevent主要用于socket的处理,

   wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

        tar -xvf libevent-2.0.21-stable.tar.gz

       cd libevent-2.0.21-stable

       ./configure  –prefix=/usr/local/libevent  

       make  

       make install  

 

#删除原来的文件夹,又一次解压缩进行编译安装

[root@localhost ~]#rm -rf /root/memcached-1.4.15/

[root@localhost ~]# tar -xvf memcached-1.4.15.tar.gz

[root@localhost ~]# cd /root/memcached-1.4.15/

[root@localhost memcached-1.4.15]# ./configure –with-libevent=/usr/local/libevent –prefix=/usr/local/memcache

[root@localhost memcached-1.4.15]# make

[root@localhost memcached-1.4.15]# make test

[root@localhost memcached-1.4.15]# make install

 

2,怎样执行memcache

/usr/local/bin/memcached -d -m 10  -u root -l 10.xx.xx.xx -p 12000 -c 1024 –P /tmp/memcached.pid

##  相关选项说明

-d   表示启动一个守护进程

-m   是分配给memcached使用的内存

-u   执行memcached的用户

-l     memcached监听的ip

-p    memcached监听的port

-c    memcache执行的最大并发连接数

-P    是设置memcachepid文件

 

[root@localhost ~]# /usr/local/memcache/bin/memcached -d -u nobody -m 1024 -t 64 -c 2048 -k -I 1M -L -l 127.0.0.1 -p11211 -P /var/memcached/memcached_11211.pid

Cannot enable large pages on this system

(There is no Linux support as of this version)

[root@localhost ~]#

Cannot enable large pages,启动命令不合适,换成例如以下

/usr/local/memcache/bin/memcached -d -m 1024 -u root -l 10.xx.xx.xx -p 11211 -c 2048 -P /var/memcached/memcached.pid

 

3,实现service启动停止以及查看状态

然后执行例如以下。载入到启动项:

chkconfig –add memcache  #注冊服务

chmod 700 memcache

chkconfig –level 345 memcache on  #指定服务在345级别执行

 

4,简单測试

[root@localhost ~]# telnet 127.0.0.1 11211

存一个简单的key1,值为123456

Trying 127.0.0.1…

Connected to 127.0.0.1.

Escape character is ‘^]’.

set key1 0 0 6

123456

STORED  #存储成功

quit

Connection closed by foreign host.

[root@localhost ~]# telnet 127.0.0.1 11211

去获取这个key1的值

Trying 127.0.0.1…

Connected to 127.0.0.1.

Escape character is ‘^]’.

get key1

VALUE key1 0 6

123456  #获取成功

END

 

5memcache的使用

有些是转载的,原文地址:http://blog.csdn.net/heiyeshuwu

 

6memcache性能监控

6.1
。安装
python
插件

下载地址:http://download.csdn.net/detail/wufongming/1159646

tar -xvf python-memcached-latest.tar.gz

cd python-memcached-1.43

python setup.py install

 

执行上面的命令的时候出现例如以下错误

Traceback (most recent call last):

File “setup.py”, line 3, in ?

from setuptools import setup

ImportError: No module named setuptools

解决的方法:yum -y install python-setuptools

成功安装后再次 python setup.py install 安装就能够成功了。

6.2
,下载安装插件

[root@squid-2 soft]# wget http://s1.dlnws.com/dealnews/developers/cacti-memcached-1.0.tar.gz

解压缩:

[root@squid-2 soft]# tar -xvf cacti-memcached-1.0.tar.gz

cacti-memcached-1.0/

cacti-memcached-1.0/cacti_memcached_host_template.xml

cacti-memcached-1.0/INSTALL

cacti-memcached-1.0/memcached.py

cacti-memcached-1.0/README

[root@squid-2 soft]#

 

将监控文件memcached.py拷贝到cactiscripts文件文件夹下

[root@squid-2 cacti-memcached-1.0]# pwd

/root/soft/cacti-memcached-1.0

[root@squid-2 cacti-memcached-1.0]# cp memcached.py /var/www/html/cacti/scripts/

[root@squid-2 cacti-memcached-1.0]#

 

赋予执行用户权限

[root@squid-2 cacti-memcached-1.0]# chown -R apache.apache /var/www/html/cacti/scripts/memcached.py

[root@squid-2 cacti-memcached-1.0]#

 

6.3
,在
cacti
界面导入
memcache
模板文件

将解压缩的cacti_memcached_host_template.xml文件copy到本地E:\u\memcache,然后进入“console”。再进入“Import Templates”。再进入“选择文件”,选择E:\u\memcache下的cacti_memcached_host_template.xml文件。然后点击右下角的“Import”button。

导入完后,会在Graph Templates看到memcache6项监控服务,例如以下图所看到的:

 [Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

6.4
,在界面加入
memcache
主机服务

进入“Devices”,点击右上角的“Add”button, 填写主机名称和主机ip地址,在“Host Template”下拉框里面选择“Memcached Server”选项,点击右下角的“Save”button创建memcache服务主机,例如以下图所看到的。

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

6.5
。给
memcache
主机加入监控图

选择“Devices”,点击主机名称连接“xx.xx_memcache”,在新的界面中,点击右上角的“Create Graphs for this Host”,然后在新的页面中选择6Memcache监控选项,点击右下角的“Create”button,就创建好了memcache监控图。例如以下图所看到的:


[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

6.6
。查看
memcache
监控图

       选择“monitor”,再选择右边的“Tree View”,再选择左边的memcache主机名称,就会在右边出现6个监控图,例如以下所看到的:

1 Memcached – Bytes Used

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」



(2)Memcached – Cache Hits and Misses

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」


 
 (3)Memcached – Current Connections
[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

(4)Memcached – Items Cached

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

(5)Memcached – Network Traffic (bits/sec)

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

 6Memcached – Requests/sec (get/set)

[Cacti] memcache安装执行、cacti监控memcache实战「建议收藏」

 

以上设置仅仅是针对默认port11211。可是当你的port不是11211,而是其它的port,比方我的是12000。这种话你就要对你的cactidata source做下小更改了。操作例如以下:

Console—Data Input Methods–Memcached – Statistics

找到Input String的值python /scripts/memcached.py

更改成:python /scripts/memcached.py p 12000

假设你是其它port的,仅仅要将port号更改成其它的值就能够了!

 

6.7
。遇到的问题总结

1)有图出不来数据,显示为nan值。问题出在。没有安装 python-memcached-latest.tar.gz插件导致。安装完插件后,重新启动cacti服务,图上的数据显示出来了。

 

2)网卡监控流量选项选择不了。报错: This data query returned 0 rows, perhaps there was a problem executing this data query. You can run this data query in debug mode to get more information.

 解决方式例如以下:

a。第一种
打开默认的
/etc/snmp/snmpd.conf文件,更改例如以下配置:
  1
、查找下面字段:
      sec.name  source          community
com2sec notConfigUser  default       public
“comunity”字段改为你要设置的password.比方“public”. 

2、查找下面字段:
# Finally, grant the group read-only access to the systemview view.
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup “”      any       noauth    exact  all none none
将”systemview”字段改为all.

3、查找下面字段:
#           incl/excl subtree                          mask
#view all    included  .1                               80
将该行前面的”#”去掉.

然后重新启动snmpd服务,就OK了。

 

b,另外另一种办法例如以下:

例如以下:
编辑linux主机下的/etc/snmp/snmpd.conf文件
找到62行:
access  notConfigGroup “”      any       noauth    exact  systemview none none
改动成:(假设有#号。把#号去掉)
access  notConfigGroup “”      any       noauth    exact  mib2 none none

找到89行,把改行的#去掉:
#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
改动成:
view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc

重起snmpd服务,service snmpd restart

 


參考文章地址:

http://blog.chinaunix.net/uid-20639775-id-154601.html

https://code.google.com/p/memcached/wiki/NewStart

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116349.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 安卓中listview的使用步骤_安卓listview控件的用法

    安卓中listview的使用步骤_安卓listview控件的用法1)排序ListView通过适配器得到内容数据,可以对数据list先排序再提供给ListView:privateList>getData(){List>list=newArrayList>();//addData…//对list进行排序if(!list.isEmpty()){Collections.sort(list,newComparator&g…

    2022年9月28日
    4
  • 计算机网络——子网划分(内含习题讲解)

    计算机网络——子网划分(内含习题讲解)PS:(习题是由b站–计算机网络-谢希仁第7版-河南科技大学视频中获得)前情提要:我们在这之前已经学过了两级的IP地址:但是两级的IP地址有很多弊端,所以我们将要学习三级IP地址,也就是两级IP地址的升级版那我们要注意什么呢?一:我怎么去知道人家用的是两级IP还是三级IP呢?答:利用子网掩码;二:那什么是子网掩码呢?…

    2022年4月19日
    38
  • Java面试-面向对象

    点击上方“全栈程序员社区”,星标公众号 重磅干货,第一时间送达 Q1。什么是多态? 多态被简要描述为“一个接口,许多实现”。多态性是能够在不同上下文中为某事物赋予不同含义或用法的一…

    2021年6月23日
    102
  • QT3D场景的快速绘制

    QT3D场景的快速绘制    QT3D场景提供了一种快速设置3D场景的一种方式,用户凭借着封装好的实体可以快速的在顶层实体(画布)当中增加各种各样的实体,并且通过3DMax软件构造的OBJ文件与QT3D实现信息交互可以的帮助用户摆脱OpenGL的用代码绘制图形的繁琐。本人在做这方面的工作时也看了很多来自CSDN的文章,但是直接将封装好的3D实体放入画布的例子有点少(是不是大家觉得太简单了?),所以作为一个QT3D建模…

    2022年6月4日
    31
  • 电信系统服务器地址,电信高速dns服务器地址谁知道?

    电信系统服务器地址,电信高速dns服务器地址谁知道?丶言小午回答数:25336|被采纳数:62016-11-2200:56:35全国各地电信DNS北京DNS地址:202.96.199.133202.96.0.133202.106.0.20202.106.148.1202.97.16.195上海DNS地址:202.96.199.132202.96.199.133202.96.209.5202.96.209.6202.96.209.133天津…

    2022年7月27日
    15
  • endnote x9中文版安装教程_vivo怎么强制安装软件

    endnote x9中文版安装教程_vivo怎么强制安装软件一、下载在百度中搜索“Endnotex9”,点第一个链接进入下载页面。软件大小为108MB,下载的是一个压缩包,如下图所示,双击解压之后是右侧的图标,解压到文件夹,双击即可安装。二、安装直接安装即可,可以更换安装路径备注:安装成功后使用汉化版,可以将CHS文件夹里的[EndNote.exe]拷贝到EndNote的安装目录下。使用英文版,可以将ENG文件夹里的[EndNote.exe]拷贝到EndNote的安装目录下。不论用的是英文版还是中文版,替换之后即可使用…

    2022年10月11日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号