1. Opsmanage介绍
OpsManage 是一款进行设备资产、代码部署、应用部署、计划任务的管理平台,结合ansible进行自动化运维,可以在很大程度上解放运维工程师的双手。类似的运维平台还有腾讯的蓝鲸运维管理平台。
Git地址:https://github.com/welliamcao/OpsManage/blob/master/README.md
2. OpsManage安装
安装准备
- 所需环境:
编程语言:Python 2.7
操作系统:CentOS 6+
Ansible版本:2.0 +
部署平台及节点服务器:Rsync 3+
MySQL版本:5.1-5.6
安装所需包
# yum install -y zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel zlib-devel sshpass gcc git -y
# yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
# yum install -y Percona-Server-server-56 install Percona-Server-devel-56
# mkdir /software
# cd !$
安装python
因为是CentOS7,所以这一步我省略了。
# wget http://mirrors.sohu.com/python/2.7.12/Python-2.7.12.tgz (Centos 7 不用安装python2.7,因为已经默认自带python2.7)
# tar -zxf Python-2.7.12.tgz
# cd Python-2.7.12
# ./configure
# make all
# make install
# make clean
# make distclean
# mv /usr/bin/python /usr/bin/python2.6.6
# ln -s /usr/local/bin/python2.7 /usr/bin/python
# vim /usr/bin/yum #做下面修改
#!/usr/bin/python2.6.6
# vim /usr/libexec/urlgrabber-ext-down #做下面修改
#!/usr/bin/python2.6.6
安装easy_install
# cd /software
# wget --no-check-certificate https://pypi.python.org/packages/f7/94/eee867605a99ac113c4108534ad7c292ed48bf1d06dfe7b63daa51e49987/setuptools-28.0.0.tar.gz#md5=9b23df90e1510c7353a5cf07873dcd22
# tar -zxf setuptools-28.0.0.tar.gz
# cd setuptools-28.0.0
# python setup.py install
安装pip
# cd /software
# wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz -O pip-1.5.5.tar.gz
# tar -zxf pip-1.5.5.tar.gz
# cd pip-1.5.5
# python setup.py install
# pip install -U pip #升级pip,这一步不要省略
安装模块
# cd /mnt/
# git clone https://github.com/welliamcao/OpsManage.git
# cd /mnt/OpsManage/
# pip install -r requirements.txt
# easy_install paramiko==2.4.1
安装redis
# cd /software/
# wget http://download.redis.io/releases/redis-3.2.8.tar.gz
# tar -zxf redis-3.2.8.tar.gz
# cd redis-3.2.8
# make
# make install
# vim redis.conf #做下面修改
daemonize yes
loglevel warning
logfile "/var/log/redis.log"
bind 127.0.0.1 192.168.30.128(服务器IP)
# cd ..
# mv redis-3.2.8 /usr/local/redis
# /usr/local/redis/src/redis-server /usr/local/redis/redis.conf
配置mysql
# vim /etc/my.cnf
[mysqld]
character_set_server = utf8
# systemctl start mysqld
# mysql -uroot -p #初始密码为空,直接回车就行;或 grep "password" /var/log/mysqld.log 查看初始密码
mysql> create database opsmanage DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> grant all privileges on opsmanage.* to [email protected]'%' identified by '123456789';
mysql> flush privileges;
mysql> \q
systemctl restart msqld
配置opsmanage
# cd /mnt
# git clone https://github.com/welliamcao/OpsManage.git
# cd OpsManage/OpsManage/
# vim settings.py #做下面修改
BROKER_URL = 'redis://127.0.0.1:6379/4' #修改成自己的配置,格式是redis://[:password]@host:port/db
REDSI_KWARGS_LPUSH = {"host":'127.0.0.1','port':6379,'db':4} #修改成自己的配置
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer", # use redis backend
"CONFIG": {
"hosts": [("127.0.0.1", 6379)], #无密码方式
"channel_capacity": {
"http.request": 1000,
"websocket.send*": 10000,
},
"capacity": 10000,
},
"ROUTING": "OpsManage.routing.channel_routing", # load routing from our routing.py file
},
}
DATABASES = {
'default': {
'ENGINE':'django.db.backends.mysql',
'NAME':'opsmanage',
'USER':'root',
'PASSWORD':'123456789',
'HOST':'127.0.0.1',
'PORT':'3306'
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), #修改成自己的配置,这一步配置错误会导致django无法连接数据库
}
}
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ["/mnt/OpsManage/OpsManage/static/",'/mnt/OpsManage/OpsManage/templates/'], #修改成自己的配置
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'/mnt/OpsManage/OpsManage/static/', #修改成自己的配置
)
SFTP_CONF = {
'port':22,
'username':'root',
'password':'123456789',
'timeout':30
} #修改成自己的配置
生成数据表与管理员账户
# cd /mnt/OpsManage/
# python manage.py makemigrations OpsManage
出错:
django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'opsmanage' (using password: YES)")
解决:
# mysql -uroot -p
mysql> grant all privileges on *.* to [email protected]'%' identified by '123456789';
mysql> flush privileges;
mysql> \q
# python manage.py makemigrations OpsManage #继续执行这一步
# python manage.py makemigrations wiki
# python manage.py makemigrations orders
# python manage.py makemigrations filemanage
# python manage.py migrate
# python manage.py createsuperuser
启动部署平台
# python manage.py runserver 0.0.0.0:8000
# systemctl stop firewalld
# setenforce 0
后面关机后再打开Opsmanage:
# /usr/local/redis/src/redis-server /usr/local/redis/redis.conf
# python manage.py runserver 0.0.0.0:8000 &
- 打开浏览器,输出 服务器ip:8080 访问:
登陆进来是用户中心
- 查看
仪表板
:
- 查看
资产管理
:
- 查看
代码发布
:
- 查看
任务管理
:
- 查看
应用部署
:
今天就谈谈如何去安装OpsManage,至于怎么去使用后面有机会再说。安装过程不能完全照搬README文档,可能实际操作过程中会遇到一些问题需要我们具体去解决。