今天有客户需要增加移动线路,但机房刚好移动线路还没有开通,试用了一下转发。效果还不错
客户需求是 服务器只做TCP服务,对应的是7000 7001 7002 7003 转发
先在移动机房增加一台CENTOS 6.5 64位 服务器安装好NGINX等组件
最好是安装1.9版本以上的
一、安装编译工具及库文件
#yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
#./configure --with-stream
#make
#make install
# /usr/local/nginx/sbin/nginx #启动
测试提示:/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
linux 64位安装nginx后启动出错报以下错误
|
#/usr/local/nginx/sbin/nginx
error
while
loading shared libraries: libpcre.so.
1
:
cannot open shared object file: No such file or directory
|
从错误看出是缺少lib文件导致,进一步查看下
1
2
3
4
5
6
7
8
9
10
|
[root
@localhost
nginx-
1.10
.
0
]# ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so.
1
=> (
0x00007fff4d5ff000
)
libpthread.so.
0
=> /lib64/libpthread.so.
0
(
0x00007fea7e357000
)
libcrypt.so.
1
=> /lib64/libcrypt.so.
1
(
0x00007fea7e120000
)
libpcre.so.
1
=> not found
libz.so.
1
=> /lib64/libz.so.
1
(
0x00007fea7df09000
)
libc.so.
6
=> /lib64/libc.so.
6
(
0x00007fea7db76000
)
/lib64/ld-linux-x86-
64
.so.
2
(
0x00007fea7e57d000
)
libfreebl3.so => /lib64/libfreebl3.so (
0x00007fea7d913000
)
libdl.so.
2
=> /lib64/libdl.so.
2
(
0x00007fea7d70f000
)
|
可以看出 libpcre.so.1 => not found 并没有找到,进入/lib64目录中手动链接下
1
2
|
[root
@localhost
/]# cd lib64/
[root
@localhost
lib64]# ln -s libpcre.so.
0.0
.
1
libpcre.so.
1
|
然后启动nginx就ok了
#pkill -9 nginx 强制结束
# /usr/local/nginx/sbin/nginx -v #查看nginx 支持模块
# /usr/local/nginx/sbin/nginx -t # 检查语法
配置nginx.conf 在最后添加如入:
stream {
upstream 7000 {hash $remote_addr consistent;
server 12.12.12.12:7000 max_fails=3 fail_timeout=30s;
}
upstream 7001 {
hash $remote_addr consistent;
server 12.12.12.12:7001 max_fails=3 fail_timeout=30s;
}
upstream 7002 {
hash $remote_addr consistent;
server 12.12.12.12:7002 max_fails=3 fail_timeout=30s;
}
upstream 7003 {
hash $remote_addr consistent;
server 12.12.12.12:7003 max_fails=3 fail_timeout=30s;
}
server {
listen 7000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7000;
}
server {
listen 7001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7001;
}
server {
listen 7002;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7002;
}
server {
listen 7003;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7003;
}
}
nginx 重启
#pkill -9 nginx 强行结束进程
# /usr/local/nginx/sbin/nginx 启动进程