Mysql: How to configure mysql proxy for an existing master-slave setup - mysql

I want to configure mysql proxy on my test environment to observe the below.
1. Behavior of the proxy
2. How load, CPU usage varies on my test server for read/write distribution.
I googled and able to install proxy on my ubuntu linux.
But I didnt see any thing on configuring it in a step by step manner and how to start or stop this.
Shall some one explore on this and this would be of great help for me.
Thanks in advance
Regards,
UDAY

By default if you run the proxy on the same machine as the server it will listen to port 4040 and query a backend server on the msyql default port of 3036. Other port numbers and server locations can be configured from the command line or with a configuration file.
To distribute queries across servers, add monitoring, profiling etc. you need to provide a Lua script to mysql-proxy. See the example / tutorial scripts in /usr/local/share/docs that came with the installation download. There is work to do for a production implementation.
The basics of how the scripting works can be found here under MySQL Proxy Scripting.
Don't be worried about Lua. The syntax is quite readable given the tutorial examples to work from. As and when you need it lua.org has more details of Lua.

Related

Database services on new vps

There are services like ServerPilot and many others that install on a vps that handle the lamp stack env. I'm wondering if there is a service that does this for databases. I install the service on a fresh vps and that the service would do all the heavy lifting like security, replication, separate read writes, back-ups and monitoring a long with easily setting up private network access for a set fee to use that service on my server.
Looking for a simple service to install on my own fresh vps, not RDS or Google Cloud.
Thank you!
What Does ServerPilot Really Do?
First, ServerPilot deploys complete LAMP stack on your server and that’s including world’s most used web server Apache, PHP5, and MYSQL. To make it even super, ServerPilot also installs and configures Nginx in front of Apache to achieve unbeatable speed and scalability.
Secondly, ServerPilot will secure your server with a firewall. To make it even secure, it will also update your server’s packages and make sure they stay updated all the time to avoid even single bug caused by outdated package.
Thirdly, ServerPilot also offers a premium feature to monitor real-time stats of your server’s performance including CPU, memory, disk space, and more.
What Does ServerPilot Not Do?
Meanwhile Serverpilot does not provide features related to installing, configuring and managing email and DNS. In this case you may need third-party DNS server to be able to point your domain to your VPS. Need recommendations? Try CloudFlare, PointHQ, NameCheap, etc.
Also, ServerPilot does not manage your server running other than Ubuntu.
Get more details at : http://www.servermom.org/install-manage-apache-nginx-php-mysql-easiest-serverpilot/1011/
I'm not sure about services, but assuming that your VPS is Ubuntu or some other Debian-based distro, you could perform sudo apt-get install lamp-server^ phpmyadmin on the command line to get your LAMP stack setup. This will setup Apache web server, PHP, and MySQL on your Linux server. Apache and PHP will come working out-of-the-box, and when you install MySQL, by default it asks for a root password to manage the database.
phpMyAdmin would be the key here because instead of doing all your database tasks via the command line, it provides a GUI interface in your web browser to manage databases and tables. To backup your database with phpMyAdmin, see this article.
With regards to customizations, for the firewall you can simply write a few iptables rules and for the database, you can run scheduled backups of a MySQL database by creating a cron job that runs the following command:/usr/bin/mysqldump -u dbusername -p'dbpassword' dbname > /path/backup.sql
Again, this isn't a service, but at least you wouldn't have to pay for any of the tools.
Unfortunately, there is no ultimate service than can perform all this stuff. However, you can set up this manually:
Database replication:
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
Database backup:
http://www.ducea.com/2006/05/27/backup-your-mysql-databases-automatically-with-automysqlbackup/
or
https://www.backuphowto.info/how-backup-mysql-database-automatically-linux-users
Database optimization:
https://www.tecmint.com/mysql-mariadb-performance-tuning-and-optimization/
and
http://www.monitis.com/blog/101-tips-to-mysql-tuning-and-optimization/
And for the networking, this tutorial may be helpful
http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

jboss as 7 - running multiple instances in the same linux server - standalone vs domain

I downloaded the jboss tar file.
Copied into my test server.
Did untar and installed it at $HOME/jboss/
Now, I need to have three instances running at the same time - Dev, QA, UAT - on a SINGLE server.
Is the Domain mode for this situation?
My conclusion was that it is not. That Domain mode is to manage JVMs across multiple servers.
For example, if I wanted QA to be in server1 and server2.
Is that correct?
However, my need is NOT to manage JBOSS instances across multiple servers.
Given that should I be using standalone mode?
If so, how would I run three instances of JBOSS (Dev, QA and UAT) concurrently.
I tried the instructions given here (Approach 2) : https://community.jboss.org/wiki/MultipleInstancesOfJBossAS7OnTheSameMachine
But I keep getting the errors like this:
MSC00001: Failed to start service jboss.serverManagement.controller.management.http: org.jboss.msc.service.StartException in service jboss.serverManagement.controller.management.http: Address already in use /127.0.0.1:9990
Is there any simple tutorial that I can follow.
I see this questions asked multiple times, but none of them seem to have a satisfactory answer.... that I find helpful. Is this a black art that lowly developers should not attempt in their home alone?
SGB
To get multiple jboss instances running on linux, in JBOSS_HOME/standalone/configuration/standalone.xml, I changed a single line from :
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
to the following...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:100}">
NOTE:
The reason I was having problem was because I had setup my JBOSS_HOME in my .bash_profile as per the jboss installation instructions. I needed to remove this so that both instances would not use the same JBOSS_HOME.
Slight Change in above comment.
bash$ ./standalone.sh -Djboss.socket.binding.port-offset=10000
This will start the server port as 18080.
default port is 8080 + 10000 will give 18080.
It's easier to add "-Djboss.socket.binding.port-offset=1000" while starting standalone.sh, e.g.:
./standalone.sh -Djboss.socket.binding.port-offset=1000
This will start jboss on ports +1000 to the standard ones (so 8080 will become 18080). No need to change xml files.
If you are using Jboss on Intellij, you would like to add the offset into server configuration, just go to Run --> Edit configuration:

