So Tired !_! 逆水行舟, 不进则退!

13Jan/16

Ubuntu下安装Altas 2.2.1

Posted by Nick Xu

1. 安装编译及依赖环境


for mariadb

1
sudo apt-get install build-essential libssl-dev liblua5.1-0-dev libmariadbd-dev flex bison gettext libjemalloc-dev libglib2.0-dev

for mysql

1
sudo apt-get install build-essential libssl-dev liblua5.1-dev libmysqld-dev flex bison gettext libjemalloc-dev libglib2.0-dev mysql-proxy

2. 补完其余依赖


1
2
3
4
5
wget https://launchpad.net/ubuntu/+archive/primary/+files/libevent_2.0.21-stable.orig.tar.gz
tar -zxvf libevent_2.0.21-stable.orig.tar.gz
cd libevent_2.0.21-stable
./configure && make
sudo make install

3. 针对configure LUA_LIBS 参数调整,建立软链接 (重要


1
2
3
4
5
6
7
8
9
10
sudo -i
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0 /usr/local/lib/liblua.so.0.0.0
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1-c++.a /usr/local/lib/liblua-c++.a
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1-c++.so.0 /usr/local/lib/liblua-c++.so.0
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so.0 /usr/local/lib/liblua.so.0
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1-c++.so /usr/local/lib/liblua-c++.so
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1-c++.so.0.0.0 /usr/local/lib/liblua-c++.so.0.0.0
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/local/lib/liblua.so
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.a /usr/local/lib/liblua.a
exit

4. 下载Atlas稳定版安装包


1
2
3
wget -O Atlas-2.2.1.zip https://codeload.github.com/Qihoo360/Atlas/zip/2.2.1
unzip Atlas-2.2.1.zip
cd Atlas-2.2.1

5. 修改 bootstrap.sh LUA_CFLAGS 将 /usr/local/include/ 修改为 /usr/include/lua5.1/ (重要


1
2
3
4
5
6
7
8
sudo cat > bootstrap.sh <<-"EOF"
#!/bin/sh 
base=$(cd "$(dirname "$0")"; pwd)
cd $base
# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --with-mysql=/usr --prefix=/usr/local/mysql-proxy CFLAGS="-DHAVE_LUA_H -O2" LDFLAGS="-lm -ldl -lcrypto -ljemalloc" LUA_CFLAGS="-I/usr/local/include/" LUA_LIBS="-L/usr/local/lib -llua"
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --with-mysql=/usr --prefix=/usr/local/mysql-proxy CFLAGS="-DHAVE_LUA_H -O2" LDFLAGS="-lm -ldl -lcrypto -ljemalloc" LUA_CFLAGS="-I/usr/include/lua5.1/" LUA_LIBS="-L/usr/local/lib -llua"
 
EOF

6. 编译安装 执行该步聚前,确认 第3、5步正确, 即 LUA_LIBS 与 LUA_CFLAGS 必须设置正确


1
2
3
./bootstrap.sh
make
sudo make install

7.配置示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
[mysql-proxy]
 
# (Necessary, the default value is ok) The name access to admin port
 
admin-username=user
 
# (Necessary, the default value is ok) The password access to admin port
 
admin-password=pwd
 
# (Necessary,set value according to the actual situation) The master database server,ip:port.
 
proxy-backend-addresses=192.168.88.11:3306
 
# (Not necessary,set value according to the actual situation) The slave database server, ip:port.
 
# The number behind '@'represents the weight used by load balance for reading,
 
# the default weight is 1. If you want the master backend also can process the read requests,
 
# add its ip:port to this configuration option.
 
proxy-read-only-backend-addresses=192.168.88.12:3306@5,192.168.88.13:3306@3,192.168.88.11:3306
 
# (Necessary,set value according to the actual situation) Username and its password login master and slave.
 
# We can use the username and password login the master database and the slave database server.
 
# The password encrypt by /usr/loca/mysql-proxy/bin/encrypt.
 
# For example, the username is: myuser, and the password is:mypwd (encrypted ciphertext is:HJBoxfRsjeI=).
 
pwds=repl:jNsKRuypPY0=
 
# (Necessary, the default value is ok) if the value is true,Atlas run as a daemon.
 
daemon=false
 
# (Necessary, the default value is ok) Atlas will start two processes when the value set true,
 
# one is monitor process, another is the work process. The monitor process will restart the work process
 
# automatically when the work process crash unexpectedly.
 
# If the value set false, Atlas will only start the work process.
 
keepalive=true
 
# (Necessary, set value according to the actual situation) The count of work threads in work process.
 
# set the value equal to twice of cpu cores
 
event-threads=4
 
# (Necessary, the default value is ok) Log level: message, warning, critical, error, debug
 
log-level=debug
 
# (Necessary, the default value is ok) Log file path
 
log-path=/usr/local/mysql-proxy/log
 
# (Necessary, the default value is ok) The switch for printing log.
 
#     ON          : log the sql to the log file with buffer.
 
#     OFF         : not log the sql.
 
#     REALTIME    : log the sql to the log file without buffer.
 
sql-log=REALTIME
 
# (Necessary, set value according to the actual situation) Slow log output settings.
 
# When this parameter is set, Only log the sql which execution time more than sql-log-slow (ms) logging.
 
# Do not set this parameter, will log all the sql.
 
sql-log-slow=10
 
# (Necessary, set value according to the actual situation) close the inactive client connections
 
# after ‘wait_timeout’ seconds
 
wait-timeout=10
 
# (Necessary, the default value is ok) The work port of Atlas
 
proxy-address=0.0.0.0:3307
 
# (Necessary, the default value is ok) The admin port of Atlas
 
admin-address=0.0.0.0:3308
 
# (Not necessary, set value according to the actual situation) Shard table setting.
 
# In this case, person is the database name, mt is the table name, id is the shard key,
 
# the shard table count is 3,and you should create table mt_0, mt_1, mt_2 in mysql manually.
 
# If you have more shard table,you can set them and separated by commas.
 
#tables = person.mt.id.3
 
# (Not necessary,set value according to the actual situation)character set,
 
# If you not set this parameter, the character is latin1.
 
charset=utf8
 
# (Not necessary,do not set this parameter) The client's IP be allowed to connect Atlas.
 
# If you not set this parameter, all client can connect Atlas.
 
client-ips=127.0.0.1,192.168.88
 
# (Not necessary,do not set this parameter) If you set client-ips, and through LVS connecting Atlas,
 
# then you need set lvs-ips, and this parameter is the true IP of LVS.
 
#lvs-ips = 192.168.1.1
Tagged as: , Comments Off
13Feb/15

mac上opencv安装步骤

Posted by Nick Xu

1. 去 http://opencv.org 下载最新版OpenCV for Linux/Mac源文件,目前版本是2.4.3。下载后解压。

2. 去 http://www.cmake.org 下载最新版cmake,.dmg文件,建议使用2.8.12.2版本。下载后安装。
3. 接下来开始安装opencv(注: 如果需要启用多核支持, 可以先按第6点进行修改后再编译,未经测试)

开一个终端,进入opencv解压缩的目录,如cd 然后把文件夹拽进去。
mkdir release
cd ./release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install
4. 至此opencv应该已经装上了。
 注:如果cmake出现错误,请到苹果开发者网站那里下载Command Line Tools安装。(关键)

由于本人是要写python,所以还要进行下一步配置。本人mac是rmbp15,自带的python版本是2.7,终端下输入python后输入import cv,如果提示没有找到cv,请按如下步骤操作。
1. 打开一个终端,cd ~
2. vim .profile
3. 添加export PYTHONPATH=/usr/local/lib/python2.7/site-packages/,其中python2.7根据个人python版本而定。
4. source .profile
5. 至此应该全部完成了。

6.补充:

I got this working with OpenCV 2.4.10 and GCC 4.9.2. I also had to make the following additional changes to the CMakeLists.txt in the root OpenCV directory:

OCV_OPTION(WITH_OPENEXR “Include ILM support via OpenEXR” OFF)
OCV_OPTION(WITH_OPENMP “Include OpenMP support” ON)
OCV_OPTION(BUILD_OPENEXR “Build openexr from source” OFF )

I originally was running into errors with “Undefined symbols for architecture x86_64 cv::imshow, cv::imread, cv::imwrite, etc,” because Homebrew installed a clang OpenCV whereas my project was using GCC. One solution would be to rebuild everything with clang but that was not appealing in my case because I wanted OpenMP support. So I instead used your solution to build a GCC version of OpenCV.

25Nov/12

[HOWTO] Build OpenWRT Trunk from svn on Mac OS X

Posted by Nick Xu

I recommend following these steps
1) Install XCode & Macports
2) Getting a build environment ready
3) Grabbing sources
4) Modifying Makefiles (e2fsprogs really doesn't like 64-bit Lion, and qemu refuses to compile)
5) Installing the missing dependancies
6) Building OpenWRT (from Updating Feeds on)

 

