Haproxy的安装以及启动脚本的调试
2016-10-28 14:16
204 查看
1 )源代码安装haproxy
[root@mysql-slave src]# tar xf haproxy-1.6.4.tar.gz
[root@mysql-slave src]# cd haproxy-1.6.4
[root@mysql-slave haproxy-1.6.4]# make TARGET=linux26 PREFIX=/usr/local/haproxy
[root@mysql-slave haproxy-1.6.4]# echo $?
0
[root@mysql-slave haproxy-1.6.4]# make install PREFIX=/usr/local/haproxy
[root@mysql-slave haproxy-1.6.4]# mkdir /usr/local/haproxy/conf
[root@mysql-slave haproxy-1.6.4]# ls
CHANGELOG CONTRIBUTING ebtree haproxy include MAINTAINERS README src tests VERSION
contrib doc examples haproxy-systemd-wrapper LICENSE Makefile ROADMAP SUBVERS VERDATE
[root@mysql-slave haproxy-1.6.4]# cp examples/option-http_proxy.cfg /usr/local/haproxy/conf/haproxy.cfg
2)haproxy的启动脚本配置
由于我的安装包是下载在/usr/local/src下的,我们查看下解压后的haproxy的文件
[root@mysql-slave examples]# pwd
/usr/local/src/haproxy-1.6.4/examples
[root@mysql-slave examples]# ls
acl-content-sw.cfg check.conf debug2html haproxy.init init.haproxy ssl.cfg
auth.cfg content-sw-sample.cfg debugfind haproxy.spec option-http_proxy.cfg stats_haproxy.sh
check debug2ansi errorfiles haproxy.vim seamless_reload.txt transparent_proxy.cfg
如上,我们可以看到一个名为haproxy.init文件
简单查看下haproxy.init的内容
[root@mysql-slave examples]# cat haproxy.init
BIN=/usr/local/haproxy/sbin/haproxy
# haproxy命令所在的位置
CFG=/usr/local/haproxy/conf/haproxy.cfg
# haproxy.cfg为haproxy的配置文件
修改完成后,将修改后的haproxy.init拷贝到/etc/init.d/目录下
附件:http://down.51cto.com/data/2368319
[root@mysql-slave src]# tar xf haproxy-1.6.4.tar.gz
[root@mysql-slave src]# cd haproxy-1.6.4
[root@mysql-slave haproxy-1.6.4]# make TARGET=linux26 PREFIX=/usr/local/haproxy
[root@mysql-slave haproxy-1.6.4]# echo $?
0
[root@mysql-slave haproxy-1.6.4]# make install PREFIX=/usr/local/haproxy
[root@mysql-slave haproxy-1.6.4]# mkdir /usr/local/haproxy/conf
[root@mysql-slave haproxy-1.6.4]# ls
CHANGELOG CONTRIBUTING ebtree haproxy include MAINTAINERS README src tests VERSION
contrib doc examples haproxy-systemd-wrapper LICENSE Makefile ROADMAP SUBVERS VERDATE
[root@mysql-slave haproxy-1.6.4]# cp examples/option-http_proxy.cfg /usr/local/haproxy/conf/haproxy.cfg
2)haproxy的启动脚本配置
由于我的安装包是下载在/usr/local/src下的,我们查看下解压后的haproxy的文件
[root@mysql-slave examples]# pwd
/usr/local/src/haproxy-1.6.4/examples
[root@mysql-slave examples]# ls
acl-content-sw.cfg check.conf debug2html haproxy.init init.haproxy ssl.cfg
auth.cfg content-sw-sample.cfg debugfind haproxy.spec option-http_proxy.cfg stats_haproxy.sh
check debug2ansi errorfiles haproxy.vim seamless_reload.txt transparent_proxy.cfg
如上,我们可以看到一个名为haproxy.init文件
简单查看下haproxy.init的内容
[root@mysql-slave examples]# cat haproxy.init
#!/bin/sh # # chkconfig: - 85 15 # description: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited \ # for high availability environments. # processname: haproxy # config: /etc/haproxy/haproxy.cfg # pidfile: /var/run/haproxy.pid # Script Author: Simon Matter <simon.matter@invoca.ch> # Version: 2004060600 # Source function library. if [ -f /etc/init.d/functions ]; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # This is our service name BASENAME=`basename $0` if [ -L $0 ]; then BASENAME=`find $0 -name $BASENAME -printf %l` BASENAME=`basename $BASENAME` fi BIN=/usr/sbin/$BASENAME CFG=/etc/$BASENAME/$BASENAME.cfg [ -f $CFG ] || exit 1 PIDFILE=/var/run/$BASENAME.pid LOCKFILE=/var/lock/subsys/$BASENAME RETVAL=0 start() { quiet_check if [ $? -ne 0 ]; then echo "Errors found in configuration file, check it with '$BASENAME check'." return 1 fi echo -n "Starting $BASENAME: " daemon $BIN -D -f $CFG -p $PIDFILE RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCKFILE return $RETVAL } stop() { echo -n "Shutting down $BASENAME: " killproc $BASENAME -USR1 RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $LOCKFILE [ $RETVAL -eq 0 ] && rm -f $PIDFILE return $RETVAL } restart() { quiet_check if [ $? -ne 0 ]; then echo "Errors found in configuration file, check it with '$BASENAME check'." return 1 fi stop start } reload() { if ! [ -s $PIDFILE ]; then return 0 fi quiet_check if [ $? -ne 0 ]; then echo "Errors found in configuration file, check it with '$BASENAME check'." return 1 fi $BIN -D -f $CFG -p $PIDFILE -sf $(cat $PIDFILE) } check() { $BIN -c -q -V -f $CFG } quiet_check() { $BIN -c -q -f $CFG } rhstatus() { status $BASENAME } condrestart() { [ -e $LOCKFILE ] && restart || : } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart) condrestart ;; status) rhstatus ;; check) check ;; *) echo $"Usage: $BASENAME {start|stop|restart|reload|condrestart|status|check}" exit 1 esac exit $?我们发现,稍微调整下,就是一个完整的haproxy的启动脚本,所以偷下懒,直接修改两个位置:
BIN=/usr/local/haproxy/sbin/haproxy
# haproxy命令所在的位置
CFG=/usr/local/haproxy/conf/haproxy.cfg
# haproxy.cfg为haproxy的配置文件
修改完成后,将修改后的haproxy.init拷贝到/etc/init.d/目录下
[root@mysql-slave examples]# cp /usr/local/src/haproxy-1.6.4/examples/haproxy.init /etc/init.d/ [root@mysql-slave examples]# mv /etc/init.d/haproxy.init /etc/init.d/haproxy [root@mysql-slave examples]# chmod +x /etc/init.d/haproxy [root@mysql-slave examples]# /etc/init.d/haproxy Usage: haproxy {start|stop|restart|reload|condrestart|status|check} 简单的测试下: [root@mysql-slave examples]# /etc/init.d/haproxy status haproxy (pid 54309) 正在运行... [root@mysql-slave examples]# /etc/init.d/haproxy stop Shutting down haproxy: [确定] [root@mysql-slave examples]# /etc/init.d/haproxy status haproxy 已停 [root@mysql-slave examples]# /etc/init.d/haproxy start Starting haproxy: [确定] [root@mysql-slave examples]# /etc/init.d/haproxy reload [root@mysql-slave examples]# echo $? 0 [root@mysql-slave examples]# /etc/init.d/haproxy condrestart Shutting down haproxy: [确定] Starting haproxy: [确定] [root@mysql-slave examples]# /etc/init.d/haproxy check Configuration file is valid 到此,haproxy的安装与脚本的配置就已经完成
附件:http://down.51cto.com/data/2368319
相关文章推荐
- nginx在windows下的安装,以及编写启动关闭nginx等操作的脚本
- 在linux中安装jdk以及tomcat并shell脚本关闭启动的进程
- Windows Service的安装,卸载,启动以及调试.
- nginx的编译安装以及启动脚本编写
- Oracle 10g 安装后 5个服务的作用以及启动关闭脚本
- 安装apached源码包以及编写shell脚本使其启动更加方便,并且和启动系统服务相同
- Windows Service的安装,卸载,启动以及调试.
- Redis Centos6.5 安装以及开机启动脚本
- Redis Centos6.5 安装以及开机启动脚本
- Windows Service的安装,卸载,启动以及调试.
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
- linux APACHE2.2.10源码安装服务自动启动脚本
- jetty支持调试的单独启动脚本
- VS2005安装后,启动调试时,提示“无法启动程序 系统找不到指定文件”的解决方案
- 试图运行项目时出错:无法启动调试 没有正确安装调试器
- VS中“无法启动调试 没有正确安装调试器”错误解决方案
- VS2003 试图运行项目时出错,无法启动调试。没有正确安装调试器。请运行安装程序安装或修复调试器。
- 试图运行项目时出错,无法启动调试。没有正确安装调试器。请运行安装程序安装或修复调试器 。
- 虚拟机下登陆beso_wifi开发板以及安装图形界面gdb调试工具
- 今天安装VS.NET 打开网站错误提示:无法在WEB服务器上启动调试..