In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what is the method of building and maintaining the Lepus slow log platform". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
First, install the LAMP basic environment
There are many ways to configure the LAMP base environment, the simplest of which are yum installation, RPM package installation, and so on. You can also compile and install the relevant software manually. There are many articles on this configuration network, without a detailed introduction, you can also refer to the tutorials of my blog for installation. Address: http://www.ruzuojun.com/topic/1203.html
Second, install the Python2.7 basic environment
1) install Python2.7
Lepus requires Python2.7 support (currently the compilation platform is 2.7.2, it is recommended that you install python2.7.2, the download address is included in this installation document).
You can directly enter the python command to query the current python version:
# python
Python 2.6.6 (r266 84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
> > >
If your system Python does not meet the requirements, please refer to the following sample article for installation
1. Download
# wget http://www.mtop.cc/software/Python-2.7.2.tar.bz2
2. Decompression
# tar jxvf Python-2.7.2.tar.bz2
3. Installation:
# cd Python-2.7.2
#. / configure-prefix=/usr/local/Python2.7-enable-shared
# make
# make install
Add the lib library to the system in the following ways, otherwise the following error will be reported: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
# vi / etc/ld.so.conf add / usr/local/Python2.7/lib
# / sbin/ldconfig
# / sbin/ldconfig-v
4. Use the newly installed python:
# mv / usr/bin/python / usr/bin/python_old
# ln-s / usr/local/Python2.7/bin/python2.7 / usr/bin/python
# python
Python 2.7.2 (default, Dec 29 2013, 13:29:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
> > >
If yum cannot be used after python is upgraded to 2.7, and the error is No module named yum, follow these steps to change the python version used by yum to the old version:
Open the yum execution file
# vim / usr/bin/yum
Modify the first line #! / usr/bin/python to the original python version of the backup, as follows:
#! / usr/bin/python_old
2) install MySQLdb for python
MySQLdb is a class library for Python to connect and operate MySQL, and this module must be installed if you are going to use the lepus system to monitor the MySQL database.
The installation steps are as follows:
# wget http://www.mtop.cc/software/MySQLdb-python.zip
# unzip MySQLdb-python.zip
# cd MySQLdb1-master/
# which mysql_config
/ usr/local/mysql/bin/mysql_config
# vim site.cfg is modified as follows:
Mysql_config = / usr/local/mysql/bin/mysql_config
# python setup.py build
# python setup.py install
Common error resolution:
1)。 If you have the following problem with compiling python
/ usr/bin/ld: cannot find-lpython2.7
Collect2: ld returned 1 exit status
Error: command 'gcc' failed with exit status 1
Please follow these steps:
a. Check and install the python-devel package
# yum-y install python-devel
b. Soft connect the libpython2.7.so library file to / usr/lib
Execute under 32-bit server
# ln-s / usr/local/Python2.7/lib/libpython2.7.so / usr/lib/libpython2.7.so
Execute under 64-bit server
# ln-s / usr/local/Python2.7/lib/libpython2.7.so / usr/lib64/libpython2.7.so
c. Check whether / etc/ld.so.conf contains / usr/local/Python2.7/lib
# vi / etc/ld.so.conf add / usr/local/Python2.7/lib
# / sbin/ldconfig
3) install Pymongo for python
Pymongo is a class library for Python to connect and operate MongoDB, and this module must be installed if you are going to use the lepus system to monitor the MongoDBs database.
The installation steps are as follows:
Download pymongo https://pypi.python.org/packages/source/p/pymongo/
# wget www.mtop.cc/software/pymongo-2.7.tar.gz
# tar zxvf pymongo-2.7.tar.gz
# cd pymongo-2.7
# python setup.py install
Third, install Lepus monitoring system
Note: before installing the Lepus system, install the LAMP and Python runtime environment according to the previous two sections.
1) upload the software package to the monitor server and extract the software to your system
# tar zxvf lepus_v3.0.tar.gz
2)。 Create a monitoring database on the monitoring machine and authorize it.
Mysql > create database lepus charset utf8 collate utf8_general_ci
Mysql > grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'localhost' identified by' mysql'
Mysql > flush privileges
Import SQL files (table structure and data files) in the SQL folder
# cd lepus_v3.0
# mysql-uroot-p lepus
< sql/lepus.sql # mysql -uroot -p lepus < sql/lepus_data.sql 4)安装Lpeus程序 进入到软件包的python文件夹 # cd python/ 授予install.sh可执行权限 # chmod +x install.sh 执行安装 # ./install.sh [note] lepus will be install on basedir: /usr/local/lepus [note] /usr/local/lepus directory does not exist,will be created. [note] /usr/local/lepus directory created success. [note] wait copy files....... [note] change script permission. [note] create links. [note] install complete. 5) 修改配置文件 备注:在python采集数据的过程中,需要连接到需要监控的数据库服务器采集数据,我们为了安全考虑,在WEB管理里面只要求录入主机和端口,没有录入账号和密码。所有需要监控的数据库请授予相同的用户密码记录在配置文件中。系统通过SNMP协议采集. SNMP需要的community也请授予相同的写在配置文件中。具体示例如下所示,我们暂定给所有被监控数据库添加一个monitor用户: 进入到安装目录,默认为/usr/local/lepus # cd /usr/local/lepus/ # vim etc/config.ini ###监控机MySQL数据库连接地址### [monitor_server] host="127.0.0.1" port=3306 user=" lepus_user " passwd="password" dbname="lepus" ###被监控数据库的用户密码### [mysql_db] username="monitor" password="monitor" [mongodb_db] username="monitor" password="monitor" [oracle_db] username="" password="" [snmp] community="lepus" 6)测试驱动(可选) 执行以下命令可以测试MySQLdb是否安装成功,以及监控机MySQL连接是否正常。 # python test_mysql.pyc The MySQLDB is OK 7) 在所有需要被监控的数据库授权 在需要被监控的数据库里(被监控机)添加允许监控机访问的帐户,并授权。授权帐户即为上面配置文件中指定的monitor用户。 授权如下所示: grant select,super,process on *.* to 'monitor'@'ip' identified by 'monitor'; MongoDB被监控机授权(还未找到合适的权限,目前暂时用管理权限) >Use admin
> db.addUser ('monitor','monitor')
7) start the monitoring system
Execute the following command to start the system acquisition process
# lepus start
Nohup: appending output to `nohup.out'
Lepus monitor start success!
Execute the following command to close the system acquisition process
# lepus stop
Lepus processes id 28937 been stop
Lepus processes id 28938 been stop
Lepus processes id 28957 been stop
Lepus processes id 28973 been stop
Lepus processes id 28984 been stop
Lepus processes id 28995 been stop
Lepus processes id 29003 been stop
Lepus processes id 29019 been stop
Lepus processes id 29174 been stop
Execute the following command to monitor whether the system is running properly
# lepus status
Lepus server is running...
8) deploy the lepus_monitor script as a scheduled task, which can monitor whether your Lepus is running.
Open the file / usr/local/lepus/lepus_monitor to modify the database connection address of the connection monitor inside, and then deploy the script as a scheduled task.
# crontab-l
* / 1 * / usr/local/lepus/lepus_monitor > > / tmp/lepus_monitor.log
9) deploy the WEB interface
Copy the files in the PHP folder to the virtual directory of the website corresponding to Apache
# cd lepus_v3.0
# cp-rf php/* / home/wwwroot/lepus/
Open the application\ config\ database.php file and modify the database information of the PHP connection monitoring server
$db ['default'] [' hostname'] = 'localhost'
$db ['default'] [' username'] = 'lepus_user'
$db ['default'] [' password'] = 'password'
$db ['default'] [' database'] = lepus
$db ['default'] [' dbdriver'] = 'mysql'
Enter the IP address or domain name through the browser to open the monitoring interface and log in to the system. . Default administrator account password after logging in with admin/Lepusadmin, please change the administrator password and add an ordinary account. After entering the system, you can add applications and hosts to start your database monitoring journey.
Fourth, install percona-toolkit tools
1) install percona-toolkit
# yum install-y per-IO-Socket-SSL
# yum install-y per-DBI
# yum install-y per-DBD-MySQL
# tar zxvf percona-toolkit-3.0.10.tar.gz
# cd percona-toolkit-3.0.10
# perl Makefile.PL
# make
# make install
2) to edit the file to modify the configuration, you need to specify the address of the database of the Lepus monitor, the local MySQL address, as well as the path and time to store the slow query.
[root@oneproxy mysql] # cat lepuspushcake query.shandra Modify Date Modify Date: 2014-03 -25 10:01#***##config lepus database serverlepus_db_host= "192.168.8.63" lepus_db_port=3306lepus_db_user= "lepus_user" lepus_db_password= "mysql" lepus_db_database= "lepus" # config Mysql servermysql_client= "/ usr/local/mysql/bin/mysql" mysql_host= "192.168.8.63" mysql_port=3306mysql_user= "root" mysql_password= "mysql" # config slowquryslowquery_dir= "/ mysql/data/" slowquery_long_time=0.1slowquery_file= `$ mysql_client-h$mysql_host-P$mysql_port-u$mysql_user-p$mysql_password-e "show variables like 'slow_query_log_file'" | grep log | awk' {print $2} '`pt_query_digest= "/ usr/local/bin/pt -query-digest "# config server_idlepus_server_id=63#collect mysql slowquery log into lepus database$pt_query_digest-user=$lepus_db_user-password=$lepus_db_password-port=$lepus_db_port-review h=$lepus_db_host Dobbylepuspusquerydatabase review-- history h$mysql_host h$mysql_host P$mysql_port u$mysql_user-p$mysql_password-e "select concat ('$slowquery_dir','slowquery_',date_format (now ())" '% Y% m% d% H'),' .log') | | grep log | sed-n-e '2p' `# config mysql slowquery$mysql_client-h$mysql_host-P$mysql_port-u$mysql_user-p$mysql_password-e "set global slow_query_log=1;set global long_query_time=$slowquery_long_time;" $mysql_client-h$mysql_host-P$mysql_port-u$mysql_user-p$mysql_password-e "set global slow_query_log_file =' $tmp_log';" # delete log before 7 dayscd $slowquery_dir/usr/bin/find. /-name 'slowquery_*'-mtime + 7 | xargs rm-rf # END####
3) set scheduled tasks
* / 3 * / usr/local/lepus/client/mysql/lepus_slowquery.sh > / dev/null 2 > & 1
4) slow log monitoring is as follows:
This is the end of the content of "what is the method of building and maintaining the Lepus slow log platform". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.