Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
changed project name
Browse files Browse the repository at this point in the history
  • Loading branch information
Shlomi Noach committed Jan 20, 2016
1 parent f2fa7a2 commit bce10ee
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -2,14 +2,14 @@

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

This project adheres to the [Open Code of Conduct](http://todogroup.org/opencodeofconduct/#ccmysql/opensource@github.com). By participating, you are expected to uphold this code.
This project adheres to the [Open Code of Conduct](http://todogroup.org/opencodeofconduct/#ccql/opensource@github.com). By participating, you are expected to uphold this code.

## Submitting a pull request

0. [Fork](https://github.com/github/ccmysql/fork) and clone the repository
0. [Fork](https://github.com/github/ccql/fork) and clone the repository
0. Create a new branch: `git checkout -b my-branch-name`
0. Make your change, add tests, and make sure the tests still pass
0. Push to your fork and [submit a pull request](https://github.com/github/ccmysql/compare)
0. Push to your fork and [submit a pull request](https://github.com/github/ccql/compare)
0. Pat your self on the back and wait for your pull request to be reviewed and merged.

Here are a few things you can do that will increase the likelihood of your pull request being accepted:
Expand Down
43 changes: 25 additions & 18 deletions README.md
@@ -1,18 +1,18 @@
# ccmysql
# ccql
Multi server MySQL client

`ccmysql` is a simple utility which executes a given a set of queries on a given set of MySQL hosts
`ccql` is a simple executable utility which executes a given a set of queries on a given set of MySQL hosts
in parallel.

Quick example:
```
echo "my.srv1.com my.srv2.com my.srv3.com" | ccmysql -q "show master status; select @@server_id" -u myuser -p 123456
echo "my.srv1.com my.srv2.com my.srv3.com" | ccql -q "show master status; select @@server_id" -u myuser -p 123456
```

## Usage

```
Usage of ccmysql:
Usage of ccql:
-C string
Credentials file, expecting [client] scope, with 'user', 'password' fields. Overrides -u and -p
-H string
Expand All @@ -36,7 +36,7 @@ Usage of ccmysql:
You may provide a list of hosts in the following ways:
- via `-h my.srv1.com:3307 my.srv2.com my.srv3.com`
- via `-H /path/to/hosts.txt`
- via _stdin_, as in `echo "my.srv1.com:3307 my.srv2.com my.srv3.com" | ccmysql ...`
- via _stdin_, as in `echo "my.srv1.com:3307 my.srv2.com my.srv3.com" | ccql ...`

Hostnames can be separated by spaces, commas, newline characters or all the above.
They may indicate a port. The default port, if unspecified, is `3306`
Expand All @@ -49,7 +49,7 @@ You may provide a query or a list of queries in the following ways:
- single or mutiple queries from text file: `-Q /path/to/queries.sql`

Queries are delimited by a semicolon (`;`). The last query may, but does not have to, be terminated by a semicolon.
Quotes are respected, up to a reasonable level. It is valid to include a semicolon in a quoted text, as in `select 'single;query'`. However `ccmysql` does not employ a full blown parser, so please don't overdo it. For example, the following may not be parsed correctly: `select '\';\''`. You get it.
Quotes are respected, up to a reasonable level. It is valid to include a semicolon in a quoted text, as in `select 'single;query'`. However `ccql` does not employ a full blown parser, so please don't overdo it. For example, the following may not be parsed correctly: `select '\';\''`. You get it.

#### Credentials input

Expand Down Expand Up @@ -88,7 +88,7 @@ echo "localhost:22293, localhost:22294, localhost:22295, localhost:22296" > /tmp
```
(note that hosts can be separated by spaces, commas, newlines or any combination)

We also assume credentials are stored in `/etc/ccmysql.cnf`:
We also assume credentials are stored in `/etc/ccql.cnf`:
```
[client]
user=msandbox
Expand All @@ -97,7 +97,7 @@ password=msandbox

Warmup: select some stuff
```
cat /tmp/hosts.txt | ccmysql -C /etc/ccmysql.cnf -q "select @@global.server_id, @@global.binlog_format, @@global.version"
cat /tmp/hosts.txt | ccql -C /etc/ccql.cnf -q "select @@global.server_id, @@global.binlog_format, @@global.version"
```
A sample output is:
```
Expand All @@ -110,46 +110,53 @@ The output is tab delimited.

Show only servers that are configured as replicas:
```
cat /tmp/hosts.txt | ccmysql -C /etc/ccmysql.cnf -q "show slave status" | awk '{print $1}'
cat /tmp/hosts.txt | ccql -C /etc/ccql.cnf -q "show slave status" | awk '{print $1}'
```
Apply `slave_net_timeout` only on replicas:
```
cat /tmp/hosts.txt | ccmysql -C /etc/ccmysql.cnf -q "show slave status;" | awk '{print $1}' | ccmysql -C /etc/ccmysql.cnf -q "set global slave_net_timeout := 10"
cat /tmp/hosts.txt | ccql -C /etc/ccql.cnf -q "show slave status;" | awk '{print $1}' | ccql -C /etc/ccql.cnf -q "set global slave_net_timeout := 10"
```

Getting tired of typing `ccmysql -C /etc/ccmysql.cnf`? Let's make a shortcut:
Getting tired of typing `ccql -C /etc/ccql.cnf`? Let's make a shortcut:
```
alias cccmysql="ccmysql -C /etc/ccmysql.cnf"
alias cccql="ccql -C /etc/ccql.cnf"
```

Which servers are acting as masters to someone?
```
cat /tmp/hosts.txt | cccmysql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}'
cat /tmp/hosts.txt | cccql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}'
```

Of those, which are also replicating? i.e. act as intermediate masters?
```
cat /tmp/hosts.txt | cccmysql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}' | sort | uniq | cccmysql -q "show slave status" | awk '{print $1}'
cat /tmp/hosts.txt | cccql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}' | sort | uniq | cccql -q "show slave status" | awk '{print $1}'
```

Set `sync_binlog=0` on all intermediate masters:
```
cat /tmp/hosts.txt | cccmysql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}' | sort | uniq | cccmysql -q "show slave status" | awk '{print $1}' | cccmysql -q "set global sync_binlog=0"
cat /tmp/hosts.txt | cccql -q "show slave status;" | awk -F $'\t' '{print $3 ":" $5}' | sort | uniq | cccql -q "show slave status" | awk '{print $1}' | cccql -q "set global sync_binlog=0"
```

## LICENSE

See [LICENSE](LICENSE). _ccmysql_ imports and includes 3rd party libraries, which have their own license. These are found under [vendor](vendor).
See [LICENSE](LICENSE). _ccql_ imports and includes 3rd party libraries, which have their own license. These are found under [vendor](vendor).

## Binaries, downloads

Find precompiled binaries for linux (amd64) and Darwin (aka OS/X, amd64) under [Releases](https://github.com/github/ccmysql/releases)
Find precompiled binaries for linux (amd64) and Darwin (aka OS/X, amd64) under [Releases](https://github.com/github/ccql/releases)

## Build

_ccmysql_ is built with Go 1.5, and uses the [Go 1.5 vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories), which requires setting `GO15VENDOREXPERIMENT=1`.
_ccql_ is built with Go 1.5, and uses the [Go 1.5 vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories), which requires setting `GO15VENDOREXPERIMENT=1`.
Please see the [build file](build.sh)

## What's in a name?

_ccql_ is an abbreviation for _Concurrent Client for MySQL_ or something. We had a few iterations with the name
but had to replace one and we were all like _yeah_ and _whoa_ and fun times. Eventually we came by this name
which upset Tom being "too much on the left-side of the keyboard when typing" and that settled the matter.
Tom uses `alias a='ccql'`.

## Notes

Credits to Domas Mituzas for creating [pmysql](http://dom.as/2010/08/12/pmysql-multi-server-mysql-client/).
Expand Down
12 changes: 6 additions & 6 deletions build.sh
@@ -1,17 +1,17 @@
#!/bin/bash

buildpath=/tmp/
target=ccmysql
target=ccql
timestamp=$(date "+%Y%m%d%H%M%S")
gobuild="go build -o $buildpath/$target go/cmd/ccmysql/main.go"
gobuild="go build -o $buildpath/$target go/cmd/ccql/main.go"

echo "Building linux binary"
echo "GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 $gobuild" | bash
(cd $buildpath && tar cfz ./ccmysql-binary-linux-${timestamp}.tar.gz $target)
(cd $buildpath && tar cfz ./ccql-binary-linux-${timestamp}.tar.gz $target)

echo "Building OS/X binary"
echo "GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild" | bash
(cd $buildpath && tar cfz ./ccmysql-binary-osx-${timestamp}.tar.gz $target)
(cd $buildpath && tar cfz ./ccql-binary-osx-${timestamp}.tar.gz $target)

echo "Binaries are:"
ls -1 $buildpath/ccmysql-binary*${timestamp}.tar.gz
echo "Binaries found in:"
ls -1 $buildpath/ccql-binary*${timestamp}.tar.gz
6 changes: 3 additions & 3 deletions go/cmd/ccmysql/main.go → go/cmd/ccql/main.go
Expand Up @@ -3,9 +3,9 @@ package main
import (
"flag"

"github.com/github/ccmysql/go/logic"
"github.com/github/ccmysql/go/sql"
"github.com/github/ccmysql/go/text"
"github.com/github/ccql/go/logic"
"github.com/github/ccql/go/sql"
"github.com/github/ccql/go/text"

"github.com/outbrain/golib/log"
"gopkg.in/gcfg.v1"
Expand Down

0 comments on commit bce10ee

Please sign in to comment.