小豆浆 运维故障管理系统 www.xdoujiang.com

  • A+
所属分类:linux实战

一、基础信息
1、IP、主机名、软件、系统版本
IP 主机名 软件 系统版本
192.168.4.73 python3 centos7

2、iptables
root@192.168.4.73:~# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

3、selinux
root@192.168.4.73:~# getenforce
Disabled

二、安装数据库
1、我这里已经准备好了rpm包了
root@192.168.4.73:mysql# ll
total 200252
-rw-r--r-- 1 root root 8984 Nov 12 2015 mysql57-community-release-el7-7.noarch.rpm
-rw-r--r-- 1 root root 25085192 Jul 16 2017 mysql-community-client-5.7.19-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 278292 Jul 16 2017 mysql-community-common-5.7.19-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 3778852 Jul 16 2017 mysql-community-devel-5.7.19-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2238032 Jul 16 2017 mysql-community-libs-5.7.19-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2115696 Jul 16 2017 mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 171537176 Jul 16 2017 mysql-community-server-5.7.19-1.el7.x86_64.rpm
root@192.168.4.73:mysql# pwd
/root/mysql

2、直接安装
root@192.168.4.73:mysql# yum -y localinstall mysql*

3、初始化
root@192.168.4.73:~# mysqld --initialize-insecure --user=mysql

4、启动服务
root@192.168.4.73:~# systemctl start mysqld

5、设置root密码
root@192.168.4.73:~# mysqladmin -u root password 123

6、创建1个数据库 一会会用到
root@192.168.4.73:~# mysql -uroot -p"123" -e "create database fms character set utf8 collate utf8_bin;"

三、搭建沙盒环境(python3环境)
1、下载python3源码包
root@192.168.4.73:~# wget http://mirrors.sohu.com/python/3.6.1/Python-3.6.1.tar.xz

2、编译三部曲
root@192.168.4.73:~# tar -xvf Python-3.6.1.tar.xz
root@192.168.4.73:~# cd Python-3.6.1/
root@192.168.4.73:Python-3.6.1# ./configure
root@192.168.4.73:Python-3.6.1# make
root@192.168.4.73:Python-3.6.1# make install

3、创建沙盒环境
root@192.168.4.73:~# pip3 install virtualenv

4、会创建1个python3目录
root@192.168.4.73:~# virtualenv -p python3 python3

5、进入目录后可以看到一些文件了
root@192.168.4.73:~# cd python3/
root@192.168.4.73:python3# ll
total 12
drwxr-xr-x 2 root root 4096 Jan 29 22:48 bin
drwxr-xr-x 2 root root 4096 Jan 29 22:48 include
drwxr-xr-x 3 root root 4096 Jan 29 22:48 lib
root@192.168.4.73:python3#

6、激活后前缀就变了
root@192.168.4.73:python3# . bin/activate
(python3) root@192.168.4.73:python3#

7、查看下当前版本
(python3) root@192.168.4.73:python3# python -V
Python 3.6.1
(python3) root@192.168.4.73:python3#

8、查看当前包的情况
(python3) root@192.168.4.73:python3# pip list --format=legacy
pip (9.0.1)
setuptools (38.4.0)
wheel (0.30.0)
(python3) root@192.168.4.73:python3#

四、搭建运维故障管理系统
1、下载源码
(python3) root@192.168.4.73:python3# git clone https://github.com/OpsWorld/fms.git
Cloning into 'fms'...
remote: Counting objects: 1040, done.
remote: Total 1040 (delta 0), reused 0 (delta 0), pack-reused 1040
Receiving objects: 100% (1040/1040), 6.93 MiB | 106.00 KiB/s, done.
Resolving deltas: 100% (194/194), done.

2、看下requirements.txt文件 一会需要安装的
(python3) root@192.168.4.73:python3# cd fms/
(python3) root@192.168.4.73:fms# ll
total 64
drwxr-xr-x 5 root root 4096 Jan 29 22:52 accounts
drwxr-xr-x 2 root root 4096 Jan 29 22:52 commons
drwxr-xr-x 4 root root 4096 Jan 29 22:52 content
drwxr-xr-x 3 root root 4096 Jan 29 22:52 dashboard
drwxr-xr-x 3 root root 4096 Jan 29 22:52 doc
drwxr-xr-x 2 root root 4096 Jan 29 22:52 fms
-rw-r--r-- 1 root root 18046 Jan 29 22:52 LICENSE
-rw-r--r-- 1 root root 801 Jan 29 22:52 manage.py
-rw-r--r-- 1 root root 1974 Jan 29 22:52 README.md
-rw-r--r-- 1 root root 85 Jan 29 22:52 requirements.txt
drwxr-xr-x 8 root root 4096 Jan 29 22:52 static
drwxr-xr-x 8 root root 4096 Jan 29 22:52 templates
(python3) root@192.168.4.73:fms# cat requirements.txt
django==1.11.0
django-breadcrumbs==1.1.4a1
django-paginator
mysqlclient
Pillow
pyyaml(python3) root@192.168.4.73:fms#

3、安装python依赖包
(python3) root@192.168.4.73:fms# pip3 install -r requirements.txt

4、修改数据库配置及访问权限
(python3) root@192.168.4.73:fms# pwd
/root/python3/fms/fms
(python3) root@192.168.4.73:fms# vim settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'fms',
'USER': 'root',
'PASSWORD': '123',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
我这里密码是123

还要修改允许的IP 我windows机器是192.168.4.56
ALLOWED_HOSTS = ['*']

5、建表
(python3) root@192.168.4.73:fms# python manage.py makemigrations
(python3) root@192.168.4.73:fms# python manage.py migrate
Operations to perform:
Apply all migrations: accounts, admin, auth, content, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying accounts.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying content.0001_initial... OK
Applying content.0002_auto_20170904_0857... OK
Applying sessions.0001_initial... OK

(python3) root@192.168.4.73:fms# python manage.py loaddata default_types
Installed 8 object(s) from 1 fixture(s)
(python3) root@192.168.4.73:fms# python manage.py loaddata default_user
Installed 1 object(s) from 1 fixture(s)

6、运行服务
(python3) root@192.168.4.73:fms# nohup python manage.py runserver 0.0.0.0:8000 &

7、网页访问
http://192.168.4.73:8000/
用户名和密码 admin admin
小豆浆 运维故障管理系统 www.xdoujiang.com

8、日志
看了下日志 有一些报错的 这个只能询问作者了

五、参考
https://github.com/OpsWorld/fms

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: