1、cuckoo版本升级
cuckoo默认的数据库为sqlite,默认连接方式为sqlite:///os.path.join(REPORT_ROOT, "db", "cuckoo.db")
升级cuckoo版本需要升级数据库版本,各个cuckoo版本的数据库有对应字段的修改,每个cuckoo版本的数据库有对应的
SCHEMA_VERSION,定义在lib/cuckoo/core/database.py中,因此升级cuckoo首先需要将数据库内容进行更新(主要是一些字段的改变和表内容的更新),方法:cd utils/db_migration/ && alembic upgrade head
2、数据库变更
通过查看cuckoo.conf配置文件,cuckoo目前主要支持三种形式的数据库sqlite、postgresql、mysql
cuckoo中对数据库进行判断,如果虚拟机数量大于1并且数据库类型为sqlite,那么并行处理任务可能会有一些问题
2.1、切换mysql
1、安装mysql(略过)
mysql> select version();
+------------+
| version() |
+------------+
| 5.6.24-log |+------------+
2、创建cuckoo数据库
mysql –uroot –ppassword 进入mysql数据库
create database cuckoo; 数据库路径在/polydata/data/db/mysql
查看数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cuckoo |
| mysql |
| performance_schema |
| polydata |
+--------------------+
3、修改配置文件
cuckoo.conf—>database—>connection = mysql://root:password@localhost/cuckoo
4、安装MySQLdb模块
sudo apt-get install python-mysqldb
python交互命令中如果能import MySQLdb则安装成功
如果未安装或安装失败,会报导入数据库驱动问题
5、解决不能通过mysql .sock连接MySQL问题
现象:Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决方法:ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
reference:http://blog.youkuaiyun.com/ixidof/article/details/5958904
至此cuckoo就可以使用mysql数据库,如果出现CuckooDatabaseError,即
删除数据库:drop database cuckoo;
2.2、切换postgresql
1、安装postgresql
apt-get install postgresql
sudo passwd postgres #修改postgres密码
版本:postgres=# select version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.9 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4, 64-bit
2、创建cuckoo数据库
sudo -u postgres psql #其中,sudo -u postgres 是使用postgres 用户登录的意思
postgres=# create database cuckoo; #创建cuckoo database
查看数据库:\l
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
cuckoo | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)常用命令:\l 查看系统中现存的数据库
\c database1 切换到database1
\dt 查看表
3、修改配置文件
cuckoo.conf—>database—>connection = postgresql://postgres:polydata@localhost:5432/cuckoo
4、安装psycopg2模块
sudo apt-get install python-psycopg2
python交互命令中如果能import psycopg2则安装成功
如果未安装或安装失败,会报导入数据库驱动问题