Skip to content

Commit

Permalink
Merge pull request #65 from percona/v1.4.3-dev
Browse files Browse the repository at this point in the history
V1.4.3 dev
  • Loading branch information
rameshvs02 authored Oct 4, 2017
2 parents 067cd06 + a6c2b06 commit aa8e380
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Options:
--cluster-hostname=host_name Hostname for connecting to the Percona XtraDB Cluster node
--cluster-app-username=user_name Application username for connecting to the Percona XtraDB Cluster node
--cluster-app-password[=password] Application password for connecting to the Percona XtraDB Cluster node
--without-cluster-app-user Configure Percona XtraDB Cluster without application user
--monitor-username=user_name Username for monitoring Percona XtraDB Cluster nodes through ProxySQL
--monitor-password[=password] Password for monitoring Percona XtraDB Cluster nodes through ProxySQL
--enable, -e Auto-configure Percona XtraDB Cluster nodes into ProxySQL
Expand Down
23 changes: 16 additions & 7 deletions proxysql-admin
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ usage () {
echo " --cluster-hostname=host_name Hostname for connecting to the Percona XtraDB Cluster node"
echo " --cluster-app-username=user_name Application username for connecting to the Percona XtraDB Cluster node"
echo " --cluster-app-password[=password] Application password for connecting to the Percona XtraDB Cluster node"
echo " --without-cluster-app-user Configure Percona XtraDB Cluster without application user"
echo " --monitor-username=user_name Username for monitoring Percona XtraDB Cluster nodes through ProxySQL"
echo " --monitor-password[=password] Password for monitoring Percona XtraDB Cluster nodes through ProxySQL"
echo " --enable, -e Auto-configure Percona XtraDB Cluster nodes into ProxySQL"
Expand All @@ -71,7 +72,7 @@ usage () {
# Check if we have a functional getopt(1)
if ! getopt --test
then
go_out="$(getopt --options=edv --longoptions=config-file:,proxysql-username:,proxysql-password::,proxysql-hostname:,proxysql-port:,cluster-username:,cluster-password::,cluster-hostname:,cluster-port:,monitor-username:,monitor-password:,cluster-app-username:,cluster-app-password:,node-check-interval:,quick-demo,mode:,write-node:,include-slaves:,enable,disable,adduser,syncusers,version,help \
go_out="$(getopt --options=edv --longoptions=config-file:,proxysql-username:,proxysql-password::,proxysql-hostname:,proxysql-port:,cluster-username:,cluster-password::,cluster-hostname:,cluster-port:,monitor-username:,monitor-password:,cluster-app-username:,cluster-app-password:,node-check-interval:,quick-demo,mode:,write-node:,include-slaves:,without-cluster-app-user,enable,disable,adduser,syncusers,version,help \
--name="$(basename "$0")" -- "$@")"
test $? -eq 0 || exit 1
eval set -- "$go_out"
Expand Down Expand Up @@ -190,6 +191,10 @@ do
CLUSTER_APP_PASSWORD="$2"
shift 2
;;
--without-cluster-app-user )
shift
WITHOUT_CLUSTER_APP_USER=1
;;
-e | --enable )
shift
ENABLE=1
Expand Down Expand Up @@ -239,7 +244,7 @@ do
ENABLE=1
;;
-v | --version )
echo "proxysql-admin version 1.3.9"
echo "proxysql-admin version 1.4.3"
exit 0
;;
--help )
Expand Down Expand Up @@ -577,8 +582,10 @@ enable_proxysql(){
esac
fi

echo -e "\nConfiguring the Percona XtraDB Cluster application user to connect through ProxySQL"
user_input_check CLUSTER_APP "Percona XtraDB Cluster application user" $WRITE_HOSTGROUP_ID
if [ "$WITHOUT_CLUSTER_APP_USER" != 1 ]; then
echo -e "\nConfiguring the Percona XtraDB Cluster application user to connect through ProxySQL"
user_input_check CLUSTER_APP "Percona XtraDB Cluster application user" $WRITE_HOSTGROUP_ID
fi

# Get the nodes in the cluster
wsrep_address=($(mysql_exec "show status like 'wsrep_incoming_addresses'" | awk '{print $2}' | sed 's|,| |g'))
Expand Down Expand Up @@ -689,8 +696,10 @@ enable_proxysql(){
check_cmd $? "Failed to add the Percona XtraDB Cluster server node $ws_ip:$ws_port. Please check username, password and other options for connecting to ProxySQL database"
fi
done
proxysql_exec "INSERT INTO mysql_query_rules (username,destination_hostgroup,active,match_digest,apply) values('$CLUSTER_APP_USERNAME',$WRITE_HOSTGROUP_ID,1,'^SELECT.*FOR UPDATE',1),('$CLUSTER_APP_USERNAME',$READ_HOSTGROUP_ID,1,'^SELECT ',1);"
check_cmd $? "Failed to add the read query rule. Please check username, password and other options for connecting to ProxySQL database"
if [ "$WITHOUT_CLUSTER_APP_USER" != 1 ]; then
proxysql_exec "INSERT INTO mysql_query_rules (username,destination_hostgroup,active,match_digest,apply) values('$CLUSTER_APP_USERNAME',$WRITE_HOSTGROUP_ID,1,'^SELECT.*FOR UPDATE',1),('$CLUSTER_APP_USERNAME',$READ_HOSTGROUP_ID,1,'^SELECT ',1);"
check_cmd $? "Failed to add the read query rule. Please check username, password and other options for connecting to ProxySQL database"
fi
proxysql_exec "LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;"
fi

Expand Down Expand Up @@ -895,7 +904,7 @@ if [ "$ENABLE" == 1 ] || [ "$DISABLE" == 1 ] || [ "$ADDUSER" == 1 ] || [ "$SYNCU
echo -e "\nProxySQL read/write configuration mode is ${BD}$MODE${NBD}"
enable_proxysql
echo -e "\nProxySQL configuration completed!\n"
PROXYSQL_CLIENT_PORT=$(proxysql_exec "SELECT * FROM runtime_global_variables WHERE variable_name='mysql-interfaces'" | awk '{print $2}' | grep -o -P '(?<=:).*(?=;)')
PROXYSQL_CLIENT_PORT=$(proxysql_exec "SELECT * FROM runtime_global_variables WHERE variable_name='mysql-interfaces'" | awk '{print $2}' | grep -o -P '(?<=:).*(?=)')
echo -e "ProxySQL has been successfully configured to use with Percona XtraDB Cluster\n"
echo -e "You can use the following login credentials to connect your application through ProxySQL\n"
if [ -z "$QUICK_DEMO" ]; then
Expand Down
12 changes: 1 addition & 11 deletions proxysql-logrotate
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@

/var/lib/proxysql/proxysql_node_monitor.log {
/var/lib/proxysql/*.log {
missingok
daily
notifempty
compress
create 0600 proxysql proxysql
rotate 5
}

/var/lib/proxysql/proxysql_galera_check.log {
missingok
daily
notifempty
compress
create 0600 proxysql proxysql
rotate 5
}

Loading

0 comments on commit aa8e380

Please sign in to comment.