ZABBIX监控一台服务器上多实例memcache落地经验步骤

大家好!我是系统运维工程师: 李超  上一次给大家分享了工作中监控多实例tomcat的自发现zabbix做法,今天带给大家的就是一台服务器上监控多memcache的一个落地经验。

首先我带大家看一下多实例memcache做法,话不多说,咱们开工:

由于是多实例,所以就需要用到zabbix的自动发现功能(LLD)基本思路如下:

1、写自动发现脚本。

2、写状态取值脚本。

3、添加配置文件。

4、添加权限。

5、配置zabbix web。

zabbix我采用yum安装所以路径是/etc/zabbix  首先创建一个目录为:     mkdir  -p /etc/zabbix/scripts
这里我们要用到两个脚本:

cd /etc/zabbix/scripts

第一个脚本

vim  memcached_discovery.py

#!/usr/bin/env python

import os

import json

t=os.popen("""sudo netstat -nltp|awk -F: '/memcached/&&/LISTEN/{print $2}'|awk '{print $1}'| grep -v grep | grep -v '^$'   """)

ports = []

for port in  t.readlines():

r = os.path.basename(port.strip())

ports += [{'{#MCPORT}':r}]

print json.dumps({'data':ports},sort_keys=True,indent=4,separators=(',',':'))

第二个脚本

vim memcached_status.sh

#!/bin/bash

#  1)yum install nc

#  2)python memcached_discovery.py

#########################

IP=127.0.0.1

PORT="$1"

METRIC="$2"

if [ $# -lt 2 ];then

echo "please set argument"

exit 1

fi

STATUS=`echo "stats" | nc $IP $PORT | grep -w "$METRIC" | awk '{print $3}'`

case $METRIC in

'version')

echo $STATUS

;;

'uptime')

echo $STATUS

;;

'curr_connections')

echo $STATUS

;;

'total_connections')

echo $STATUS

;;

'cmd_get')

echo $STATUS

;;

'cmd_set')

echo $STATUS

;;

'get_hits')

echo $STATUS

;;

'get_misses')

echo $STATUS

;;

'bytes_read')

echo $STATUS

;;

'bytes_written')

echo $STATUS

;;

'curr_items')

echo $STATUS

;;

'total_items')

echo $STATUS

;;

'expired_unfetched')

echo $STATUS

;;

'evicted_unfetched')

echo $STATUS

;;

*)

echo "Not selected metric"

exit 0

;;

esac

ok,两个脚本解决因为我zabbix配置文件里指定的.conf位置是zabbix_agentd.d下

所以cd /etc/zabbix/zabbix_agnetd.d

下边创建key

vim userparameter_memcached.conf

UserParameter=memcached.discovery[*],python /etc/zabbix/scripts/memcached_discovery.py

UserParameter=memcached[*],/bin/bash /etc/zabbix/scripts/memcached_status.sh $1 $2

保存退出!

添加zabbix权限

vim /etc/sudoers.d/zabbix

Defaults:zabbix    !requiretty

zabbix ALL=(ALL) NOPASSWD: SUPERVISORCTLZB

Cmnd_Alias SUPERVISORCTLZB = /sbin/ss,/usr/sbin/ss,/sbin/dmidecode,/usr/sbin/dmidecode,/sbin/service,/usr/sbin/service,/bin/netstat

ok,记得要么关闭防火墙要么添加规则并添加zabbix权限  否则会监控时出现json格式的问题

下边就在web上导入模板添加模板就好了,这些都是基础的不在复述,下边给大家模板:

<?xml version="1.0" encoding="UTF-8"?>

<zabbix_export>

<version>3.0</version>

<date>2017-04-05T09:25:04Z</date>

<groups>

<group>

<name>Template For Base</name>

</group>

</groups>

<templates>

<template>

<template>Template Linux Memcached Discovery</template>

<name>Template Linux Memcached Discovery</name>

<description/>

<groups>

<group>

<name>Template For Base</name>

</group>

</groups>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<items/>

