Centos7操作系统搭建ITDB系统及实时备份服务

一、ITDB简介

    ITDB一款来自希腊的开源IT资产管理系统,它是基于Web的IT资产信息管理系统。对于那些IT设备较多而又缺少管理IT资产信息工具的公司,ITDB是一个不错的选择,ITDB经过三年的开发、更新无论从功能还是界面都是一个成熟的产品。

二、ITDB资产管理系统搭建

    1、安装环境

        操作系统:CentOS Linux release 7.6.1810 (Core) 

        IDTB服务器地址:172.28.5.151

        IDTB备份服务器:172.28.5.152

        sqlite版本:sqlite.x86_64   3.7.17-4.el7

    2、安装httpd以及php以及php-pdo(php操作数据库的工具,默认的sqlite已经安装)

        yum install -y httpd php php-pdo

        image.png

    3、确保开机启动httpd服务

        image.png

    4、启动httpd服务:

        image.png    

    5、验证httpd和php正常工作

        在服务器/var/www/html目录下新建 一个test.php文件,内容为:

        vim /var/www/html/test.php

        image.png

        打开浏览器输入:172.28.5.151/test.php

        image.png

    6、下载压缩包

        登录官网:http://www.sivann.gr/software/itdb/ ,下载合适的版本:itdb-1.23.zip ,下载后然后再上传至服务器。   

        image.png

        image.png

    7、解压文件并拷贝到web服务器根目录

         unzip itdb-1.23.zip 

        image.png

        然后拷贝解压后的文件到/var/www/html目录下:

        进入/var/www/html,重命名数据库:

        image.png

        添加相应权限并重启服务:

        image.png

    8、浏览器输入服务IP地址:

        image.png

        根据提示的错误,进行相应的操作,然后重启服务,然后再用浏览器打开,一直进行调试,直至出现正确界面:

        image.png

    9、设置成中文:

        登录ITDB系统,然后找到settings:

        image.png

        ITDB系统的首页界面:

        image.png

三、ITDB资产管理系统实时备份

        选择一台备份服务器,用来存放备份出来的文件。

        备份服务的IP地址是 172.28.5.152 ,

        以下操作在备份服务器(172.28.5.152)上进行:

    1、安装rsync

        yum -y install rsync

        image.png

    2、手动添加rsync用户,此用户是用来运行rysnc daemon进程的

        useradd rsync -s /sbin/nologin 

    3、创建rsync daemon 工作模式的模块目录

            mkdir -p /backup/itdb

    4、修改目录属主属组

        chown rsync.rsync /backup/itdb/

    5、修改rsync配置文件/etc/rsync.conf, 以下为一个配置文件案例

        vim /etc/rsyncd.conf

        image.png

        image.png

    6、创建同步用户密码文件

        vim /etc/rsync.password

        image.png

        rsync_backup 是同步用户, leesir 是密码

    7、设置密码文件读取权限

        chmod 600 /etc/rsync.password

    8、启动rsync守护进程

        rsync --daemon

    9、查看873端口是否监听

        image.png

    以下操作在ITDB服务器上进行操作:

    1、查看当前系统是否支持inotify

        image.png

        显示这三个文件则证明支持

    2、安装编译及下载以及同步需要的安装包

        yum install wget gcc gcc-c++ make rsync -y

        image.png

    3、下载inotify源码包并编译安装

        wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz -P /opt

          cd /opt && tar xvf inotify-tools-3.14.tar.gz

        cd /opt/inotify-tools-3.14/ && ./configure --prefix=/usr/local/inotify

         make && make install

    4、增加同步用户密码文件/etc/rsync.password

        leesir        (这里只需要密码,不需要写用户)

    5、编写监控脚本,监控文件变动信息,实时同步到备份服务器,itdb系统使用的数据库是sqlite3 ,数据全部存储在it.db文件里,只要同步好这个文件就可以了,it.db一般在/var/www/html/data目录下,所以同步此目录就可以了。

        编写一个同步数据的脚本 /opt/inotiyf_itdb.sh

        

#! /bin/bash


#para


host01=172.28.5.152


src=/var/www/html/data


dst=itdb


user=rsync_backup


rsync_passfile=/etc/rsync.password


inotify_home=/usr/local/inotify


#judgge


if [ ! -e "$src" ] \

|| [ ! -e "${rsync_passfile}" ] \

|| [ ! -e "${inotify_home}/bin/inotifywait" ] \

|| [ ! -e "/usr/bin/rsync" ];

then

echo "Check File and Folder"

exit 9

fi

${inotify_home}/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,delete,create,attrib $src \

| while read file

do

# rsync -avzP --delete --timeout=100 --password-file=${rsync_passfile} $src $user@$host01::$dst >/dev/null 2>&1

cd $src && rsync -aruz -R --delete ./ --timeout=100 $user@$host01::$dst --password-file=${rsync_passfile} >/dev/null 2>&1

done

exit 0

        解释:

    image.png

    6、后台运行脚本

        #bash /opt/inotify_itdb.sh &

        image.png

    7、在itdb 网页修改或增加内容,然后到备份服务ls -l 查看文件的时间,看看文件是否同步了。

    8、如果有需要恢复的,可以将备份出来的itdb.db文件复制到/var/www/html/data/目录下,然后重启httpd服务就可以了

        

        

        

        

        

猜你喜欢

转载自blog.51cto.com/5001660/2371938