Software Environment: centos7.3,glib-2.49,lua5.1,atlas2.2.1,mysql5.7
Dependent Package Installation
****************************************************************************************
LUA installation
-------------------------------------------
Yum install-y libtermcap-devel ncurses-devel libevent-devel readline-devel
TAR-ZXVF lua-5.1.5.tar.gz
Chown-r Root.root *
CD lua-5.1.5/
Modify the install_top=/usr/local in "Makefile" in the current directory to install_top=/usr/local/lua
Mainly to avoid the possibility of conflict with the LUA library that comes with the system
Vim Makefile
install_top=/usr/local/lua
Make Linux Install
glib-2.49 Installation
----------------------------------------
Rpm-q ncurses readline readline-devel lua libffi libffi-devel libiconv xz glib2 cmake popt libnl libevent libevent-devel Openssl-devel Libtermcap-devel Ncurses-devel
Yum install-y libffi-devel Libtermcap-devel
Http://www.rpmfind.net/linux/rpm2html/search.php?query=libevent-devel
RPM-IVH libevent-devel-2.0.21-4.el7.x86_64.rpm
Libiconv Dependency Packages
Tar xvzf libiconv-1.14.tar.gz
Chown-r Root.root *
CD libiconv-1.14
CD Srclib
Sed-i-E '/gets is a security/d './stdio.in.h
Cd..
Note Do not establish a separate directory, must be installed in the/usr/local directory, or install glib will be reported/usr/bin/ld:cannot Find-liconv
./configure--prefix=/usr/local Gl_cv_header_working_stdint_h=yes
Make
Make install
PKG Installation
TAR-ZXVF pkg-config-0.29.2.tar.gz
Chown-r Root.root *
CD PKG-CONFIG-0.29.2/
./configure--enable-iconv=no--with-libiconv=gnu--with-internal-glib
Make
Make install
Ln-s/usr/local/lib/libiconv.so.2/usr/lib/libiconv.so.2
Ln-s/usr/local/lib/libiconv.so.2/usr/lib64/libiconv.so.2
Pkg-config--version
0.29.2
Pcre Installation
TAR-ZXVF pcre-8.39.tar.gz
Chown-r Root.root *
CD pcre-8.39/
./configure--enable-utf8--enable-unicode-properties
Make
Make install
Ln-s/usr/local/lib/libpcre.so.1/lib
Ln-s/usr/local/lib/libpcreposix.so.0/lib
GLib installation
Rpm-q Libffi-devel
Xz-d GLIB-2.49.7.TAR.XZ
Chown-r Root.root *
TAR-XVF Glib-2.49.7.tar
mkdir/usr/local/glib-2.49.7
CD glib-2.49.7/
./configure--prefix=/usr/local/glib-2.49.7--with-libiconv=gnu libffi_cflags= "-i/usr/local/include" LIBFFI_LIBS= " -l/usr/local/lib-lffi "
Make
Make install
Configure Pkg-config
# find/usr/-name Pkgconfig
/usr/lib64/pkgconfig
/usr/share/pkgconfig
/usr/local/lib/pkgconfig
/usr/local/lib64/pkgconfig
/usr/local/mysql/lib/pkgconfig
/usr/local/glib-2.49.7/lib/pkgconfig
# Cd/usr/local/glib-2.49.7/lib/pkgconfig
# ls
gio-2.0.pc gio-unix-2.0.pc glib-2.0.pc gmodule-2.0.pc gmodule-export-2.0.pc gmodule-no-export-2.0.pc gobject-2.0.pc gthread-2.0.pc
Vim. Bash_profile
Export pkg_config_path=/usr/local/glib-2.49.7/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib64/pkgconfig:/ Usr/local/mysql/lib/pkgconfig: $PKG _config_path
. ./.bash_profile
Test GLib pkg
Vim hello.c
#include <stdio.h>
#include <glib.h>
int main (int argc, char** argv) {
glist* List=null;
List=g_list_append (list, "Hello world!");
List=g_list_append (list, "made by Pcat");
List=g_list_append (list, "http://www.cnblogs.com/perfei/");
printf ("The first item is%s\n", G_list_first (list)->data);
return 0;
}
Compile as follows:
GCC hello.c-o Hello $ (pkg-config--cflags--libs glib-2.0)
# Ls-ltr | grep Hello
-rw-r--r--1 root root 305 November 16:47 hello.c
-rwxr-xr-x 1 root root 8648 November 17:05 Hello
#./hello
The first item is Hello world!
Atlas Database Middleware installation configuration
****************************************************************************************
Install
--------------------------------------------------------------------------------------------
Tar- ZXVF atlas-2.2.1.tar.gz
Chown-r root.root *
CD ATLAS-2.2.1/
Mkdir/usr/local/mysql-proxy
./configure-- Prefix=/usr/local/mysql-proxy \
--with-lua=/usr/local/lua \
--with-mysql=/usr/local/mysql \
GLIB_CFLAGS= "-i/usr/local/glib-2.49.7/include/glib-2.0" \
glib_libs= "-l/usr/local/glib-2.49.7/lib/-lglib-2.0" \
gmodule_cflags= "-i/usr/local/glib-2.49.7/include" \
gmodule_libs= "-l/usr/local/glib-2.49.7/lib-lgmodule-2.0" \
gthread_cflags= "-i/usr/local/glib-2.49.7/include" \
gthread_libs= "-l/usr/local/glib-2.49.7/lib- lgthread-2.0 "\
lua_cflags="-i/usr/local/lua/include "\
lua_libs="-l/usr/local/lua/lib-llua-5.1 "\
cflags= "-dhave_lua_h-o2" \
ldflags= "-l/usr/local/lib-l/usr/local/lib64-lm-ldl-lcrypto"
Atlas2.2.1 corresponds to the mysql5.6 version, the following adjustments are required when using mysql5.7
All around need to replace, see error message
Vim src/network-mysqld-packet.c
:%s/client_secure_connection/client_reserved2/g
A place to replace, see error message
Vim./plugins/admin/admin-plugin.c
:%s/client_secure_connection/client_reserved2/g
Make
Make if error processing, the following processing can be done
Ln-s/usr/local/glib-2.49.7/lib/glib-2.0/include/glibconfig.h/usr/local/glib-2.49.7/include/glib-2.0
Make install
----------------------------------------------------------------------
Libraries has been installed in:
/usr/local/mysql-proxy/lib/mysql-proxy/plugins
If you ever happen to want to link against installed libraries
In a given directory, Libdir, you must either use Libtool, and
Specify the pathname of the library, or use the '-llibdir '
Flag during linking and do at least one of the following:
-Add Libdir to the ' ld_library_path ' environment variableduring execution
-Add Libdir to the ' ld_run_path ' environment variableduring linking
-Use the '-WL,-RPATH-WL,LIBDIR ' linker flag
-Your system administrator add Libdir to '/etc/ld.so.conf '
See all operating system documentation about GKFX libraries for
More information, such as the LD (1) and ld.so (8) manual pages.
----------------------------------------------------------------------
Cd/usr/local
MV Mysql-proxy atlas-2.2.1 && ln-s atlas-2.2.1 mysql-proxy
Configuration file
--------------------------------------------------------------------------------------------
/usr/local/mysql-proxy/bin/encrypt admin_123
ywy55wecqg6tz6zxvgqr9a==
/usr/local/mysql-proxy/bin/encrypt Rootroot
mdukaaw7vcwa8s/owzlmvq==
Vim/usr/local/mysql-proxy/conf/atlas.cnf
[Mysql-proxy]
Admin-username = Atlasadmin
Admin-password = admin_123
Proxy-backend-addresses = 10.168.21.186:3306
proxy-read-only-backend-addresses = 10.168.21.186:[email Protected],10.168.21.187:[email protected],10.168.21.188: [Email protected]
PWDs = admin:ywy55wecqg6tz6zxvgqr9a==,root:mdukaaw7vcwa8s/owzlmvq==
Daemon = True
KeepAlive = True
Event-threads = 16
Log-level = Message
Log-path =/usr/local/mysql-proxy/log
Sql-log = On
Proxy-address = 0.0.0.0:3309
Admin-address = 0.0.0.0:3307
charset = UTF8
Start
--------------------------------------------------------------------------------------------
/usr/local/mysql-proxy/bin/mysql-proxyd Atlas Start
Ok:mysql-proxy of Atlas is started
# Ps-ef | grep Atlas
Root 26516 1 0 14:42? 00:00:00/usr/local/mysql-proxy/bin/mysql-proxy--defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
Root 26517 26516 0 14:42? 00:00:00/usr/local/mysql-proxy/bin/mysql-proxy--defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
Startup scripts
# Vim/etc/init.d/atlas
#!/bin/sh
#
# Mysql-proxy This script starts and stops the Mysql-proxy daemon
#
# Chkconfig:-78 30
# Processname:mysql-proxy
# Description:mysql-proxy is a proxy daemon to MySQL
# config:/usr/local/mysql-proxy/conf/mysql-proxy.cnf
# Pidfile:/usr/local/mysql-proxy/log/mysql-proxy.pid
#
Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
daemon= "/usr/local/mysql-proxy/bin/mysql-proxy"
Configfile= "/USR/LOCAL/MYSQL-PROXY/CONF/ATLAS.CNF"
Pidfile= "/usr/local/mysql-proxy/log/mysql-proxy.pid"
Lockfile= "/var/lock/subsys/mysql-proxy"
prog= ' basename $DAEMON '
Retval=0
Start () {
Echo-n $ "Starting ${prog} ..."
[-X $DAEMON] | | Exit 5
[-F $CONFIGFILE] | | Exit 6
${daemon}--defaults-file=${configfile} | | Echo-n "${prog} already running"
Retval=$?
Echo
[[$RETVAL-eq 0]] && touch $LOCKFILE
Return $RETVAL
}
Stop () {
Echo-n $ "Stopping ${prog} ..."
if [[' PS aux | grep bin/mysql-proxy | grep-v grep | wc-l '-GT 0]; Then
Kill-term ' Ps-a-oppid,pid,cmd | grep Bin/mysql-proxy | Grep-v grep | awk ' {print $} '
Fi
Retval=$?
Echo
[[$RETVAL-eq 0]] && rm-f $LOCKFILE $PIDFILE
Return $RETVAL
}
Restart () {
Stop
Sleep 1
Start
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart
Restart
;;
Condrestart)
[[-E $LOCKFILE]] && restart
;;
*)
echo "Usage: $ {Start|stop|restart|condrestart}"
Retval=1
;;
Esac
Exit $RETVAL
chmod +x/etc/init.d/atlas
chmod 0660/usr/local/mysql-proxy/conf/atlas.cnf
Service Atlas Stop
Service Atlas Start
# Service Atlas Stop
Stopping mysql-proxy ...
# Service Atlas Start
Unit Atlas.service could not being found.
Starting mysql-proxy ...
#/etc/init.d/atlas Stop
Stopping mysql-proxy ...
#/etc/init.d/atlas Start
Starting mysql-proxy ...
# Ps-ef | grep Atlas
Root 27560 1 0 14:49? 00:00:00/usr/local/mysql-proxy/bin/mysql-proxy--defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
Root 27561 27560 0 14:49? 00:00:00/usr/local/mysql-proxy/bin/mysql-proxy--defaults-file=/usr/local/mysql-proxy/conf/atlas.cnf
Root 27591 15666 0 14:49 pts/1 00:00:00 grep--color=auto Atlas
Connection
------------------------------------------------------------------
Management interface Login, which is the interface used by DBA database management
# mysql-h127.0.0.1-p3307-uatlasadmin-padmin_123
[Email protected] oms]$ mysql-h10.168.21.187-p3307-uatlasadmin-padmin_123
MySQL: [Warning] Using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.0.99-agent-admin
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> select * from Help;
+-------------------------------+---------------------------------------------------------+
| Command | Description |
+-------------------------------+---------------------------------------------------------+
| SELECT * FROM Help | Shows this Help |
| SELECT * from Backends | Lists the backends and their state |
| SET OFFLINE $backend _id | Offline backend server, $backend _id is backend_ndx ' s ID |
| SET ONLINE $backend _id | Online backend server, ... |
| ADD MASTER $backend | Example: "Add Master 127.0.0.1:3306", ... |
| ADD SLAVE $backend | Example: "Add slave 127.0.0.1:3306", ... |
| REMOVE Backend $backend _id | Example: "Remove backend 1", ... |
| SELECT * FROM Clients | Lists the Clients |
| ADD CLIENT $client | Example: "Add client 192.168.1.2", ... |
| REMOVE CLIENT $client | Example: "Remove client 192.168.1.2", ... |
| SELECT * FROM PWDs | Lists the PWDs |
| ADD PWD $pwd | Example: "Add pwd User:raw_password", ... |
| ADD Enpwd $pwd | Example: "Add Enpwd user:encrypted_password", ... |
| REMOVE PWD $pwd | Example: "Remove pwd user", ... |
| SAVE CONFIG | Save the backends to config file |
| SELECT VERSION | Display the version of Atlas |
+----------------------------+---------------------------------------------------------+
Rows in Set (0.00 sec)
Working interface, which is the interface that the application accesses
# mysql-h10.168.21.187-p3309-uadmin-padmin_123
[Email protected] oms]$ mysql-h10.168.21.187-p3309-uadmin-padmin_123
MySQL: [Warning] Using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.0.81-log MySQL Community Server (GPL)
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| SYS |
+--------------------+
4 rows in Set (0.17 sec)
Atlas mysql5.7 Installation Configuration