<discovery_rules>

<discovery_rule>

<name>Linux Memcached Discovery</name>

<type>0</type>

<snmp_community/>

<snmp_oid/>

<key>memcached.discovery</key>

<delay>60</delay>

<status>0</status>

<allowed_hosts/>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<delay_flex/>

<params/>

<ipmi_sensor/>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<filter>

<evaltype>0</evaltype>

<formula/>

<conditions/>

</filter>

<lifetime>30</lifetime>

<description>Discovery of redis ports on Linux</description>

<item_prototypes>

<item_prototype>

<name>Memcached-$1-bytes_read</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},bytes_read]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-bytes_written</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},bytes_written]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-cmd_get</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},cmd_get]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-cmd_set</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},cmd_set]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-curr_connections</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},curr_connections]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-evicted_unfetched</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},evicted_unfetched]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-expired_unfetched</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},expired_unfetched]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-get_hits</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},get_hits]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-get_misses</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},get_misses]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>1</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-total_connections</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},total_connections]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-total_items</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},total_items]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-uptime</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},uptime]</key>

<delay>3600</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-version</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>memcached[{#MCPORT},version]</key>

<delay>3600</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

<item_prototype>

<name>Memcached-$1-shutdown</name>

<type>0</type>

<snmp_community/>

<multiplier>0</multiplier>

<snmp_oid/>

<key>net.tcp.listen[{#MCPORT}]</key>

<delay>60</delay>

<history>90</history>

<trends>365</trends>

<status>0</status>

<value_type>3</value_type>

<allowed_hosts/>

<units/>

<delta>0</delta>

<snmpv3_contextname/>

<snmpv3_securityname/>

<snmpv3_securitylevel>0</snmpv3_securitylevel>

<snmpv3_authprotocol>0</snmpv3_authprotocol>

<snmpv3_authpassphrase/>

<snmpv3_privprotocol>0</snmpv3_privprotocol>

<snmpv3_privpassphrase/>

<formula>1</formula>

<delay_flex/>

<params/>

<ipmi_sensor/>

<data_type>0</data_type>

<authtype>0</authtype>

<username/>

<password/>

<publickey/>

<privatekey/>

<port/>

<description/>

<inventory_link>0</inventory_link>

<applications>

<application>

<name>Memcached_Status</name>

</application>

</applications>

<valuemap/>

<logtimefmt/>

<application_prototypes/>

</item_prototype>

</item_prototypes>

<trigger_prototypes>

<trigger_prototype>

<expression>{Template Linux Memcached Discovery:net.tcp.listen[{#MCPORT}].last()}&lt;&gt;1</expression>

<name>Memcached-{HOST.NAME}-{#MCPORT} shutdown</name>

<url/>

<status>0</status>

<priority>4</priority>

<description/>

<type>0</type>

<dependencies/>

</trigger_prototype>

</trigger_prototypes>

<graph_prototypes/>

<host_prototypes/>

</discovery_rule>

</discovery_rules>

<macros/>

<templates/>

<screens/>

</template>

</templates>

</zabbix_export>

至此,zabbix监控多实例memcache已经完成!      系统运维工程师:李超

原文地址:http://blog.51cto.com/13120271/2072657

时间: 2024-10-13 12:25:37

ZABBIX监控一台服务器上多实例memcache落地经验步骤的相关文章

ZABBIX监控一台机器上的多tomcat实例落地经验步骤

以前做过通过jmx监控单个tomcat实例,但是有的时候公司一台服务器上有10个tomcat容器那怎么办呢,来吧往下看吧 1,注意操作文件路径: zabbix安装路径: /data/zabbix/etc/zabbix_agentd.conf.d/jmx_discovery.sh /etc/zabbix/zabbix_agentd.conf 配置文件中 UnsafeUserParameters=1 必须打开,否则模板的自动发现功能报错. 该模板的监控和触发属性在自动发现中配置,所以导入模板后,下属

Zabbix 三、Zabbix监控第一台服务器

一.zabbix-server添加被监控主机  1.Node1节点安装zabbix-agent,zabbix-sender并修改配置文件 [[email protected] ~]# yum install zabbix-agent zabbix-sender Dependencies Resolved =================================================================================================

ZABBIX(二) zabbix 监控第一台服务器

一.搭建一台测试服务器 1.安装一台centos7操作系统 本次测试我在虚拟机上安装了一台centos7.2的操作系统: 2.在Centos7.2的操作系统上安装zabbix 的angent服务: (1)导入软件安装源 rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm (2)安装zabbix-agent客户端服务 yum -y install zabbix-ag

zabbix监控第一台服务器

客户机的IP是192.168.0.80,主机名是wls12c 1. 安装客户端, 1.1 新建zabbix的用户 groupadd zabbix useradd -g zabbix zabbix 1.2 安装客户端 ./configure --prefix=/usr/local/zabbix-3.6.2/ --enable-agent make make install 1.3 配置文件 vim etc/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.

zabbix 创建主机、主机群组、监控第一台服务器

前面介绍了zabbix服务器和zabbix agent的安装配置,今天使用zabbix监控第一台服务器. 1. 安装zabbix agent 在被监控的服务器上安装zabbix agent . 参考<<zabbix agent安装配置>>. 2. zabbix监控服务器 2.1 创建主机 configuration(组态,配置)–>Hosts(主机)–>Create host(创建主机) 属性 描述 主机名 Host name 主机名,只允许数字,空格,句号,下划线,非

windows下同一台服务器上装有两个ORACLE数据库实例,通过命令启停数据库

同一台服务器上装有两个ORACLE数据库实例,通过命令启停数据库,如何区分操作的是哪个数据库实例?操作如下: 1.在命令行 set oracle_sid=one_实例   //先修改环境变量,这一步等于切换了数据库实例 sqlplus /nolog    connect /as sysdba    shutdown 或者 2.连接的时候 sqlplus user/[email protected] as sysdba    //也可以指定 shutdown immediate select in

监控多台服务器

主要分系统监控和业务监控两类 系统监控就是每台主机的CPU,内存网络带宽等使用情况以及Mysql, Redis, Nginx等服务的核心指标等这是比较基本的监控必须得有如果这块监控做的好生产环境可以提前发现很多问题防患于未然. 业务监控就是业务相关的指标如某API每秒调用次数每分钟该API的平均响应时间服务的在线人数甚至一些运营相关的数据如七日留存率啦每日新增用户每日流失用户等.这些数据也很重要他是你整个业务的晴雨表为你做一些重要决策提供依据. 对于系统监控有很多开源软件可以拿来用如比较出名的n

【 Linux 】单台服务器上并发TCP连接数

单台服务器上并发TCP连接数    问题:一台服务器到底能够支持多少TCP并发连接呢? 1. 文件描述符限制:    对于服务器来说,每一个TCP连接都要占用一个文件描述符,一旦文件描述符使用完,新的连接到来返回给我们的错误是"Socket/File:Can't open so many files" 这时,你需要明白操作系统可以打开最大文件数的限制. 进程限制(用户限制):            执行 ulimit -n 输出1024,说明对于一个进程而言最多只能打开1024个文件,

网络编程释疑之:单台服务器上的并发TCP连接数可以有多少

曾几何时我们还在寻求网络编程中C10K问题的解决方案,但是现在从硬件和操作系统支持来看单台服务器支持上万并发连接已经没有多少挑战性了.我们先假设单台服务器最多只能支持万级并发连接,其实对绝大多数应用来说已经远远足够了,但是对于一些拥有很大用户基数的互联网公司,往往面临的并发连接数是百万,千万,甚至腾讯的上亿(注:QQ默认用的UDP协议).虽然现在的集群,分布式技术可以为我们将并发负载分担在多台服务器上,那我们只需要扩展出数十台电脑就可以解决问题,但是我们更希望能更大的挖掘单台服务器的资源,先努力