1. XCode & Macports
a. You will need to install Xcode 4.0 from the Apple developers' webpage, which will redirect you to the App Store entry for Xcode where you will follow the instructions on that page to install.

b. Then,  grab the latest MacPorts .pkg installer for Lion.
Mount the disk image and install MacPorts with the .pkg file. Open the Terminal.app from /Applications/Utilities

sudo port -v selfupdate && sudo port install subversion

Follow these directions if the above command does not work after mounting the dmg and installing.

Then:

port select --list gcc

Should give you an output similar to

air:~ alex$ port select --list gcc

Available versions for gcc:

apple-gcc42

gcc42

llvm-gcc42

mp-gcc44 (active)

none

I do not believe the version of gcc matters, but if it does, here's how to replicate my set up:

sudo port install gcc44 && sudo port select --set gcc mp-gcc44

Don't follow the above step unless you run into trouble later in the HOWTO when we try to compile OpenWRT.  The above command will build gcc-4.4 from scratch and that takes time. A lot of time.

 

2. Set up the build environment
a. Now install the packages needed to manipulate the OpenWRT source (horizontal scroll to see entire command, its long):

sudo port install coreutils asciidoc binutils bzip2 fastjar flex getopt gtk2 intltool jikes zlib openssl p5-extutils-makemaker python26 rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses

