Debian Codegraph @

debian/examples/README

raw
1
2 Using cloudsql-proxy in other packages
3 ----- -------------- -- ----- --------
4
5 By default, cloudsql-proxy does not start a daemon process, since
6 there are many configuration options that would depend on the
7 processes running on a machine. Indeed, it is not certain how many
8 proxies are needed on a particular machine, and how to map them to
9 local ports. It is left to dependent packages to set up the daemon
10 process.
11
12 You can use one local proxy client to connect to multiple Cloud SQL
13 instances. The way you do this depends on whether you are using Unix
14 sockets or TCP.
15
16 Unix sockets
17 ---- -------
18
19 To connect the proxy to multiple instances, you provide the instance
20 connection names with the -instances parameter, in a comma-separated
21 list (no spaces). The proxy connects to each instance when it
22 starts. This is recommended if the credentials to present to each
23 backend database is the same for all connections.
24
25 You connect to each instance using its socket, in the specified
26 directory.
27
28 For example:
29
30 ./cloud_sql_proxy -dir=/cloudsql \
31 -instances=myProject:us-central1:myInstance,myProject:us-central1:myInstance2 &
32 mysql -u myUser -S /cloudsql/myProject:us-central1:myInstance2
33
34 TCP
35 ---
36
37 When you connect using TCP, you specify the port on your machine to
38 use to connect to the instance, and every instance must have its own
39 port. The mysql tool uses 3306 by default, but you can specify
40 another port for it to use.
41
42 For example:
43
44 ./cloud_sql_proxy \
45 -instances=myProject:us-central1:myInstance=tcp:3306,myProject:us-central1:myInstance2=tcp:3307 &
46 mysql -u myUser --host 127.0.0.1 --port 3307
47
48
49 Automating startup as a Daemon
50 ---------- ------- -- - ------
51
52 For a one off process an admin may start cloudsql-proxy, with the
53 appropriate flags, on the command line. However, to automatically
54 start the cloudsql-proxy(ies) at system start, or to package software
55 that requires one or more proxies, it is desireable to create systemd
56 unit files, and the corresponding /etc/init.d scripts.
57
58 This examples directory contains an example of how to set up a single
59 separate proxy. You may adjust the script to start a single proxy.
60
61 Naming Convention
62 ------ ----------
63
64 If installations follow a common naming convention, it would make it
65 easier to discover5 cloudsql-proxy daemon invocations on the machine.
66
67 1) Name the init.d file cloudsql-proxy-<foo>, where <foo> represents
68 your package, project, or intent
69 2) Similarily, name the systemd unit cloudsql-proxy-<foo>.service