当前位置: 代码迷 >> 综合 >> cmdb
  详细解决方案

cmdb

热度:81   发布时间:2023-12-20 22:44:32.0

CMDB --Configuration Management Database 配置管理数据库, CMDB存储与管理企业IT架构中设备的各种配置信息,它与所有服务支持和服务交付流程都紧密相联,支持这些流程的运转、发挥配置信息 的价值,同时依赖于相关流程保证数据的准确性。

 

实验环境

centos7.3_x64

 

实验软件

jdk-8u152-linux-x64.tar.gz

zookeeper-3.4.11.tar.gz

redis-3.2.12.tar.gz

mongodb-linux-x86_64-rhel70-2.8.0-rc5.tgz

cmdb.tar.gz

 

软件安装

yum clean all && yum makecache fast -y

cp -pv /etc/hosts /etc/hosts.bak

echo 192.168.10.17 cmdb >> /etc/hosts

hostnamectl set-hostname cmdb

systemctl restart ntpd.service && systemctl enable ntpd.service

ntpdate 192.168.10.17 && clock -w

python --version

Python 2.7.5

 

tar zxvf /root/jdk-8u152-linux-x64.tar.gz

mv /root/jdk1.8.0_152 /usr/local/java

cp -pv /etc/profile /etc/profile.bak

export JAVA_HOME=/usr/local/java  >> /etc/profile

export PATH=$PATH:$JAVA_HOME/bin  >> /etc/profile

source  /etc/profile && java -version

java version "1.8.0_152"

 

tar zxvf /root/zookeeper-3.4.11.tar.gz

mv /root/zookeeper-3.4.11 /usr/local/zk1

mv /usr/local/zk1/conf/zoo_sample.cfg  /usr/local/zk1/conf/zoo.cfg

mkdir -pv /usr/local/zk1/data

echo 1 > /usr/local/zk1/data/myid

cat /usr/local/zk1/conf/zoo.cfg

dataDir=/usr/local/zk1/data/

clientPort=2181

maxClientCnxns=100

tickTime=2000

initLimit=10

syncLimit=5

zookeeper.connect=192.168.10.17:2181

 

touch /etc/init.d/zookeeper && chmod +x /etc/init.d/zookeeper

cat /etc/init.d/zookeeper 

#!/bin/bash

#chkconfig:2345 20 90

#description:zookeeper

#processname:zookeeper

 

ZK_PATH=/usr/local/zk1 

export JAVA_HOME=/usr/local/java

 

case $1 in

         start) sh  $ZK_PATH/bin/zkServer.sh start;;

         stop)  sh  $ZK_PATH/bin/zkServer.sh stop;;

         status) sh  $ZK_PATH/bin/zkServer.sh status;;

         restart) sh $ZK_PATH/bin/zkServer.sh restart;;

         *)  echo "require start|stop|status|restart"  ;;

esac

/etc/init.d/zookeeper  start

chkconfig --add zookeeper

 

tar zxvf /root/redis-3.2.12.tar.gz

cd /root/redis-3.2.12

make -j4 && make install  PREFIX=/usr/local/redis

cp -pv /root/redis-3.2.12/redis.conf /usr/local/redis/

mkdir -pv /var/log/redis && touch /var/log/redis/redis.log

cp -pv /usr/local/redis/redis.conf /usr/local/redis/redis.conf.bak

cat /usr/local/redis/redis.conf

port  6379

daemonize  yes   

bind  127.0.0.1 192.168.10.17

#requirepass 123456  

appendonly yes

appendfsync everysec

pidfile   /var/run/redis.pid

logfile   /var/log/redis/redis.log

