cmdb on centos 7 install opsmanage

举报
JBo 发表于 2021/08/12 08:34:18 2021/08/12
【摘要】 centos 7 opsmanage centos 7 opsmanage ops manage ansible OpsManage是什么? 开发语言与框架: OpsManage环境要求 安装环境配置 install redis 修改以下配置,不要设置密码 设置启动参数 redis boot config supervisord 加日志文件 启动celery centos 7 opsmana...

centos 7 opsmanage


centos 7 opsmanage


ops manage ansible

OpsManage是什么?

一款代码部署、应用部署、计划任务、设备资产管理平台。

开源协议GNU General Public License v2

开源声明:欢迎大家star或者fork我的开源项目,如果大家在自己的项目里面需要引用该项目代码,请在项目里面申明协议和版权信息。

开发语言与框架:

  • 编程语言:Python2.7 + HTML + JScripts
  • 前端Web框架:Bootstrap
  • 后端Web框架:Django
  • 后端Task框架:Celery + Redis

OpsManage环境要求

  • 编程语言:Python 2.7
  • 操作系统:CentOS 7
  • Ansible版本:2.0 +
  • 部署平台及节点服务器:Rsync 3+
  • MySQL版本:5.1-5.6

安装环境配置

一、安装Python env

# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
# yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
# wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/Centos-7.repo

# yum install screen ftp vim wget cmake git gcc gcc-c++ htop lrzsz ncurses-libs libdbi-devel -y

# yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel -y
# yum install libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel -y
# yum install python-devel zlib-devel  sshpass gcc git -y

~~~yum install kernel-devel libxslt-devel libffi-devel python-devel zlib-devel  sshpass python-paramiko -y~~~
~~~yum install 'perl(Data::Dumper)' python-devel mysql-devel -y~~~

# yum install Percona-Server-server-56 Percona-Server-devel-56 -y

# wget http://mirrors.sohu.com/python/2.7.12/Python-2.7.12.tgz  #CentOS 7不用安装python2.7

# python -V

Python 2.7.5

二、安装pip

centos 7

# wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
# python get-pip.py
# pip install -U 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

install redis

# wget http://download.redis.io/releases/redis-3.2.8.tar.gz
# tar -xzvf 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 你的服务器ip地址
例如: bind 127.0.0.1 192.168.88.201

设置启动参数

# cd ../
# mv redis-3.2.8 /usr/local/redis
# /usr/local/redis/src/redis-server /usr/local/redis/redis.conf

redis boot

[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

path

ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service

五、安装MySQL

# vim /etc/my.cnf
[mysqld]
character-set-server=utf8
server-id=1
log-bin=mysqld-bin
log-bin-index=mysqld-bin
#添加以上字段
# systemctl start mysql.service 	#centos 7
# mysql -uroot -p  				#初始密码为空,直接回车就行
mysql> create database opsmanage DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> grant all privileges on opsmanage.* to root@'%' identified by 'password';
mysql> flush privileges;
mysql>\q

六、配置OpsManage

# cd /mnt/OpsManage/OpsManage
# vim settings.py
BROKER_URL =  redis://localhost:6379/3 #修改成自己的配置
REDSI_KWARGS_LPUSH = {"host":'localhost','port':6379,'db':3} #修改成自己的配置
DATABASES = {
    'default': {
        'ENGINE':'django.db.backends.mysql',
        'NAME':'opsmanage',
        'USER':'root',		#修改成自己的配置
        'PASSWORD':'welliam',	#修改成自己的配置
        'HOST':'192.168.1.233', #修改成自己的配置
        'PORT': 3306
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ["/opt/OpsManage/OpsManage/static/",'/opt/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',
            ],
        },
    },
]
STATICFILES_DIRS = (
     '/opt/OpsManage/OpsManage/static/',	#修改成自己的配置
    )

worksapce.

# mkdir /var/lib/opsmanage/workspaces/ -p
# mkdir /data/opsmanage/workspaces/ -p

七、生成数据表与管理员账户

# cd /mnt/OpsManage/
# 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

八、启动部署平台

# cd /opt/OpsManage/
# python manage.py runserver 0.0.0.0:8000  #请继续完成下面的配置Celery步骤

九、配置证书认证

# ssh-keygen -t  rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@ipaddress

十、配置Celery异步任务系统

config supervisord

# echo_supervisord_conf > /etc/supervisord.conf

# export PYTHONOPTIMIZE=1

加日志文件

# vim /etc/supervisord.conf

最后添加,/var/log/celery-*.log这些是日志文件,如果有错误请注意查看

### list


[program:celery-worker-default]
command=/usr/bin/python manage.py celery worker --loglevel=info -E -Q default
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-worker-default.log   
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

[program:celery-worker-ansible]
command=/usr/bin/python manage.py celery worker --loglevel=info -E -Q ansible
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-worker-ansible.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1


[program:celery-beat]
command=/usr/bin/python manage.py celery beat
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-beat.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

[program:celery-cam]
command=/usr/bin/python manage.py celerycam
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-celerycam.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

启动celery

# /usr/local/bin/supervisord -c /etc/supervisord.conf
# supervisorctl status #要检查是否都是running状态,uptime是不是递增
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。