<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[微信开源PhxSQL在CentOS下编译安装]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[开源世界]]></category>
<pubDate>Thu, 08 Sep 2016 04:33:25 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	官方更新了第三方库的版本之后，编译方法和可能遇到的错误和本文部分内容不一样了，全新安装的朋友请看<a href="http://www.zhanghaijun.com/post/969/" target="_blank">【CentOS下PhxSQL编译安装第2版】</a><br/><br/>注：仅测试在CentOS release 6.7 和 CentOS Linux release 7.2.1511下编译通过，本文以用户使用较多的CentOS 6 操作系统为例，centos 7 的差别是不需要升级autoconf、automake、gcc和python的版本，其他操作系统的用户请参考官方提供的中文详细编译手册：<a href="https://github.com/tencent-wechat/phxsql/wiki/%E4%B8%AD%E6%96%87%E8%AF%A6%E7%BB%86%E7%BC%96%E8%AF%91%E6%89%8B%E5%86%8C" target="_blank">https://github.com/tencent-wechat/phxsql/wiki/%E4%B8%AD%E6%96%87%E8%AF%A6%E7%BB%86%E7%BC%96%E8%AF%91%E6%89%8B%E5%86%8C</a><br/><br/>一、准备工作<br/>1.1：相关项目地址：<br/><a href="https://github.com/tencent-wechat/phxsql" target="_blank">https://github.com/tencent-wechat/phxsql</a><br/><a href="https://github.com/google/glog" target="_blank">https://github.com/google/glog</a><br/><a href="https://github.com/google/googlemock" target="_blank">https://github.com/google/googlemock</a><br/><a href="https://github.com/google/leveldb" target="_blank">https://github.com/google/leveldb</a><br/><a href="https://github.com/tencent-wechat/phxpaxos" target="_blank">https://github.com/tencent-wechat/phxpaxos</a><br/><a href="https://github.com/tencent-wechat/phxrpc" target="_blank">https://github.com/tencent-wechat/phxrpc</a><br/><a href="https://github.com/tencent-wechat/libco" target="_blank">https://github.com/tencent-wechat/libco</a><br/><a href="https://github.com/google/protobuf" target="_blank">https://github.com/google/protobuf</a><br/><br/>1.2：获取源码：<br/>git clone --recursive https://github.com/tencent-wechat/phxsql.git （--recursive参数可以同时获得所依赖的第三方库colib,glog,leveldb,protobuf源码，和依赖库phxpaxos,phxrpc）<br/><br/>1.3：编译前的准备工作,由于centos自带或者使用yum安装的工具软件版本都比较低，所以要升级相关依赖的库及工具。<br/>1.3.1：<br/>yum install readline readline-devel libstdc++-static glibc-static perl-Module-Install.noarch -y<br/><br/>1.3.2：autoconf<br/>下载地址：http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz<br/><div class="code">tar xzvf autoconf-2.69.tar.gz<br/>cd autoconf-2.69<br/>./configure --prefix=/usr/local/autoconf-2.69<br/>make &amp;&amp; make install<br/><br/>mv /usr/bin/autoconf /usr/bin/bak_autoconf<br/>mv /usr/bin/autoheader /usr/bin/bak_autoheader<br/>mv /usr/bin/autom4te /usr/bin/bak_autom4te<br/>mv /usr/bin/autoreconf /usr/bin/bak_autoreconf<br/>mv /usr/bin/autoscan /usr/bin/bak_autoscan<br/>mv /usr/bin/autoupdate /usr/bin/bak_autoupdate&nbsp;&nbsp; <br/>ln -sf /usr/local/autoconf-2.69/bin/autoconf /usr/bin/autoconf<br/>ln -sf /usr/local/autoconf-2.69/bin/autoheader /usr/bin/autoheader<br/>ln -sf /usr/local/autoconf-2.69/bin/autom4te /usr/bin/autom4te<br/>ln -sf /usr/local/autoconf-2.69/bin/autoreconf /usr/bin/autoreconf<br/>ln -sf /usr/local/autoconf-2.69/bin/autoscan /usr/bin/autoscan<br/>ln -sf /usr/local/autoconf-2.69/bin/autoupdate /usr/bin/autoupdate</div><br/><br/>1.3.3：automake<br/>下载地址：http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz<br/><div class="code">tar xzvf automake-1.14.tar.gz<br/>cd automake-1.14<br/>./configure --prefix=/usr/local/automake-1.14<br/>make &amp;&amp; make install<br/><br/>ln -sf /usr/local/automake-1.14/bin/aclocal-1.14 /usr/bin/aclocal-1.14<br/>ln -sf /usr/local/automake-1.14/bin/automake-1.14 /usr/bin/automake-1.14<br/>ln -sf /usr/local/automake-1.14/bin/aclocal-1.14 /usr/bin/aclocal-1.14<br/>mkdir /usr/share/automake-1.14<br/>ln -sf /usr/local/automake-1.14/share/automake-1.14/test-driver&nbsp;&nbsp;/usr/share/automake-1.14/test-driver</div><br/><br/>1.3.4：cmake<br/>下载地址：https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz<br/><div class="code">tar xzvf cmake-3.6.1.tar.gz<br/>cd cmake-3.6.1<br/>./configure<br/>make &amp;&amp; make install</div><br/><br/>1.3.5：python<br/>下载地址：https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz<br/><div class="code">tar xzvf Python-2.7.12.tgz<br/>cd Python-2.7.12<br/>./configure --prefix=/usr/local/python27<br/>make &amp;&amp; make install</div><br/><br/>1.3.6：gcc<br/>下载地址：http://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.gz<br/><div class="code">tar xzvf gcc-4.9.4.tar.gz<br/>cd gcc-4.9.4<br/>./contrib/download_prerequisites<br/>cd ..<br/>mkdir gcc-build-4.9.4<br/>cd gcc-build-4.9.4<br/>../gcc-4.9.4/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib<br/>make -j4 （-j4参数根据自己的cpu核心数来设置，这样编译的速度会快点，其实加了编译的时间也很长的）<br/>make install<br/>ls /usr/local/bin &#124; grep gcc<br/>update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/x86_64-unknown-linux-gnu-gcc-4.9.4 40 （优先使用4.9.4版本的gcc）<br/>使用 gcc --version 就可以看见当前使用的gcc版本是刚才编译的新版本了。<br/>cp gcc-build-4.9.4/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20 /usr/lib64/<br/>删除原来低版本的软链：rm -rf /usr/lib64/libstdc++.so.6<br/>创建新版本的软链：ln -sf /usr/lib64/libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6</div><br/><br/>####################################################################<br/>1.3.7：boost&nbsp;&nbsp; (此步可忽略)<br/>官网：http://www.boost.org/<br/>下载地址：https://sourceforge.net/projects/boost/files/boost/1.61.0/<br/>tar xzvf boost_1_61_0.tar.gz<br/>cd boost_1_61_0<br/>./bootstrap.sh --prefix=/usr/local/boost<br/>./b2<br/>./b2 install<br/><br/>echo /usr/local/boost/lib &gt;/etc/ld.so.conf.d/boost.conf<br/>ldconfig<br/>####################################################################<br/><br/>二、编译相关依赖<br/><div class="code">2.1：colib<br/>cd /home/phxsql/third_party/colib<br/>make<br/><br/>2.2：glog<br/>cd /home/phxsql/third_party/glog<br/>mkdir build &amp;&amp; cd build<br/>export CXXFLAGS=&quot;-fPIC&quot; &amp;&amp; cmake .. -DCMAKE_INSTALL_PREFIX=/home/phxsql/third_party/glog &amp;&amp; make VERBOSE=1<br/>make<br/>make install<br/><br/>2.3：leveldb<br/>/home/phxsql/third_party/leveldb<br/>make<br/>mkdir lib<br/>cp -ar out-shared lib/<br/>cp -ar out-static lib/<br/><br/>2.4：protobuf<br/>cd /home/phxsql/third_party/protobuf<br/>./autogen.sh<br/>./configure CXXFLAGS=-fPIC --prefix=/home/phxsql/third_party/protobuf<br/>make<br/>make install<br/><br/>2.5：phxrpc<br/>cd /home/phxsql/third_party/phxrpc<br/>mv third_party/protobuf third_party/bak_protobuf<br/>ln -sf /home/phxsql/third_party/protobuf /home/phxsql/third_party/phxrpc/third_party/protobuf<br/>ln -sf /usr/local/boost/include/boost /home/phxsql/third_party/phxrpc/boost<br/>make<br/>make boost&nbsp;&nbsp;(如果前面boost忽略，此步略过)<br/><br/>2.6：phxpaxos<br/>cd /home/phxsql/third_party/phxpaxos<br/>mv third_party/protobuf third_party/bak_protobuf<br/>mv third_party/leveldb third_party/bak_leveldb<br/>mv third_party/glog third_party/bak_glog<br/>ln -sf /home/phxsql/third_party/protobuf /home/phxsql/third_party/phxpaxos/third_party/protobuf<br/>ln -sf /home/phxsql/third_party/leveldb /home/phxsql/third_party/phxpaxos/third_party/leveldb<br/>ln -sf /home/phxsql/third_party/glog /home/phxsql/third_party/phxpaxos/third_party/glog<br/><br/>./autoinstall.sh<br/>make<br/>make install<br/>cd plugin<br/>make<br/>make install</div><br/><br/>三、编译安装PHXSQL<br/><div class="code">cd /home/phxsql<br/>wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.31-77.0/source/tarball/percona-server-5.6.31-77.0.tar.gz<br/>tar xzvf percona-server-5.6.31-77.0.tar.gz<br/>mv percona-server-5.6.31-77.0 percona<br/>sh autoinstall.sh<br/>make<br/>make install<br/><br/>3.1：生成安装包<br/>make package<br/>生成的压缩包名称为：phxsql-0.8.0.tar.gz</div><br/><br/>四、部署测试<br/>把安装包拷贝到其他测试的机器上，解压，本文目录全部为/home/phxsql<br/>创建mysql用户<br/>useradd -d /home/datacenter -s /sbin/nologin mysql<br/>mkdir /home/phxsql/etc<br/>cd /home/phxsql/tools<br/>把director_operator.py文件第26行中的chown user:mysql 修改为chown mysql:mysql<br/>把binary_installer.py文件第35行中的 cd %s/percona.src; ./scripts/mysql_install_db --defaults-file=%s/etc/my.cnf 修改为：cd %spercona.src; ./scripts/mysql_install_db --defaults-file=%setc/my.cnf<br/><br/>测试部署是用的三台虚拟机：<br/>python install.py -i&quot;192.168.1.186&quot; -p 54321 -g 6000 -y 11111 -P 17000 -a 8001 -f /home/datacenter/<br/>python install.py -i&quot;192.168.1.180&quot; -p 54321 -g 6000 -y 11111 -P 17000 -a 8001 -f /home/datacenter/<br/>/usr/local/python27/bin/python2.7 install.py -i&quot;192.168.1.241&quot; -p 54321 -g 6000 -y 11111 -P 17000 -a 8001 -f /home/datacenter/<br/><br/>在任意一台机器上执行<br/>cd /home/phxsql/sbin/<br/>./phxbinlogsvr_tools_phxrpc -f InitBinlogSvrMaster -h&quot;192.168.1.186,192.168.1.180,192.168.1.241&quot; -p 17000 (集群初始化完成之后就可以使用了。)<br/><br/><br/>./phxbinlogsvr_tools_phxrpc -f GetMemberList -h&quot;192.168.1.186&quot; -p 17000<br/>get master 192.168.1.241 expire time 1473313474<br/>ip 192.168.1.186 port 17000<br/>ip 192.168.1.180 port 17000<br/>ip 192.168.1.241 port 17000<br/><br/>登录数据库：<br/>/home/phxsql/percona.src/bin/mysql -uroot -h&quot;192.168.1.186&quot; -P54321<br/><br/>#获取master信息：<br/>./phxbinlogsvr_tools_phxrpc -f GetMasterInfoFromGlobal -h 192.168.1.186 -p 17000<br/>get master 192.168.1.241 expire time 1473314016<br/><br/>修改管理帐号及密码：<br/>./phxbinlogsvr_tools_phxrpc -f SetMySqlAdminInfo -h 192.168.1.180 -p 17000 -u root -d &quot;&quot; -U zhj -D zhj2016&nbsp;&nbsp;<br/>get master 192.168.1.241 expire time 1473313844<br/>SetMySqlAdminInfo admin username root -&gt; new admin username zhj<br/><br/>用官方提供的测试工具测试：<br/>cd /home/phxsql/tools/<br/>chmod +x test_phxsql.sh<br/>./test_phxsql.sh 54321 192.168.1.186 192.168.1.180 192.168.1.241<br/><a href="http://www.zhanghaijun.com/attachment.php?fid=218" target="_blank"><img src="http://www.zhanghaijun.com/attachment.php?fid=218" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>sysbench 简单测试：<br/><a href="http://www.zhanghaijun.com/attachment.php?fid=219" target="_blank"><img src="http://www.zhanghaijun.com/attachment.php?fid=219" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>Tags - <a href="http://www.zhanghaijun.com/tags/centos/" rel="tag">centos</a> , <a href="http://www.zhanghaijun.com/tags/phxsql/" rel="tag">phxsql</a>
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] 微信开源PhxSQL在CentOS下编译安装]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>