本文档是手动制作mysql5.6的trove镜像
openstack版本为newton
1、创建基础虚拟机
登录openstack创建一台虚拟机,这台虚拟机用于制作trove镜像,虚拟机的根磁盘最终会上传到glance给trove使用,虚拟机的根磁盘容量根据需要设置,这里略掉这步的详细操作。
以下操作皆登录到这台虚拟机中操作
2、配置ssh
cat /etc/ssh/sshd_configUseDNS no
3、添加mysql源
yum install http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpmyum remove mariadb-libs
4、编辑/etc/yum.repos.d/mysql-community.repo 禁用mysql5.7,启用mysql5.6
# Enable to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
5、安装mysql5.6
安装完mysql後,不必设置mysqld随机启动
yum install mysql-community-server
6、配置mysql
6.1、编辑/etc/my.cnf,在文件末尾添加下面一行,include这行上面有一行空白...!includedir /etc/mysql/conf.d/
6.2、创建目录
mkdir -p /etc/mysql/conf.d/
7、安装percona-xtrabackup
innobackupexyum install https://www.percona.com/redir/downloads/percona-release/redhat/percona-release-0.1-4.noarch.rpmyum install percona-xtrabackup-24
8、源代码安装trove-agent
8.1、安装相关软件包yum install git python-virtualenv
8.2、创建用户
useradd -m trove# 设置trove sudocat /etc/sudoers.d/trove Defaults:trove !requirettytrove ALL=(ALL) NOPASSWD:ALL
8.3、下载trove源码
mkdir /opt/trovechown trove:trove /opt/trovesu - trovecd /opt/trovegit clone https://github.com/openstack/trove.git
8.4、整合代码
由于在centos上备份时,有bug:1649592,已经整合时master分支,需要将commit整合进stable/newton分支commit c1fd3e3a4c643dba524656c8d53d3506233beaf3Merge: 880c707 f5d1caeAuthor: JenkinsDate: Thu Jan 19 16:07:48 2017 +0000 Merge "Fix backup of mysql variants on Centos"...commit f5d1caea889f85196dfc1efe4892560f0b145191Author: Doug Shelley 2016-01-20 04:22:03Committer: Doug Shelley 2016-12-14 00:29:41
8.5、整合提交
git config --global user.email "youre mail"git config --global user.name "yuoure name"git checkout stable/newtongit cherry-pick f5d1cae
8.6、安装trove
8.6.1、安装troveyum install gccsu - trovecd /opt/trovevirtualenv vensource ven/bin/activatepip install pip --upgradecd trovepip install -r requirements.txt \ --index-url http://mirrors.aliyun.com/pypi/simple/ \ --trusted-host mirrors.aliyun.compython setup.py install
8.6.2、创建启动文件
mkdir -p /etc/trove/conf.dchown -R trove:trove /etc/trovemkdir -p /var/lib/trovechown -R trove:trove /var/lib/trovemkdir -p /var/log/trovechown -R trove:trove /var/log/trove# 如果trove-guestagent.conf,guest_info.conf未预先创建,# 并设置/etc/trove的owner为trove,创建instance后,# 由nova注入的这两个文件将拥有root权限# 文件预先存在,nova 注入文件不改变文件的user和group,会改变文件的读写权限touch /etc/trove/conf.d/trove-guestagent.conftouch /etc/trove/conf.d/guest_info.confchown -R trove:trove /etc/trovecat /usr/lib/systemd/system/trove-guestagent.service[Unit]Description=OpenStack Trove guestagent ServiceAfter=syslog.target network.target[Service]Type=simpleUser=troveExecStart=/opt/trove/ven/bin/trove-guestagent --config-file /etc/trove/conf.d/trove-guestagent.conf --config-file /etc/trove/conf.d/guest_info.confRestart=on-failure[Install]WantedBy=multi-user.targetsystemctl daemon-reloadsystemctl enable trove-guestagent
9、上传镜像
9.1、清理系统rm -rf .sshrm -rf /home/trove/.cache/rm -rf /var/lib/mysql/auto.cnf poweroff
9.2、将镜像制作成快照
10、配置trove使用制作好的镜像trove-manage --config-file /etc/trove/trove.conf \ datastore_version_update mysql mysql-5.6 mysql \ 0eb99bad-ad41-420c-bab5-844d84421c23 '' 1