ln -s /usr/local/redis/bin/* /bin/

 

touch /etc/init.d/redis && chmod +x /etc/init.d/redis

cat /etc/init.d/redis 

#!/bin/sh

# chkconfig:   2345 90 10

# Simple Redis init.d script conceived to work on Linux systems

# as it does use of the /proc filesystem.

 

REDISPORT=6379

EXEC=/usr/local/redis/bin/redis-server 

CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid

CONF="/usr/local/redis/redis.conf"

 

case "$1" in

    start)

        if [ -f $PIDFILE ]

        then

                echo "$PIDFILE exists, process is already running or crashed"

        else

                echo "Starting Redis server..."

                $EXEC $CONF

        fi

        ;;

    stop)

        if [ ! -f $PIDFILE ]

        then

                echo "$PIDFILE does not exist, process is not running"

        else

                PID=$(cat $PIDFILE)

                echo "Stopping ..."

                $CLIEXEC -p $REDISPORT shutdown

                while [ -x /proc/${PID} ]

                do

                    echo "Waiting for Redis to shutdown ..."

                    sleep 1

                done

                echo "Redis stopped"

        fi

        ;;

    *)

        echo "Please use start or stop as first argument"

        ;;

esac

/etc/init.d/redis start

chkconfig --add redis

 

tar zxvf /root/mongodb-linux-x86_64-rhel70-2.8.0-rc5.tgz

mv /root/mongodb-linux-x86_64-rhel70-2.8.0-rc5 /usr/local/mongodb

mkdir -p /usr/local/mongodb/data

mkdir -p /usr/local/mongodb/data/db

mkdir -p /usr/local/mongodb/logs

touch /usr/local/mongodb/logs/mongodb.log

ln -s /usr/local/mongodb/bin/* /bin/

cat /usr/local/mongodb/mongodb.conf 

port = 27017        

bind_ip = 192.168.10.17

dbpath =  /usr/local/mongodb/data/  

logpath = /usr/local/mongodb/logs/mongodb.log 

logappend = true   

fork = true

maxConns=5000  

journal = true   

auth = true

httpinterface=true      

 

touch /etc/init.d/mongodb  && chmod +x /etc/init.d/mongodb       创建启动脚本

cat /etc/init.d/mongodb 

#!/bin/sh 

#chkconfig: 2345 80 90 

#description: mongodb

 

start() {

mongod -f /usr/local/mongodb/mongodb.conf

}

 

stop() {

mongod -f /usr/local/mongodb/bin/mongodb.conf --shutdown

}

 

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

stop

start

;;

*)

echo $"Usage: $0 {start|stop|restart}" 

exit 1

esac

/etc/init.d/mongodb start

chkconfig --add mongodb

 

mongo --host 192.168.10.17

> use admin

> db.createUser({user: 'root', pwd: 'Root1q2w', roles: ['root']})

> use cmdb

> db.createUser({user: "cc",pwd: "cc",roles: [ { role: "readWrite", db: "cmdb" } ]})

 

tar zxvf /root/cmdb.tar.gz

mv /root/cmdb /opt/

cd /opt/cmdb/

python init.py --discovery 192.168.10.17:2181 --database cmdb --redis_ip 192.168.10.17 --redis_port 6379 --redis_pass Root1q2w --mongo_ip 192.168.10.17 --mongo_port 27017 --mongo_user cc --mongo_pass cc --blueking_cmdb_url http://192.168.10.17:8083 --listen_port 8083

blueking_cmdb_url: http://192.168.10.17:8083

bash /opt/cmdb/start.sh

bash /opt/cmdb/init_db.sh

 

netstat -tuplna | grep 2181

tcp6       0      0 :::2181                 :::*                    LISTEN      2160/java 

netstat -tuplna | grep 6379

tcp        0      0 192.168.10.17:6379      0.0.0.0:*               LISTEN      5291/redis-server 1 

tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      5291/redis-server 1

netstat -tuplna | grep 27017

tcp        0      0 192.168.10.17:27017     0.0.0.0:*               LISTEN      14789/mongod

netstat -tuplna | grep 28017

tcp        0      0 192.168.10.17:28017     0.0.0.0:*               LISTEN      2190/mongod     

netstat -tuplna | grep cmdb

tcp        0      0 192.168.10.17:8080      0.0.0.0:*               LISTEN      15064/./cmdb_apiser 

tcp        0      0 192.168.10.17:60001     0.0.0.0:*               LISTEN      15140/./cmdb_hostse 

tcp        0      0 192.168.10.17:60002     0.0.0.0:*               LISTEN      15200/./cmdb_topose 

tcp        0      0 192.168.10.17:60003     0.0.0.0:*               LISTEN      15185/./cmdb_procse 

tcp        0      0 192.168.10.17:60005     0.0.0.0:*               LISTEN      15095/./cmdb_dataco 

 

http://serverip:28017

41.jpg

 

http://serverip:8083

41.jpg