From 6882107fe34b1cbba22f9f14c8ab45884ab93cf4 Mon Sep 17 00:00:00 2001 From: Zhang Huangbin Date: Sun, 27 Nov 2016 23:56:51 +0800 Subject: [PATCH 1/9] Don't exit with non-zero code if proxysql was stopped If proxysql is stopped, function `stop()` should return exit code `0` instead of a non-zero code. This also fixes `restart` action cannot start (a already stopped) proxysql service. --- etc/init.d/proxysql | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/init.d/proxysql b/etc/init.d/proxysql index 9c8313b29..99af580bd 100755 --- a/etc/init.d/proxysql +++ b/etc/init.d/proxysql @@ -92,7 +92,6 @@ stop() { if [ "X$pid" = "X" ] then echo "ProxySQL was not running." - exit 1 else # Note: we send a kill to all the processes, not just to the child for i in `pgrep proxysql` ; do From fa09d1f86413d234253e320254335ce79004c673 Mon Sep 17 00:00:00 2001 From: Oloruntobi Ogunbiyi Date: Tue, 3 Jan 2017 12:11:09 -0500 Subject: [PATCH 2/9] Update minor issues with Admin interface and Query cache docs --- doc/admin_tables.md | 14 +++++++------- doc/query_cache.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/admin_tables.md b/doc/admin_tables.md index cc4ac41d6..36c63cee3 100644 --- a/doc/admin_tables.md +++ b/doc/admin_tables.md @@ -4,7 +4,7 @@ Admin tables ProxySQL admin interface is an interface that uses the MySQL protocol, making it very easy to be configured by any client able to send commands through such interface. ProxySQL parses the queries sent through this interface for any command specific to ProxySQL, and if appropiate sends them to the embedded SQLite3 engine to run the queries. -Please note that SQL syntax used by SQLite3 and MySQL differs, therefore not all commands working on MySQL will work on SQLite3 . +Please note that SQL syntax used by SQLite3 and MySQL differs, therefore not all commands that work on MySQL will work on SQLite3 . For example, although the USE command is accepted by the admin interface, it doesn't change the default schema as this feature is not available in SQLite3. Connecting to the ProxySQL admin interface, we see that there are a few databases available. @@ -126,11 +126,11 @@ CREATE TABLE mysql_users ( The fields have the following semantics: * `username`, `password` - credentials for connecting to the mysqld or ProxySQL instance * `active` - the users with active = 0 will be tracked in the database, but will be never loaded in the in-memory data structures -* `default_hostgroup` - if there is no matching rule for the queries send by this users, the traffic is generates is sent to the specified hostgroup +* `default_hostgroup` - if there is no matching rule for the queries sent by the users, the traffic it generates is sent to the specified hostgroup * `default_schema` - the schema to which the connection should change by default * `schema_locked` - not supported yet (TODO: check) * `transaction_persistent` - if this is set for the user with which the MySQL client is connecting to ProxySQL (thus a "frontend" user - see below), transactions started within a hostgroup will remain within that hostgroup regardless of any other rules -* `fast_forward` - if set it bypass the query processing layer (rewriting, caching) and pass through the query directly as is to the backend server. +* `fast_forward` - if set, it bypasses the query processing layer (rewriting, caching) and passes the query directly to the backend server. * `frontend` - if set to 1, this (username, password) pair is used for authenticating to the ProxySQL instance * `backend` - if set to 1, this (username, password) pair is used for authenticating to the mysqld servers against any hostgroup @@ -338,15 +338,15 @@ The fields have the following semantics: * `user` - the user with which the MySQL client connected to ProxySQL in order to execute this query * `db` - the schema currently selected * `cli_host`, `cli_port` - the (host, port) pair of the TCP connection between the MySQL client and ProxySQL -* `hostgroup` - the currenct hostgroup. If a query being processed, this is the hostgroup towards which the query was or will be routed, or the default hostgroup. The routing is done by default in terms of the default destination hostgroup for the username with which the MySQL client connected to ProxySQL (based on `mysql_users` table, but it can be modified on a per-query basis by using the query rules in `mysql_query_rules` -* `l_srv_host`, `l_srv_port` - the local (host, part) pair of the TCP connection between ProxySQL and the backend MySQL server from the current hostgroup +* `hostgroup` - the current hostgroup. If a query being processed, this is the hostgroup towards which the query was or will be routed, or the default hostgroup. The routing is done by default in terms of the default destination hostgroup for the username with which the MySQL client connected to ProxySQL (based on `mysql_users` table, but it can be modified on a per-query basis by using the query rules in `mysql_query_rules` +* `l_srv_host`, `l_srv_port` - the local (host, port) pair of the TCP connection between ProxySQL and the backend MySQL server from the current hostgroup * `srv_host`, `srv_port` - the (host, port) pair on which the backend MySQL server is listening for TCP connections * `command` - the type of MySQL query being executed (the MySQL command verb) * `time_ms` - the time in millisecond for which the query has been in the specified command state so far * `info` - the actual query being executed -Please note that this is just a snapshot in time of the actual MySQL queries being ran. There is no guarantee that the same queries will be running a fraction of a second later. -Here is how the results look like: +Please note that this is just a snapshot in time of the actual MySQL queries being run. There is no guarantee that the same queries will be running a fraction of a second later. +Here is what the results look like: ```sql mysql> select * from stats_mysql_processlist; diff --git a/doc/query_cache.md b/doc/query_cache.md index b5cdd135e..c700f5db1 100644 --- a/doc/query_cache.md +++ b/doc/query_cache.md @@ -16,7 +16,7 @@ If the application will re-executed the same query, the resultset will be return It is a quite common scenarios to identify database load caused by not-optimal SELECT statements that generate a resultset that should be cached for few seconds. To implement a code change can be a long process (developers should write new code, build it, testing in staging, then deploy on production), and this is often not a suitable option during an emergency. -As the configuration of the database proxy layer (ProxySQL in this case) falls under the responsibility of DBAs, to enable caching DBAs doesn't require that developers to make changes to the application. +As the configuration of the database proxy layer (ProxySQL in this case) falls under the responsibility of DBAs, to enable caching DBAs won't require developers to make changes to the application. Therefore this is a feature that empowers the DBAs. From 6b3291b53e237460eef62a6ee6033d2e8a4dea46 Mon Sep 17 00:00:00 2001 From: Bogdan Radulescu Date: Wed, 4 Jan 2017 12:41:55 +0200 Subject: [PATCH 3/9] Improvements to the systemd support. We now run as the MySQL user and fix permissions before running. --- Makefile | 6 +++--- systemd/proxysql.service | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6fd636326..abb344090 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ DEBUG=${ALL_DEBUG} CURVER=1.3.0g MAKEOPT="-j 8" DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) -ifeq ($(wildcard /usr/lib/systemd/systemd), /usr/lib/systemd/systemd) +ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system) SYSTEMD=1 else SYSTEMD=0 @@ -395,7 +395,7 @@ cleanall: rm binaries/*rpm || true install: src/proxysql - install -m 0755 src/proxysql /usr/local/bin + install -m 0755 src/proxysql /usr/bin install -m 0600 etc/proxysql.cnf /etc if [ ! -d /var/lib/proxysql ]; then mkdir /var/lib/proxysql ; fi ifeq ($(SYSTEMD), 1) @@ -418,7 +418,7 @@ endif uninstall: rm /etc/proxysql.cnf - rm /usr/local/bin/proxysql + rm /usr/bin/proxysql rmdir /var/lib/proxysql 2>/dev/null || true ifeq ($(SYSTEMD), 1) systemctl stop proxysql.service diff --git a/systemd/proxysql.service b/systemd/proxysql.service index 7ea7df229..1dedf8541 100644 --- a/systemd/proxysql.service +++ b/systemd/proxysql.service @@ -3,10 +3,16 @@ Description=High Performance Advanced Proxy for MySQL After=network.target [Service] +Type=simple +User=mysql +Group=mysql +PermissionsStartOnly=true LimitNOFILE=102400 LimitCORE=1073741824 -ExecStart=/usr/local/bin/proxysql -f +ExecStartPre=/bin/mkdir -p /var/lib/proxysql +ExecStartPre=/bin/chown mysql:mysql -R /var/lib/proxysql /etc/proxysql.cnf +ExecStart=/usr/bin/proxysql -f Restart=always [Install] -WantedBy=default.target +WantedBy=multi-user.target From 3446a172d4019f28ea61605bb3f55f6996650c83 Mon Sep 17 00:00:00 2001 From: Lee Clemens Date: Thu, 5 Jan 2017 12:32:28 -0500 Subject: [PATCH 4/9] Update return codes for LSB compliance start when already running and stop when already stopped should return successful return codes (0) --- etc/init.d/proxysql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/init.d/proxysql b/etc/init.d/proxysql index 9c8313b29..585488a2d 100755 --- a/etc/init.d/proxysql +++ b/etc/init.d/proxysql @@ -82,7 +82,7 @@ start() { fi else echo "ProxySQL is already running." - exit 1 + exit 0 fi } @@ -92,7 +92,7 @@ stop() { if [ "X$pid" = "X" ] then echo "ProxySQL was not running." - exit 1 + exit 0 else # Note: we send a kill to all the processes, not just to the child for i in `pgrep proxysql` ; do From 45619476a01ba621331a62aa6966e3e619fdbd47 Mon Sep 17 00:00:00 2001 From: Domenico Lupinetti Date: Fri, 13 Jan 2017 17:32:46 +0100 Subject: [PATCH 5/9] Updated documentation Column time_start does not exists anymore. Changed to: ```time_start_us``` --- doc/configuration_howto.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/configuration_howto.md b/doc/configuration_howto.md index c7197ba6b..b1d8deb91 100644 --- a/doc/configuration_howto.md +++ b/doc/configuration_howto.md @@ -148,9 +148,9 @@ Not all the tables in monitor are currently used. For now we can check the relevant tables with the follow queries: ``` sql -Admin> SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start DESC LIMIT 10; +Admin> SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 10; +-----------+-------+------------------+----------------------+---------------+ -| hostname | port | time_start | connect_success_time | connect_error | +| hostname | port | time_start_us | connect_success_time | connect_error | +-----------+-------+------------------+----------------------+---------------+ | 127.0.0.1 | 21891 | 1456968814253432 | 562 | NULL | | 127.0.0.1 | 21892 | 1456968814253432 | 309 | NULL | @@ -165,9 +165,9 @@ Admin> SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start DESC L +-----------+-------+------------------+----------------------+---------------+ 10 rows in set (0.00 sec) -Admin> SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start DESC LIMIT 10; +Admin> SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start_us DESC LIMIT 10; +-----------+-------+------------------+-------------------+------------+ -| hostname | port | time_start | ping_success_time | ping_error | +| hostname | port | time_start_us | ping_success_time | ping_error | +-----------+-------+------------------+-------------------+------------+ | 127.0.0.1 | 21891 | 1456968828686787 | 124 | NULL | | 127.0.0.1 | 21892 | 1456968828686787 | 62 | NULL | @@ -209,7 +209,7 @@ Admin> SELECT * FROM mysql_servers; Let's check another table in the monitor schema , `monitor.mysql_server_read_only_log`: ``` sql -Admin> SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start DESC LIMIT 10; +Admin> SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start_us DESC LIMIT 10; Empty set (0.00 sec) ``` @@ -267,8 +267,8 @@ Admin> LOAD MYSQL SERVERS TO RUNTIME; Wait few seconds, and check again the status: ``` sql -Admin> SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start DESC LIMIT 10; +-----------+-------+------------------+--------------+-----------+-------+ -| hostname | port | time_start | success_time | read_only | error | +Admin> SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start_us DESC LIMIT 10; +-----------+-------+------------------+--------------+-----------+-------+ +| hostname | port | time_start_us | success_time | read_only | error | +-----------+-------+------------------+--------------+-----------+-------+ | 127.0.0.1 | 21891 | 1456969634783579 | 762 | 0 | NULL | | 127.0.0.1 | 21892 | 1456969634783579 | 378 | 1 | NULL | From c68bca997ea5d6e5721fad79ccbb0ce7a30b99c2 Mon Sep 17 00:00:00 2001 From: Christopher Troup Date: Wed, 8 Feb 2017 17:51:44 -0500 Subject: [PATCH 6/9] Add build/support for CentOS 5 CentOS 5 doesn't have support for epoll_create1(), so I've defined a macro to fall back on epoll_create() in that case. Note that the `1` argument to epoll_create() is actually ignored, and is only there to conform to the requirement that it be larger than 0. --- Makefile | 49 ++++++++++++- .../proxysql/centos5-build/proxysql.spec | 73 +++++++++++++++++++ .../images/proxysql/centos5-build/rpmmacros | 2 + lib/MySQL_Thread.cpp | 8 +- 4 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 docker/images/proxysql/centos5-build/proxysql.spec create mode 100644 docker/images/proxysql/centos5-build/rpmmacros diff --git a/Makefile b/Makefile index abb344090..ae263bffa 100644 --- a/Makefile +++ b/Makefile @@ -54,9 +54,14 @@ clean: cd lib && ${MAKE} clean cd src && ${MAKE} clean -packages: centos6.7 centos7 centos6.7-dbg centos7-dbg ubuntu12 ubuntu14 debian7 debian8 ubuntu12-dbg ubuntu14-dbg debian7-dbg debian8-dbg ubuntu16 ubuntu16-dbg fedora24 fedora24-dbg +packages: centos6.7 centos7 centos6.7-dbg centos7-dbg centos5 centos5-dbg ubuntu12 ubuntu14 debian7 debian8 ubuntu12-dbg ubuntu14-dbg debian7-dbg debian8-dbg ubuntu16 ubuntu16-dbg fedora24 fedora24-dbg .PHONY: packages +centos5: binaries/proxysql-${CURVER}-1-centos5.x86_64.rpm +.PHONY: centos5 + +centos5-dbg: binaries/proxysql-${CURVER}-1-centos5.x86_64.rpm +.PHONY: centos5-dbg centos6.7: binaries/proxysql-${CURVER}-1-centos67.x86_64.rpm .PHONY: centos6.7 @@ -107,6 +112,48 @@ debian8-dbg: binaries/proxysql_${CURVER}-dbg-debian8_amd64.deb .PHONY: debian8-dbg +binaries/proxysql-${CURVER}-1-centos5.x86_64.rpm: + docker stop centos5_build || true + docker rm centos5_build || true + docker create --name centos5_build renecannao/proxysql:build-centos5 bash -c "while : ; do sleep 10 ; done" + docker start centos5_build + docker exec centos5_build bash -c "cd /opt; git clone -b v${CURVER} https://github.com/sysown/proxysql.git proxysql" + docker exec centos5_build bash -c "cd /opt/proxysql; ${MAKE} clean && ${MAKE} ${MAKEOPT} build_deps && ${MAKE} ${MAKEOPT}" + docker exec -it centos5_build bash -c "cd /opt/proxysql ; mkdir -p proxysql/usr/bin; mkdir -p proxysql/etc; cp src/proxysql proxysql/usr/bin/; cp -a etc proxysql ; mkdir -p proxysql/usr/share/proxysql/tools ; cp -a tools/proxysql_galera_checker.sh tools/proxysql_galera_writer.pl proxysql/usr/share/proxysql/tools ; mv proxysql proxysql-${CURVER} ; tar czvf proxysql-${CURVER}.tar.gz proxysql-${CURVER}" + docker exec -it centos5_build bash -c "mkdir -p /root/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}" + docker cp docker/images/proxysql/centos5-build/rpmmacros centos5_build:/root/.rpmmacros + docker cp docker/images/proxysql/centos5-build/proxysql.spec centos5_build:/root/rpmbuild/SPECS/proxysql.spec + sleep 2 + docker exec -it centos5_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" + docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + sleep 2 + docker exec -it centos5_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" + sleep 2 + docker cp centos5_build:/root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm ./binaries/proxysql-${CURVER}-1-centos5.x86_64.rpm + docker stop centos5_build + docker rm centos5_build + +binaries/proxysql-${CURVER}-1-dbg-centos5.x86_64.rpm: + docker stop centos5_build || true + docker rm centos5_build || true + docker create --name centos5_build renecannao/proxysql:build-centos5 bash -c "while : ; do sleep 10 ; done" + docker start centos5_build + docker exec centos5_build bash -c "cd /opt; git clone -b v${CURVER} https://github.com/sysown/proxysql.git proxysql" + docker exec centos5_build bash -c "cd /opt/proxysql; ${MAKE} clean && ${MAKE} ${MAKEOPT} build_deps && ${MAKE} ${MAKEOPT} debug" + docker exec -it centos5_build bash -c "cd /opt/proxysql ; mkdir -p proxysql/usr/bin; mkdir -p proxysql/etc; cp src/proxysql proxysql/usr/bin/; cp -a etc proxysql ; mkdir -p proxysql/usr/share/proxysql/tools ; cp -a tools/proxysql_galera_checker.sh tools/proxysql_galera_writer.pl proxysql/usr/share/proxysql/tools ; mv proxysql proxysql-${CURVER} ; tar czvf proxysql-${CURVER}.tar.gz proxysql-${CURVER}" + docker exec -it centos5_build bash -c "mkdir -p /root/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}" + docker cp docker/images/proxysql/centos5-build/rpmmacros centos5_build:/root/.rpmmacros + docker cp docker/images/proxysql/centos5-build/proxysql.spec centos5_build:/root/rpmbuild/SPECS/proxysql.spec + sleep 2 + docker exec -it centos5_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" + docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + sleep 2 + docker exec -it centos5_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" + sleep 2 + docker cp centos5_build:/root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm ./binaries/proxysql-${CURVER}-1-dbg-centos5.x86_64.rpm + docker stop centos5_build + docker rm centos5_build + binaries/proxysql-${CURVER}-1-centos67.x86_64.rpm: docker stop centos67_build || true docker rm centos67_build || true diff --git a/docker/images/proxysql/centos5-build/proxysql.spec b/docker/images/proxysql/centos5-build/proxysql.spec new file mode 100644 index 000000000..0ca966d7e --- /dev/null +++ b/docker/images/proxysql/centos5-build/proxysql.spec @@ -0,0 +1,73 @@ +# Don't try fancy stuff like debuginfo, which is useless on binary-only +# packages. Don't strip binary too +# Be sure buildpolicy set to do nothing +%define __spec_install_post %{nil} +%define debug_package %{nil} +%define __os_install_post %{_dbpath}/brp-compress + +Summary: A high-performance MySQL proxy +Name: proxysql +Version: 1.3.0h +Release: 1 +License: GPL+ +Group: Development/Tools +SOURCE0 : %{name}-%{version}.tar.gz +URL: http://www.proxysql.com/ + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root + +%description +%{summary} + +%prep +%setup -q + +%build +# Empty section. + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot} + +# in builddir +cp -a * %{buildroot} + +%clean +rm -rf %{buildroot} + +%post +mkdir /var/run/%{name} +chkconfig --add %{name} + +%postun +rm -rf /var/run/%{name} +chkconfig --del %{name} + +%files +%defattr(-,root,root,-) +%config(noreplace) %{_sysconfdir}/%{name}.cnf +%{_bindir}/* +%{_sysconfdir}/init.d/%{name} +/usr/share/proxysql/tools/proxysql_galera_checker.sh +/usr/share/proxysql/tools/proxysql_galera_writer.pl + +%changelog +* Wed Oct 19 2016 Rene Cannao 1.3.0 +- experimental support for Prepared Statements +- enhanced scalability +* Thu Sep 29 2016 Rene Cannao 1.2.4 +- Forth stable release of 1.2 +* Tue Sep 20 2016 Rene Cannao 1.2.3 +- Third stable release of 1.2 +* Fri Sep 2 2016 Rene Cannao 1.2.2 +- Second stable release of 1.2 +* Tue Aug 2 2016 Rene Cannao 1.2.1 +- First stable release of 1.2 +* Mon Mar 14 2016 Rene Cannao 1.2.0 +- First testing release of 1.2 +* Sat Mar 11 2016 Rene Cannao 1.1.2 +- Upgraded to release 1.1.2 +* Sat Oct 31 2015 Rene Cannao 1.0.1 +- Compiles 1.0.1 +* Wed Sep 9 2015 Andrei Ismail 0.2 +- Added support for automatic packaging on Ubuntu 14.04 and CentOS 7. diff --git a/docker/images/proxysql/centos5-build/rpmmacros b/docker/images/proxysql/centos5-build/rpmmacros new file mode 100644 index 000000000..a1d0f32f0 --- /dev/null +++ b/docker/images/proxysql/centos5-build/rpmmacros @@ -0,0 +1,2 @@ +%_topdir %(echo $HOME)/rpmbuild +%_tmppath %{_topdir}/tmp \ No newline at end of file diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 5c5c64fc3..e60fce4f8 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -8,6 +8,12 @@ MySQL_Session *sess_stopat; #endif +#ifdef epoll_create1 + #define EPOLL_CREATE epoll_create1(0) +#else + #define EPOLL_CREATE epoll_create(1) +#endif + #define PROXYSQL_LISTEN_LEN 1024 #define MIN_THREADS_FOR_MAINTENANCE 8 @@ -1930,7 +1936,7 @@ void MySQL_Thread::run() { if (idle_maintenance_thread) { // we check if it is the first time we are called if (efd==-1) { - efd = epoll_create1(0); + efd = EPOLL_CREATE; int fd=pipefd[0]; struct epoll_event event; memset(&event,0,sizeof(event)); // let's make valgrind happy From 794057684db14a6da26c895e6340abd3555c7068 Mon Sep 17 00:00:00 2001 From: Christopher Troup Date: Fri, 10 Feb 2017 19:57:48 -0500 Subject: [PATCH 7/9] Add chkconfig support Installing the RPM via `rpm -i proxysql-.rpm` generates an error on systems that have chkconfig -- it requires special syntax at the top of the init.d script. --- etc/init.d/proxysql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/init.d/proxysql b/etc/init.d/proxysql index 585488a2d..6d6b90bfc 100755 --- a/etc/init.d/proxysql +++ b/etc/init.d/proxysql @@ -1,5 +1,9 @@ #!/bin/bash # +# chkconfig: 345 99 01 +# description: High Performance and Advanced Proxy for MySQL and forks. \ +# It provides advanced features like connection pool, query routing and rewrite, \ +# firewalling, throttling, real time analysis, error-free failover ### BEGIN INIT INFO # Provides: proxysql # Required-Start: $local_fs From 59ccce30cecdba20b4c6b049bbfcc4332c77bbe2 Mon Sep 17 00:00:00 2001 From: Christopher Troup Date: Fri, 10 Feb 2017 20:17:15 -0500 Subject: [PATCH 8/9] Define version outside the `spec` file for RPM builds Instead of hardcoding the version number in the RPM spec file, we can pass the version in as part of the `rpmbuild` process, using the same version as is defined in the Makefile. --- Makefile | 16 ++++++++-------- .../images/proxysql/centos5-build/proxysql.spec | 2 +- .../images/proxysql/centos67-build/proxysql.spec | 2 +- .../images/proxysql/centos7-build/proxysql.spec | 2 +- .../images/proxysql/fedora24-build/proxysql.spec | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index ae263bffa..b03f87269 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ binaries/proxysql-${CURVER}-1-centos5.x86_64.rpm: docker cp docker/images/proxysql/centos5-build/proxysql.spec centos5_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos5_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos5_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -146,7 +146,7 @@ binaries/proxysql-${CURVER}-1-dbg-centos5.x86_64.rpm: docker cp docker/images/proxysql/centos5-build/proxysql.spec centos5_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos5_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos5_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos5_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -167,7 +167,7 @@ binaries/proxysql-${CURVER}-1-centos67.x86_64.rpm: docker cp docker/images/proxysql/centos67-build/proxysql.spec centos67_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos67_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos67_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos67_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos67_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -188,7 +188,7 @@ binaries/proxysql-${CURVER}-1-dbg-centos67.x86_64.rpm: docker cp docker/images/proxysql/centos67-build/proxysql.spec centos67_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos67_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos67_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos67_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos67_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -209,7 +209,7 @@ binaries/proxysql-${CURVER}-1-centos7.x86_64.rpm: docker cp docker/images/proxysql/centos7-build/proxysql.spec centos7_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos7_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos7_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos7_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos7_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -230,7 +230,7 @@ binaries/proxysql-${CURVER}-1-dbg-centos7.x86_64.rpm: docker cp docker/images/proxysql/centos7-build/proxysql.spec centos7_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it centos7_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it centos7_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it centos7_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it centos7_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -252,7 +252,7 @@ binaries/proxysql-${CURVER}-1-fedora24.x86_64.rpm: docker cp docker/images/proxysql/fedora24-build/proxysql.spec fedora24_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it fedora24_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it fedora24_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it fedora24_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it fedora24_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 @@ -273,7 +273,7 @@ binaries/proxysql-${CURVER}-1-dbg-fedora24.x86_64.rpm: docker cp docker/images/proxysql/fedora24-build/proxysql.spec fedora24_build:/root/rpmbuild/SPECS/proxysql.spec sleep 2 docker exec -it fedora24_build bash -c "cp /opt/proxysql/proxysql-${CURVER}.tar.gz /root/rpmbuild/SOURCES" - docker exec -it fedora24_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec" + docker exec -it fedora24_build bash -c "cd /root/rpmbuild; rpmbuild -ba SPECS/proxysql.spec --define \"version ${CURVER}\"" sleep 2 docker exec -it fedora24_build bash -c "cp /root/rpmbuild/RPMS/x86_64/proxysql-${CURVER}-1.x86_64.rpm /root/rpm" sleep 2 diff --git a/docker/images/proxysql/centos5-build/proxysql.spec b/docker/images/proxysql/centos5-build/proxysql.spec index 0ca966d7e..1770cd57b 100644 --- a/docker/images/proxysql/centos5-build/proxysql.spec +++ b/docker/images/proxysql/centos5-build/proxysql.spec @@ -7,7 +7,7 @@ Summary: A high-performance MySQL proxy Name: proxysql -Version: 1.3.0h +Version: %{version} Release: 1 License: GPL+ Group: Development/Tools diff --git a/docker/images/proxysql/centos67-build/proxysql.spec b/docker/images/proxysql/centos67-build/proxysql.spec index 0ca966d7e..1770cd57b 100644 --- a/docker/images/proxysql/centos67-build/proxysql.spec +++ b/docker/images/proxysql/centos67-build/proxysql.spec @@ -7,7 +7,7 @@ Summary: A high-performance MySQL proxy Name: proxysql -Version: 1.3.0h +Version: %{version} Release: 1 License: GPL+ Group: Development/Tools diff --git a/docker/images/proxysql/centos7-build/proxysql.spec b/docker/images/proxysql/centos7-build/proxysql.spec index 0ca966d7e..1770cd57b 100644 --- a/docker/images/proxysql/centos7-build/proxysql.spec +++ b/docker/images/proxysql/centos7-build/proxysql.spec @@ -7,7 +7,7 @@ Summary: A high-performance MySQL proxy Name: proxysql -Version: 1.3.0h +Version: %{version} Release: 1 License: GPL+ Group: Development/Tools diff --git a/docker/images/proxysql/fedora24-build/proxysql.spec b/docker/images/proxysql/fedora24-build/proxysql.spec index 0ca966d7e..1770cd57b 100644 --- a/docker/images/proxysql/fedora24-build/proxysql.spec +++ b/docker/images/proxysql/fedora24-build/proxysql.spec @@ -7,7 +7,7 @@ Summary: A high-performance MySQL proxy Name: proxysql -Version: 1.3.0h +Version: %{version} Release: 1 License: GPL+ Group: Development/Tools From 83ca1944f067cff8f12a269b8f29369a0a820faa Mon Sep 17 00:00:00 2001 From: Christopher Troup Date: Sat, 11 Feb 2017 13:20:28 -0500 Subject: [PATCH 9/9] Post Uninstall hooks for fedora based OS's Previously the `postun` hook would try and remove ProxySQL from chkconfig, but that would fail because the package was already uninstalled. Instead, we can do this in the `preun` hook, and ensure that ProxySQL is properly shutdown before doing cleanup tasks. --- docker/images/proxysql/centos5-build/proxysql.spec | 5 ++++- docker/images/proxysql/centos67-build/proxysql.spec | 5 ++++- docker/images/proxysql/centos7-build/proxysql.spec | 5 ++++- docker/images/proxysql/fedora24-build/proxysql.spec | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docker/images/proxysql/centos5-build/proxysql.spec b/docker/images/proxysql/centos5-build/proxysql.spec index 1770cd57b..16ff2cff5 100644 --- a/docker/images/proxysql/centos5-build/proxysql.spec +++ b/docker/images/proxysql/centos5-build/proxysql.spec @@ -39,9 +39,12 @@ rm -rf %{buildroot} mkdir /var/run/%{name} chkconfig --add %{name} +%preun +/etc/init.d/%{name} stop +chkconfig --del %{name} + %postun rm -rf /var/run/%{name} -chkconfig --del %{name} %files %defattr(-,root,root,-) diff --git a/docker/images/proxysql/centos67-build/proxysql.spec b/docker/images/proxysql/centos67-build/proxysql.spec index 1770cd57b..16ff2cff5 100644 --- a/docker/images/proxysql/centos67-build/proxysql.spec +++ b/docker/images/proxysql/centos67-build/proxysql.spec @@ -39,9 +39,12 @@ rm -rf %{buildroot} mkdir /var/run/%{name} chkconfig --add %{name} +%preun +/etc/init.d/%{name} stop +chkconfig --del %{name} + %postun rm -rf /var/run/%{name} -chkconfig --del %{name} %files %defattr(-,root,root,-) diff --git a/docker/images/proxysql/centos7-build/proxysql.spec b/docker/images/proxysql/centos7-build/proxysql.spec index 1770cd57b..16ff2cff5 100644 --- a/docker/images/proxysql/centos7-build/proxysql.spec +++ b/docker/images/proxysql/centos7-build/proxysql.spec @@ -39,9 +39,12 @@ rm -rf %{buildroot} mkdir /var/run/%{name} chkconfig --add %{name} +%preun +/etc/init.d/%{name} stop +chkconfig --del %{name} + %postun rm -rf /var/run/%{name} -chkconfig --del %{name} %files %defattr(-,root,root,-) diff --git a/docker/images/proxysql/fedora24-build/proxysql.spec b/docker/images/proxysql/fedora24-build/proxysql.spec index 1770cd57b..16ff2cff5 100644 --- a/docker/images/proxysql/fedora24-build/proxysql.spec +++ b/docker/images/proxysql/fedora24-build/proxysql.spec @@ -39,9 +39,12 @@ rm -rf %{buildroot} mkdir /var/run/%{name} chkconfig --add %{name} +%preun +/etc/init.d/%{name} stop +chkconfig --del %{name} + %postun rm -rf /var/run/%{name} -chkconfig --del %{name} %files %defattr(-,root,root,-)