腾讯CMDB3.6.3部署

CMDB版本: https://gitee.com/Tencent-BlueKing/bk-cmdb/tree/release-v3.6.3

 

服务端配置:

 

 

 

 

 

 

 


#开始安装
#关闭防火墙和SELINUX
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld

#安装依赖
yum -y install  wget gcc gcc-c++ git vim gcc* java

#yum安装Golang
curl -o /etc/yum.repos.d/go-repo.repo https://mirror.go-repo.io/centos/go-repo.repo
yum clean all && yum makecache
yum -y install golang || kill -9 $$


#Nodejs安装:
[ -d /opop ] && mkdir /opop && cd /opop
wget https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz
xz -d node-v12.16.2-linux-x64.tar.xz
tar xvf node-v12.16.2-linux-x64.tar -C /usr/local/
mv /usr/local/node-v12.16.2-linux-x64/ /usr/local/node12.16
echo "export NODE_HOME=/usr/local/node12.16" >>/etc/profile
echo "export PATH=\$NODE_HOME/bin:\$PATH">>/etc/profile
source /etc/profile


#安装第三方组件依赖
[ ! -d /opop ] && mkdir /opop
wget -P /opop https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
wget -P /opop http://download.redis.io/releases/redis-3.2.11.tar.gz
cat >>/etc/yum.repos.d/mongodb-org-4.0.repo<<EOF
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/4.0/x86_64/
enabled=1
gpgcheck=0
EOF
yum -y install mongodb-org

cd /opop

#安装zookeeper
tar -zxvf /opop/zookeeper-3.4.14.tar.gz -C /usr/local/
cp -r /usr/local/zookeeper-3.4.14/conf/zoo_sample.cfg /usr/local/zookeeper-3.4.14/conf/zoo.cfg
#cd /usr/local/zookeeper-3.4.14/bin!!!!!!!!!!!!!!!
echo '#!/bin/bash' >>/etc/rc.d/init.d/start.sh
echo '#chkconfig:2345 99 20'>>/etc/rc.d/init.d/start.sh
echo "/usr/local/zookeeper-3.4.14/bin/zkServer.sh start">>/etc/rc.d/init.d/start.sh
chmod +x /etc/rc.d/init.d/start.sh
chkconfig --add /etc/rc.d/init.d/start.sh
chkconfig start.sh on

/usr/local/zookeeper-3.4.14/bin/zkServer.sh start &

#安装redis
tar -zxvf /opop/redis-3.2.11.tar.gz -C /usr/local/
cd /usr/local/ && mv redis-3.2.11/ redis3.2 && cd redis3.2/
make
cd src && make install PREFIX=/usr/local/redis
cd /usr/local/redis/ && mkdir etc logs db
cp -r /usr/local/redis3.2/redis.conf  etc/
sed -i "s/logfile \"\"/logfile \"\/usr\/local\/redis\/logs\/redis.log\"/g" /usr/local/redis/etc/redis.conf
sed -i "s/daemonize no/daemonize yes/g" /usr/local/redis/etc/redis.conf
echo "requirepass abc123" >> /usr/local/redis/etc/redis.conf
echo "dir /usr/local/redis/db" >> /usr/local/redis/etc/redis.conf
echo "/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf" >> /etc/rc.d/init.d/start.sh
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf &

#配置数据库
Redis需要打开auth认证的功能,并为其配置密码
安装MongoDB后,创建数据库 cmdb,并为新创建的数据库设置用户名和密码
MongoDB 示例:
登陆MongoDB后执行以下命令:
sed -i "s/bindIp: 127.0.0.1/bindIp: 0.0.0.0/" /etc/mongod.conf
systemctl start mongod
systemctl enable mongod.service

mongo --host 127.0.0.1:27017<<EOF
use cmdb
db.createUser({user: "cc",pwd: "cc",roles: [ { role: "readWrite", db: "cmdb" } ]})
EOF
systemctl restart mongod
mongo -ucc -pcc --authenticationDatabase cmdb<<EOF
exit
EOF
注:以上用户名、密码、数据库名仅作示例展示,用户使用中可以更具实际情况自行配置。如果安装的MongoDB的版本大于等于3.6,需要手动修改init.py自动生成的配置文件,详细步骤参看init.py相关小节。


#源码下载
#GOPATH 是go项目的根目录,配置GOPATH的示例如下:
mkdir -p /data/go/src
echo "export GOPATH=/data/go">>/etc/profile
source /etc/profile
cd $GOPATH/src
git clone --depth=1 git@gitee.com:Tencent-BlueKing/bk-cmdb.git
mv bk-cmdb/ configcenter

#编译
#进入源码根目录:
cd configcenter/src/
make NPM=cnpm

#打包
make package
#归档包存放位置: $GOPATH/src/configcenter/src/bin/pub/cmdb.tar.gz

#部署CMDB
cd $GOPATH/src/configcenter/src/bin/pub/
tar -zxvf cmdb.tar.gz -C /data/
#初始化系统
cd /data/cmdb/
python init.py \
--discovery 127.0.0.1:2181 \
--database cmdb \
--redis_ip 127.0.0.1 \
--redis_port 6379 \
--redis_pass abc123 \
--mongo_ip 127.0.0.1 \
--mongo_port 27017 \
--mongo_user  cc \
--mongo_pass cc \
--blueking_cmdb_url http://127.0.0.1:8083 \
--listen_port 8083

注:初始化系统的命令中有可能会出现字符编码问题,执行前如有报错需确认是否为字符编码问题

出现:initial configurations success, configs could be found at cmdb_adminserver/configures 则说明初始化成功

翻译:初始配置成功,可以在cmdb_adminserver / configures中找到配置

 

#启动服务
/data/cmdb/start.sh
正常情况执行完成后提示:process count should be: 12 , now: 12

 

 

#服务启动之后初始化数据库:
bash /data/cmdb/init_db.sh

========================================================================================

注:

如出现异常,需要查看每个组件下的logs目录中查看日志,或到/data/cmdb/cmdb_hostserver/logs/std.log查看,

如遇到fail to watch children for path(/cc/services/endpoints/sync), err:zk: node does not exist报错,需要重启下CMDB

/data/cmdb/restart.sh 或者 /data/cmdb/stop.sh && /data/cmdb/start.sh

以上报错在网页上显示为

========================================================================================

浏览器访问http://IP:8083

 

 

 

            欢迎一起讨论技术

 

posted @ 2020-05-15 15:18  Linux大魔王  阅读(753)  评论(0编辑  收藏  举报