While this is compiling the packages for your system, continue on to 2b and 3a since they don't depend on any of the above packages.

b. The OpenWRT source is case-sensitive, unfortunately HFS+ drives formatted by Apple are not set to be case-sensitive; so we're going to create a .sparseimage workspace by opening Disk Utility in the /Applications/Utilities directory.

Click File -> New -> Blank Disk Image...
On the top of the dialog that just came up fill in "OpenWRT" without the quotes in the Save As: field and in the lower Name: field.

Choose a size larger than 3GB. My disk image is ~8G and will reach it's limit after compiling the packages and firmware images more than a few times.
IMPORTANT: In the Format: drop down, select  Mac OS Extended (case-sensitive

In the Image Format: drop down select "sparse disk image". Then click Create. The newly created disk image will be on the left panel of the Disk Utility, double clicking it will mount it on /Volumes/OpenWRT

3.Grabbing the source tree
a. Open the Terminal and type:

cd /Volumes/OpenWRT && svn co svn://svn.openwrt.org/openwrt/trunk/

Give it a few minutes while it pulls the source from the repository.

4. Modifying Makefiles
Open TextEdit.app and open /Volume/OpenWRT/trunk/tools/Makefile

cd /Volume/OpenWRT/trunk && open tools/Makefile

On line 17 erase the "e2fsprogs entry so it should look like this:

tools-y += sstrip ipkg-utils genext2fs  mtd-utils mkimage

Comment out line 22 like so:

#tools-$(CONFIG_TARGET_x86) += qemu

Then go on to comment out line 50, line 52, line 58; they are the build dependencies for mtd-utils (dep: e2fsprogs), qemu (dep: e2fsprogs), and e2fsprogs respectively.

5. Installing the missing dependencies
Now let's install and copy MacPort's e2fsprogs and osso-uuid's libraries and headers so we can build tools/mtd-utils correctly

sudo port install e2fsprogs osso-uuid

Followed by:

cd /Volumes/OpenWRT/trunk;

mkdir -p staging_dir/host/include/e2fsprogs;

cp -R /opt/local/include/ossp staging_dir/host/include/e2fsprogs/;

cp /opt/local/lib/libuuid* staging_dir/host/lib

Then follow this manual on how to build OpenWRT now that you have successfully built the necessary tools to compile OpenWRT images on Mac OS X 10.7 Lion.

Start from the section titled "Updating Feeds" and follow the wiki in it's entirety. Do not select any 'qemu' entries when you reach the make menuconfig step; qemu will not build on 64-bit Lion.

Tagged as: , , , , No Comments
   
site
site