-
Notifications
You must be signed in to change notification settings - Fork 115
/
db_monitor安装记录
130 lines (113 loc) · 3.94 KB
/
db_monitor安装记录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
操作系统版本:Centos 6.10
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
[root@localhost ~]#
1.安装mysql5.7
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install yum-utils -y
yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr
yum -y install mysql-community-server
yum -y install MySQL-python
yum -y install mysql-devel
初始化数据
service mysqld start
service mysqld stop
进入安全模式修改root口令
/usr/bin/mysqld_safe --skip-grant-tables &
回车
mysql -uroot -p
直接回车
mysql>use mysql;
mysql>update user set authentication_string=password('输入新密码') where user='root';
或者
mysql>UPDATE user SET password=PASSWORD('输入新密码') WHERE user='root';
mysql>FLUSH PRIVILEGES;
mysql>quit
service mysqld restart
2. 安装python2.7
yum groupinstall -y 'development tools'
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar zxf Python-2.7.13.tgz
cd Python-2.7.13
./configure
make all
make install
mv /usr/bin/python /usr/bin/python.old
rm -f /usr/bin/python-config
ln -s /usr/local/bin/python /usr/bin/python
ln -s /usr/local/bin/python-config /usr/bin/python-config
ln -s /usr/local/include/python2.7/ /usr/include/python2.7
vi /usr/bin/yum
修改第一行为
#!/usr/bin/python.old
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
下载dbmon最新代码安装依赖包
cd /opt
git clone https://github.com/gumengkai/dbmon.git
cd dbmon/
pip install -r requirements.txt
3.同步数据库,建用户
创建数据库导入sql
cd setup/mysql/
mysql -uroot -p
输入设置的密码
create database db_monitor default character set utf8;
mysql>use db_monitor
mysql>source dbmon.sql
mysql>source initdata.sql
mysql>quit
(监控Oracle时在被监控库、监控用户下执行):setup/oracle/procedure.sql & setup/oracle/table.sql
修改数据库连接配置
cd /opt/dbmon/
vi config/db_monitor.conf
vi dbmon/settings.py
pip install django-ckeditor
pip install markdown
暂时没有做用户/角色体系,可以先通过django自带的admin页面来管理
[root@aliyun dbmon]# python manage.py migrate
[root@aliyun dbmon]# python manage.py createsuperuser
user/passwd
4. 安装rabbitmq
用于celery任务管理
yum install epel-release
[root@aliyun dbmon]# yum install erlang
[root@aliyun dbmon]# yum install rabbitmq-server
[root@aliyun dbmon]# service rabbitmq-server start
Starting rabbitmq-server: SUCCESS
rabbitmq-server.
5. 启动
--数据采集
pip install requests
pip install delegator
[root@aliyun check_alarm]# python main_check.py
如果有下列提示,请查看tab_alarm_conf表是否中文乱码,重新导入一下数据
Traceback (most recent call last):
File "main_check.py", line 1320, in <module>
alarm.alarm()
File "/opt/dbmon/check_alarm/alarm.py", line 73, in alarm
pct_alarm = cpu_conf[0][1]
TypeError: 'int' object has no attribute '__getitem__'
--django
[root@aliyun dbmon]# python manage.py runserver 0.0.0.0:8000
浏览器访问
http://127.0.0.1:8000/login
如果提示缺少markdown2 安装 pip install markdown2
--webssh
[root@aliyun webssh]# python main.py
--celery
[root@aliyun dbmon]# celery -A dbmon worker -l info
[root@aliyun dbmon]# celery -A dbmon beat -l info
6.安装oracle客户端
下载客户端基本包(instantclient-basic-linux.x64-12.2.0.1.0.zip) 地址 https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
mkdir -p /opt/oracle
cd /opt/oracle
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
yum install libaio
sudo sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
参考 https://oracle.github.io/odpi/doc/installation.html#linux
7.创建诊断报告保存目录
mkdir -p /opt/dbmon/templates/oracle_report/