Access MySQL via HTTP

Is there any working solution for MySQL to be able to request data directly via HTTP/jsonp way?
I need to provide ready SQL statement to the server.
Something with SQL-templates etc.
There is beta version of mysql 5.7 that does that
MySql experimental MySQL HTTP API
I am currently trying the following alternatives:
YOG-Sql Tunnel in PHP and
Others: (1) undergo writing some webservices (java - php - c), (2) use 'mysql proxy' or 'mysql tunnel' (3) Code everyhing in gcc and run a proxy as http.
Tried many, stayed with YogSQL Tunnel (lot easier) - BTW ALL THOSE DID NOT GAVE SAME REAL-TIME RESULTS AS EVERYTHING INSIDE THE SAME DATACENTER (2 servers) or a gigabit network (250k - 500k records/second). So, latency may be a killer on one's ubiquitous cloud computing.
No, there is no way to do this.
I tried NGINX http add-on modules
ngnix really rocks, on static html even amazon free was outstanding (1ms wait) on 3000 requests/sec. Specific SQL modules, whatsoever, may be memory-consumig if goes heavy loader.io.

Secure Remote mySQL Connection

Since our shared hosting server doesn't allow us to setup Tomcat I decided to install it on our local machine. The local Tomcat server allows us to listen to a certain port for Bancnet transactions which will then be processed and written to the remote site.
Question:
Is it safe for me to set the local PHP application to connect directly to the remote mySQL server? Any suggestions on how to make the connection secure. BTW, I have a self-signed certificate installed in the localhost but not sure how this applies to remote mySQL connection.
You could create a ssh tunnel between MySQL server and client. For more resiliency, use autossh.
If you don't connect over SSL or some other encrypted tunnel, I would absolutely assume that anything you send or receive from MySQL is done so in clear text that can be intercepted and used for malicious purposes from any link along the way. This might be fine for testing purposes with dummy data, but before you put this in production use or pull down live user data for testing, you really should either make arrangements for the data to be stored local to the web app or for there to be an encrypted connection.
Giving you a full overview of how to set up SSL connections to MySQL is beyond the scope of Stack Overflow and it's a bit complicated, but if you want to proceed, check out the documentation and do some research, there are some good informational resources out there.
I'm a bit confused as to the architecture you are trying to describe. What's running where?
If you can't install Tomcat then you probably won't be able to install anything like VPN software on the box.
MySQL can encrypt using SSL provided it has been enabled at compile time and at run time.
Alternatively, it should be fairly trivial to build a webservices tier on top of the remote database.
I would recommend switching to a VPS or managed host though.

Integrate different Nagios webservers

I have different sites running with 4 to 5 server at each location. All the locations have one monitoring server with Nagios. Now I want to create a central location and want to combine all the nagios services running at each location. Can anyone please point me to some documentation for these type of jobs.
There are two approaches that you can take.
Install a new Nagios core as you did at each location and perform active checks on each of the remote hosts. You'll likely end up installing NRPE on each of the remote hosts at each location and can read this document for the details: http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf. If your remote servers are Windows servers, you can use NSClient to much of the same things that NRPE does for Linux hosts. This effectively centralizes your monitoring server. I also wrote some how-to style entries for using NRPE to run privileged commands http://blog.gnucom.cc/?p=479 or to run event handlers http://blog.gnucom.cc/?p=458. If you get tired of installing NRPE, you can use my script here http://blog.gnucom.cc/?p=185. I also have instructions to install NSClient here http://blog.gnucom.cc/?p=201.
Install a new Nagios core as you did at each location and perform passive checks by instructing the remote Nagios cores to feed their results to the new central Nagios core's passive command file. I haven't done this myself, so I'm going to point you to the communities documentation here http://nagios.sourceforge.net/docs/2_0/passivechecks.html. You could probably look at my event handler post to set up event handlers that send checks to the main server.
From my personal experience, the first option I mentioned is easier to implement, and is far easy to administer. However, as your server fleet grows you'll start seeing major CPU bottlenecks with the main Nagios core. This is where passive checks would become beneficial, as the main Nagios core simply waits for critical checks to be sent to it rather than having to check them itself.
Hope this helps. :)
A centralized view tool may be what you are looking for. There are a number of different options available.
Nagiosfusion
MK Livestatus
Nagcen
Thruk