http://img.youtube.com/vi/ytyms4cNSbo/0.jpg
You will laugh at the lying politicians and be pissed at the same time.
Gun Free Zone
Just another WordPress site
http://img.youtube.com/vi/ytyms4cNSbo/0.jpg
You will laugh at the lying politicians and be pissed at the same time.
Gun Free Zone
https://theawesomer.com/photos/2023/08/laser_record_t.jpg
Compact discs use a laser to read data and convert that to music. Vinyl records, on the other hand, use a needle to pick up vibrations. Artist Tee Ken Ng used a laser pointer to do something else with a record, exposing a glow-in-the-dark record to laser light as it spun on a turntable. He made some more complicated patterns in this second video.
@teekenng Drawing with a laser pointer on a record that I covered with glow in the dark vinyl. The laser energises the phosphors in the #photoluminescent vinyl causing it to glow. As they lose their charge the older lines fade creating the trail effect. #hypnotic #vinylart #laser #spiral #liveanimation ♬ Space Walk – Lemon Jelly
The Awesomer
https://i0.wp.com/lefred.be/wp-content/uploads/2023/08/Screenshot-from-2023-08-18-15-01-29.png?w=1688&ssl=1
There are plenty GUI and Web application used to monitor a MySQL server. But if you are long time MySQL DBA, you might have used (and abused) Innotop !
I loved it ! And I even became maintainer of it. This particular task became more and more complicated with the different forks and their differences. Also, let’s be honest, Perl saved my life so many times in the past… but this was in the past. These days, having Perl on a system is more complicated.
But Innotop is still very popular in the MySQL world and to help me maintaining it, I would like to welcome a new member in the maintainer group: yoku0825. Tsubasa Tanaka has been a long time user and contributor of Innotop and I’m sure will keep to good work.
I’ve tried to find an alternative to Innotop, and I even wrote my own clone in Go for MySQL 8.0: innotopgo. But some limitations of the framework I used affected my motivation…

But some time ago, Charles Thompson contacted me about a new tool he was writing. He was looking for feedback.
The tool was very promising and finally this week he released it !
The tool is written in Python 3 and it’s very easy to modify it to contribute code.
Dolphie, the name of the tool, is available on GitHub and can easily be installed using pip:
$ pip install dolphie
Dolphie is already very complete and supports several new features available in MySQL 8.0.
For example I do like the Transaction History, that display the statement that were done inside a running transaction:


Dolphie also integrates the error log from Performance_Schema:

And it also allows searches:

Dolphie also provides some very interesting trending graphs that can be used to look at performance issues.
This is an example:

The best way to discover all its possibilities is to install and test it.
Dolphie is a brand new Open Source (GPLv3) tool for MySQL DBAs, made for the Community by the Community. It’s very easy to get involved, as Dolphie is written in Python, and Charles, its author, is very responsive in implementing features and solving problems.
I really encourage you to test it, submit bugs, feature requests and, of course, contributions !
Welcome Dolphie and long life !
Planet MySQL
https://www.percona.com/blog/wp-content/uploads/2023/08/Use-systemd-in-Linux-to-Configure-and-Manage-Multiple-MySQL-Instances-200×115.jpeg
This blog describes how to configure systemd for multiple instances of MySQL. With package installations of MySQL using YUM or APT, it’s easy to manage MySQL with systemctl, but how will you manage it when you install from the generic binaries?
Here, we will configure multiple MySQL instances from the generic binaries and manage them using systemd.
We will do that, but why would you need multiple instances on the same host in the first place? Why not just create another database on the same instance? In some cases, you will need multiple instances on the host.
The original motivation for FB was due to different hardware generations, especially between regions/data centers. For example, an older data center may have smaller/less powerful machines, so they run fewer mysqld per host there to compensate. There were other exceptions, too, like abnormally large special-case-shard needing dedicated machines.
That said, other performance motivations mentioned above did play into it, especially before the days of multi-threaded replication. And I agree that in the modern age of cloud and huge flash storage, the vast majority of companies will never need to consider doing this in prod, but there is always a chance of its need.
To install and use a MySQL binary distribution, the command sequence looks like this:
yum install libaio1 libaio-dev numactl
useradd -r -g mysql -s /bin/false mysql
groupadd mysql
cd /usr/local/
tar xvfz /root/Percona-Server-8.0.19-10-Linux.x86_64.ssl101.tar.gz
ln -s /usr/local/Percona-Server-8.0.19-10-Linux.x86_64.ssl101/ mysql
cd /data/
mkdir -p /data/mysql/{3306,3307}/data
chown -R mysql:mysql /data
chmod 750 -R /data/mysql/{3306,3307}/data
Below is an example of the first instance I placed in /etc/prod3306.cnf. My naming convention is prod3306 and prod3307. I then place that naming convention in the configuration filename /etc/prod3306.cnf. I could have done my.cnf.instance or instance.my.cnf.
[root@ip-172-31-128-38 share]# cat /etc/prod3306.cnf [mysqld@prod3306] datadir=/data/mysql/3306 socket=/data/mysql/3306/prod3306.sock mysqlx_socket=/data/mysql/3306/prod3306x.sock log-error=/data/mysql/prod3306.err port=3306 mysqlx_port=33060 server-id=1336 slow_query_log_file=/data/mysql/3306/slowqueries.log innodb_buffer_pool_size = 50G lower_case_table_names=0 tmpdir=/data/mysql/3306/tmp/ log_bin=/data/mysql/3306/prod3306-bin relay_log=/data/mysql/3306/prod3306-relay-bin lc_messages_dir=/usr/local/mysql/share [mysqld@prod3307] datadir=/data/mysql/3307 socket=/data/mysql/3307/prod3307.sock mysqlx_socket=/data/mysql/3307/prod3307x.sock log-error=/data/mysql/prod3307.err port=3307 mysqlx_port=33070 server-id=2337 slow_query_log_file=/data/mysql/3307/slowqueries.log innodb_buffer_pool_size = 50G lower_case_table_names=0 lc_messages_dir=/usr/local/mysql/share tmpdir=/data/mysql/3307/tmp/ log_bin=/data/mysql/3307/prod3307-bin relay_log=/data/mysql/3307/prod3307-relay-bin
The directory lc_messages_dir=/usr/local/mysql/share is required when your MySQL binaries base directory is not the default one, so I had to pass the path for it — otherwise, MySQL won’t start.
Initialize your database and get the temporary password for the database from the error log file so you can log in and update the passwords after the MySQL instances are started.
ln -s /usr/local/mysql/bin/mysqld /usr/bin mysqld --no-defaults --initialize-insecure --user=mysql --datadir=/data/mysql/3307 --lower_case_table_names=0 mysqld --no-defaults --initialize-insecure --user=mysql --datadir=/data/mysql/3306 --lower_case_table_names=0
Create the SYSTEMD base configuration at /etc/systemd/system/mysql@.service and place the following contents inside. This is where the naming convention of the MySQL instances comes into effect. In the SYSTEMD configuration file, %I will be replaced with the naming convention that you use.
[root@ip-172-31-128-38 share]# cat /usr/lib/systemd/system/mysqld@.service # Copyright (c) 2016, 2021, Oracle and/or its affiliates. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, # as published by the Free Software Foundation. # # This program is also distributed with certain software (including # but not limited to OpenSSL) that is licensed under separate terms, # as designated in a particular file or component or in included license # documentation. The authors of MySQL hereby grant you an additional # permission to link the program and your derivative works with the # separately licensed software that they have included with MySQL. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License, version 2.0, for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # systemd service file for MySQL forking server # [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql Type=forking PIDFile=/data/mysql/mysqld-%i.pid # Disable service start and stop timeout logic of systemd for mysqld service. TimeoutSec=0 # Execute pre and post scripts as root PermissionsStartOnly=true # Needed to create system tables #ExecStartPre=/usr/bin/mysqld_pre_systemd %I # Start main service ExecStart=/usr/bin/mysqld --defaults-file=/etc/prod3306.cnf --defaults-group-suffix=@%I --daemonize --pid-file=/data/mysql/mysqld-%i.pid $MYSQLD_OPTS # Use this to switch malloc implementation EnvironmentFile=-/etc/sysconfig/mysql # Sets open_files_limit LimitNOFILE = 65536 Restart=on-failure RestartPreventExitStatus=1 Environment=MYSQLD_PARENT_PID=1 PrivateTmp=false [root@ip-172-31-128-38 share]#
Reload daemon
systemctl daemon-reload
Start MySQL
systemctl start mysqld@prod3307 systemctl start mysqld@prod3306
Enable MySQL service
systemctl enable mysqld@prod3307 systemctl enable mysqld@prod3306
Error log for each instance
[root@ip-172-31-128-38 3307]# tail -5 /data/mysql/prod3306.er tail: cannot open ‘/data/mysql/prod3306.er’ for reading: No such file or directory [root@ip-172-31-128-38 3307]# tail -5 /data/mysql/prod3306.err 2023-07-10T05:26:42.521994Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: Shutdown complete (mysqld 8.0.19-10) Percona Server (GPL), Release 10, Revision f446c04. 2023-07-10T05:26:48.210107Z 0 [System] [MY-010116] [Server] /usr/bin/mysqld (mysqld 8.0.19-10) starting as process 20477 2023-07-10T05:26:52.094196Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2023-07-10T05:26:52.112887Z 0 [System] [MY-010931] [Server] /usr/bin/mysqld: ready for connections. Version: '8.0.19-10' socket: '/data/mysql/3306/prod3306.sock' port: 3306 Percona Server (GPL), Release 10, Revision f446c04. 2023-07-10T05:26:52.261062Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/data/mysql/3306/prod3306x.sock' bind-address: '::' port: 33060
root@ip-172-31-128-38 3307]# tail -5 /data/mysql/prod3307.err 2023-07-10T05:26:36.032160Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: Shutdown complete (mysqld 8.0.19-10) Percona Server (GPL), Release 10, Revision f446c04. 2023-07-10T05:26:58.328962Z 0 [System] [MY-010116] [Server] /usr/bin/mysqld (mysqld 8.0.19-10) starting as process 20546 2023-07-10T05:27:02.179449Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2023-07-10T05:27:02.198092Z 0 [System] [MY-010931] [Server] /usr/bin/mysqld: ready for connections. Version: '8.0.19-10' socket: '/data/mysql/3307/prod3307.sock' port: 3307 Percona Server (GPL), Release 10, Revision f446c04. 2023-07-10T05:27:02.346514Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/data/mysql/3307/prod3307x.sock' bind-address: '::' port: 33070 [root@ip-172-31-128-38 3307]#
Utilizing systemctl to control MySQL significantly simplifies the management of MySQL instances. This approach facilitates the easy configuration of multiple instances, extending beyond two, and streamlines the overall administration process. However, it is essential to be mindful of memory allocation when setting up multiple MySQL instances on a single server. Allocating memory appropriately for each MySQL instance ensures sufficient overhead and optimal performance.
Percona Monitoring and Management is a best-of-breed open source database monitoring solution. It helps you reduce complexity, optimize performance, and improve the security of your business-critical database environments, no matter where they are located or deployed.
Download Percona Monitoring and Management Today
Planet MySQL
https://stackabuse.com/assets/images/icon-information-circle-solid.svg
Pandas is a powerful Python library for working with and analyzing data. One operation that you might need to perform when working with data in Pandas is selecting columns based on their string prefix. This can be useful when you have a large DataFrame and you want to focus on specific columns that share a common prefix.
In this Byte, we’ll explore a few methods to achieve this, including creating a series to select columns and using DataFrame.loc.
Let’s start with a simple DataFrame:
import pandas as pd
data = {
'item1': [1, 2, 3],
'item2': [4, 5, 6],
'stuff1': [7, 8, 9],
'stuff2': [10, 11, 12]
}
df = pd.DataFrame(data)
print(df)
Output:
item1 item2 stuff1 stuff2
0 1 4 7 10
1 2 5 8 11
2 3 6 9 12
To select columns that start with ‘item’, you can use list comprehension:
selected_columns = [column for column in df.columns if column.startswith('item')]
print(df[selected_columns])
Output:
item1 item2
0 1 4
1 2 5
2 3 6
Another approach to select columns based on their string prefix is to create a Series object from the DataFrame columns, and then use the str.startswith() method. This method returns a boolean Series where a True value means that the column name starts with the specified string.
selected_columns = pd.Series(df.columns).str.startswith('item')
print(df.loc[:, selected_columns])
Output:
item1 item2
0 1 4
1 2 5
2 3 6
The DataFrame.loc method is primarily label-based, but may also be used with a boolean array. The ix indexer for DataFrame is deprecated now, as it has a number of problems. .loc will raise a KeyError when the items are not found.
Consider the following example:
selected_columns = df.columns[df.columns.str.startswith('item')]
print(df.loc[:, selected_columns])
Output:
item1 item2
0 1 4
1 2 5
2 3 6
Here, we first create a boolean array that is True for columns starting with ‘item’. Then, we use this array to select the corresponding columns from the DataFrame using the .loc indexer. This method is more efficient than the previous ones, especially for large DataFrames, as it avoids creating an intermediate list or Series.
The filter() function in pandas DataFrame provides a flexible and efficient way to select columns based on their names. It is especially useful when dealing with large datasets with many columns.
The filter() function allows us to select columns based on their labels. We can use the like parameter to specify a string pattern that matches the column names. However, if we want to select columns based on a string prefix, we can use the regex parameter.
Here’s an example:
import pandas as pd
# Create a DataFrame
df = pd.DataFrame({
'product_id': [101, 102, 103, 104],
'product_name': ['apple', 'banana', 'cherry', 'date'],
'product_price': [1.2, 0.5, 0.75, 1.3],
'product_weight': [150, 120, 50, 60]
})
# Select columns that start with 'product'
df_filtered = df.filter(regex='^product')
print(df_filtered)
This will output:
product_id product_name product_price product_weight
0 101 apple 1.20 150
1 102 banana 0.50 120
2 103 cherry 0.75 50
3 104 date 1.30 60
In the above code, the ^ symbol is a regular expression that matches the start of a string. Therefore, '^product' will match all column names that start with ‘product’.
Next: The filter() function returns a new DataFrame that shares the data with the original DataFrame. So, any modifications to the new DataFrame will not affect the original DataFrame.
In this Byte, we explored different ways to select columns in a pandas DataFrame based on a string prefix. We learned how to create a Series and use it to select columns, how to use the DataFrame.loc function, and how to apply the DataFrame.filter() function. Of course, each of these methods has its own advantages and use cases. The choice of method depends on the specific requirements of your data analysis task.
Planet Python
https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/08/network-switch-cables.jpg
Internet access is essential, but you may wonder which Linux processes use your connection the most on your computer. Fortunately, with some common Linux utilities, monitoring which processes use your bandwidth is easy. Here are some of them:
nethogs is a program that does for internet connections what htop or top does for CPU and memory usage. It shows you a snapshot of which processes are accessing the network.
Like top, htop, or atop, nethogs is a full-screen program that updates after a few seconds to show you the current network connections by processes.
Installing nethogs is simple. You just go through your package manager.
For example, on Debian and Ubuntu:
sudo apt install nethogs
And on Arch Linux:
sudo pacman -S nethogs
On the Red Hat family:
sudo dnf install nethogs
To run nethogs, you’ll need to be root:
sudo nethogs
It’s possible to set it so that you can run nethogs as a regular user using this command:
sudo setcap "cap_net_admin,cap_net_raw+pe" /path/to/nethogs
You should replace “/path/to/nethogs” with the absolute pathname of nethogs. You can find this with the which command:
which nethogs
While lsof is a utility for listing open files, it can also list open network connections. The -i option lists internet connections attached to running processes on the system. On Linux, everything is a file, after all.
To see current internet connections, use this command:
lsof -i
lsof will show you the name of any commands with open internet connections, the PID, the file descriptor, the type of internet connection, the size, the protocol, and the formal file name of the connection.
Using the -i4 and -i6 options allows you to view connections using IPv4 or IPv6.
There’s a good chance you have lsof installed already. It’s also easy to install on major Linux distros if it isn’t.
On Debian and Ubuntu, type:
sudo apt install lsof
And on Arch:
sudo pacman -S lsof
On the Red Hat family of distros:
sudo dnf install lsof
netstat is a powerful program on its own, letting you see network connections on your system. It doesn’t show you which processes the network connections are attached to. As with lsof, you can see this with a command-line option.
netstat is part of the net-tools package. You can install it on most Linux distros using the default package manager.
For example, on Debian or Ubuntu:
sudo apt install net-tools
On Arch Linux:
sudo pacman -S net-tools
To install netstat on Fedora, CentOS, and RHEL, run:
sudo dnf install net-tools
You can run netstat at the command line. By default, it will show you information such as the protocol, the address, and the state of the connection, but the -p option adds a column that shows the process ID and the command name.
netstat -p
When you run it, netstat will just list all the network connections and then exit. With the -c option, you can see a continually updated list of connections:
netstat -pc
This would be similar to using a screen-oriented program like nethogs, but the advantage of doing it this way is that you can pipe the output into another program like grep or a pager to examine it:
netstat -p | grep 'systemd'
To see all of the processes with network connections on your system, you may have to run netstat as root:
sudo netstat
Linux, like many modern OSes, is intimately connected to the internet. It can be difficult at times to track down which processes are using your bandwidth. With tools like nethogs, lsof, and netstat, you can track down processes that have open connections.
Processes sometimes go haywire, even with connections. On Linux, you can easily terminate any rogue processes.
MakeUseOf
https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2023/08/mongodb-queries-you-must-know.jpg
MongoDB is one of the most desired and admired NoSQL databases for professional development. Its flexibility, scalability, and ability to handle large volumes of data make it a top choice for modern applications. If you want to master MongoDB’s regular queries and operations, you’re in the right place.
Whether you’re looking to efficiently retrieve and manipulate data, implement robust data models, or build responsive applications, acquiring a deep understanding of common MongoDB queries and operations will undoubtedly enhance your skills.
Creating a database locally via the MongoDB Shell is straightforward, especially if you’ve set up a remote cluster. You can create a new database in MongoDB with the use command:
use db_name
While the above command creates a new database, you can use it to switch to an existing database without creating a new one from scratch.
First, switch to the database you want to drop using the use command as done previously. Then drop the database using the dropDatabase() command:
use db_name
db.dropDatabase()
To create a collection, switch to the target database. Use the createCollection() keyword to make a new MongoDB collection:
db.createCollection("collection_name")
Replace collection_name with your chosen collection name.
While sending data to a collection, you can insert a single document or an array of documents.
To insert a single document:
db.collection_name.insertOne({"Name":"Idowu", "Likes":"Chess"})
You can also use the above method to insert an array of documents with one ID:
db.collection_name.insertOne([{"Name":"Idowu", "Likes":"Chess"}, {"Language": "Mongo", "is_admin": true}])
To insert many documents at once, with each having separate IDs, use the insertMany keyword:
db.collection_name.insertMany([{"Name":"Idowu", "Likes":"Chess"}, {"Name": "Paul", "Likes": "Wordle"}])
You can query all documents from a collection using the find() keyword:
db.collection_name.find()
The above returns all the documents inside the specified collection:
You can also limit the returned data to a specific number. For instance, you can use the following command to get only the first two documents:
db.collection_name.find().limit(2)
There are many ways to filter documents in MongoDB. Consider the following data, for instance:
If querying only a specific field in a document, use the find method:
db.collection_name.find({"Likes":"Wordle"}, {"_id":0, "Name":1})
The above returns all documents where the value of Likes is Wordle. It only outputs the names and ignores the document ID.
You can also filter a collection by a numerical factor. Say you want to get the names of all users older than 21, use the $gt operator:
db.collection_name.find({"Likes":"Chess", "Age":{"$gt":21}}, {"_id":0, "Name":1})
The output looks like so:
Try replacing find with findOne to see what happens. However, there are many other filtering keywords:
Sorting helps arrange the query in a specific order. You can sort in descending or ascending order. Keep in mind that sorting requires a numerical reference.
For instance, to sort in ascending order:
db.collection_name.find({"Likes":"Chess"}).sort({"Age":1})
To sort out the above query in descending order, replace “1” with “-1.”
db.collection_name.find({"Likes":"Chess"}).sort({"Age":-1})
MongoDB updates require atomic operators to specify how you want the update done. Here is a list of commonly used atomic operators you can pair with an update query:
To update a document and add a new field, for example:
db.collection_name.updateOne({"Name":"Sandy"}, {"$set":{"Name":"James", "email":"example@gmail.com"}})
The above updates the specified document as shown:
Removing the email field is straightforward with the $unset operator:
db.collection_name.updateOne({"Name":"Sandy"}, {"$unset":{"email":"example@gmail.com"}})
Consider the following sample data:
You can insert an item into the existing items array field using the $push operator:
db.collection_name.updateOne({"Name":"Pete"}, {"$push":{"items":"Plantain"}})
Here’s the output:
Use the $each operator to insert many items at once:
db.collection_name.updateOne({"Name":"Pete"}, {"$push":{"items": {"$each":["Almond", "Melon"]}}})
Here’s the output:
As mentioned, the $pull operator removes an item from an array:
db.collection_name.updateOne({"Name":"Pete"}, {"$pull":{"items":"Plantain"}})
The updated data looks like so:
Include the $in keyword to remove many items in an array at one go:
db.collection_name.updateOne({"Name":"Pete"}, {"$pull":{"items": {"$in":["Almond", "Melon"]} }})
The deleteOne or deleteMany keyword trashes a document from a collection. Use deleteOne to remove a document based on a specified field:
db.collection_name.deleteOne({"Name":"IDNoble"})
If you want to delete many documents with keys in common, use deleteMany instead. The query below deletes all documents containing Chess as their Likes.
db.collection.deleteMany({"Likes":"Chess"})
Indexing improves query performance by streamlining the number of documents MongoDB needs to scan. It’s often best to create an index on fields you query more frequently.
MongoDB indexing is similar to how you use indexes to optimize SQL queries. For instance, to create an ascending index on the Name field:
db.collection.createIndex({"Name":1})
To list your indexes:
db.collection.getIndexes()
The above is only a preamble. There are several other methods for creating an index in MongoDB.
The aggregation pipeline, an improved version of MapReduce, allows you to run and store complex calculations from inside MongoDB. Unlike MapReduce, which requires writing the map and the reduce functions in separate JavaScript functions, aggregation is straightforward and only uses built-in MongoDB methods.
Consider the following sales data, for example:
Using MongoDB’s aggregation, you can calculate and store the total number of products sold for each category as follows:
db.sales.aggregate([{$group:{"_id":"$Section", "totalSold":{$sum:"$Sold"}}}, {$project:{"_id":0, "totalSold":1, "Section":"$_id"}}])
The above query returns the following:
MongoDB offers many querying methods, including features to improve query performance. Regardless of your programming language, the above query structures are rudimentary for interacting with a MongoDB database.
There may be some discrepancies in base syntaxes, though. For example, while some programming languages like Python recognize snake cases, others, including JavaScript, use the camel case. Ensure you research what works for your chosen technology.
MakeUseOf
So, you’ve been tasked with managing the MySQL databases in your environment, but you’re not sure where to start.
Here’s the quick & dirty guide. Oh yeah, and for those who love our stuff, take a look to your right.
See that subscribe button? Grab our newsletter!
Here are the steps that are required for MySQL management as a DBA:
The “yum” tool is your friend. If you’re using Debian, you’ll use apt-get but it’s very similar. You can do a “yum list” to see what packages are available. We prefer to use the Percona distribution of MySQL.
It’s fully compatible with stock MySQL distribution, but usually a bit ahead in terms of tweaks and fixes. Also, if you’re not sure, go with MySQL 5.5 for new installations.
$ rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm
$ yum install Percona-Server-client-55
$ yum install Percona-Server-shared-55
$ yum install Percona-Server-shared-compat
$ yum install Percona-Server-server-55
The last command will create a fresh database for you as well.
Already have data in an existing database? Then you can migrate between MySQL and Oracle.
MySQL replication is a process you’ll need to setup over and over again. Its statement based in MySQL. A lot of INSERT, UPDATE, DELETE & CREATE statements are transferred to the slave database, and applied by a thread running on that box.
The steps to setup are as follows:
$ mysqldump -A –single-transaction > full_primary.mysql
Alternatively, you can use xtrabackup to take setup replication without locking!
$ mysql < full_primary.mysql
mysql> change master to
> master_user=’rep’,
> master_password=’rep’,
> master_host=’10.20.30.40′,
> master_log_file=’bin-log.001122′,
> master_log_pos=11995533;
mysql> start slave;
mysql> show slave statusG;
You should see something like this:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
If you’re managing an existing MySQL database and you hit a performance blip, it’s likely due to something that has changed. You may be getting a spike in user traffic, that’s new! Or you may have some new application code that has been recently deployed, that’s new SQL that’s running in your database. What to do?
If you haven’t already, enable the slow query log:
mysql> set global slow_query_log=1;
mysql> set global long_query_time=0.50;
Now wait a while. A few hours perhaps, or a few days. The file should default to
/var/lib/mysql/server-slow.log
Now analyze it. You’ll use a tool from the percona toolkit to do that. If you haven’t already done so, install the percona toolkit as well.
$ yum install percona-toolkit
$ pt-query-digest /var/lib/mysql/server-slow.log > /tmp/server-report.txt
Once you’ve done that “less” the file, and review. You’ll likely see the top five queries account for 75% of the output. That’s good news because it means less query tuning. Concentrate on those five and you’ll get the most bang for your buck.
Bounce your opinions about the queries off of the developers who build application code. Ask them where the code originates. What are those pages doing?
Check the tables, are there missing indexes? Look at the EXPLAIN output. Consider tuning the table data structures, multi-column, or covering indexes. There is typically a lot that can improve these troublesome queries.
You’ll want to have a battery of day-to-day tools at your disposal for interactive monitoring of the database. Don’t go overboard. Obsessive tuning means obsessively turning knobs and dials. If there are no problems, you’re likely to create some. So, keep that in mind.
innotop is a “top” like utility for monitoring what’s happening inside your little database universe. It’s probably already available through yum and the “epel” repository:
$ yum install innotop
First edit the .my.cnf file and add:
[client]
user=root
password=mypw
From there you should be able to just fire up innotop without problems.
mysqltuner is a catch all tool that does a once over of your server, and gives you some nice feedback. Get a copy as follows:
$ wget mysqltuner.pl
Then run it:
$ chmod +x mysqltuner.pl
$ ./mysqltuner.pl
Here are a couple of useful mysql shell commands to get database information:
mysql> show processlist;
mysql> show innodb status;
mysql> show status;
There is also one last tool which can come in handy for reviewing a new MySQL server. Also, from percona toolkit, the summary tool. Run it as follows:
$ pt-summary
You absolutely need to know about backups if you want to sleep at night. Hardware and database servers fail, software has bugs that bite. And if all that doesn’t get you, people make mistakes. So-called operator error will surely get you at some point. There are three main types:
With the database shutdown, make a complete copy of the /var/lib/mysql directory, along with perhaps the /etc/my.cnf file. That together amounts to a cold backup of your database.
There has been an enterprise tool for MySQL that provides this for some time. But we’re all very lucky to also have the open source Percona xtrabackup at our disposal. Here’s a howto using it for replication setup.
These will generate a file containing all the CREATE statements to recreate all your objects, and then INSERT statements to add data.
$ mysqldump -A > my_database_dump.mysql
The percona toolkit summary tool is a great place to start.
$ pt-summary
Want to compare the my.cnf files of two different servers?
$ pt-config-diff h=localhost h=10.20.30.40
Of course, you’ll want to review the my.cnf file overall. Be sure you have looked at these variables:
tmp_table_size
max_head_table_size
default_storage_engine
read_buffer_size
read_rnd_buffer_size
sort_buffer_size
join_buffer_size
log_slow_queries
log_bin
innodb_log_buffer_size
innodb_log_file_size
innodb_buffer_pool_size
key_buffer_size (for MyISAM)
query_cache_size
max_packet_size
max_connections
table_cache
thread_cache_size
thread_concurrency
The output of the pt-summary and mysqltuner.pl scripts should give you some useful information here. Be sure to have passwords set on all accounts. Use fewer privileges by default, and only add additional ones to accounts as necessary.
You can use wildcards for the IP address but try to be as specific as possible. Allow for a subnet, not the whole internet ‘10.20.30.%’ for example instead of just ‘%’.
Also keep in mind that at the operating system or command line level, anyone with root access can really mess up your database. Writing to the wrong datafile or changing permissions can hose a running database very quickly.
Use a monitoring system such as Nagios to keep an eye on things. At minimum check for:
Periodically it’s a good idea to review your systems even when they’re running smoothly. Don’t go overboard with this however. As they say if it isn’t broke, don’t fix it.
MySQL is full of surprises. In the Oracle world you might be surprised at how arcane some things are to setup, or how much babysitting they require. Or you might be surprised at how obscure some tuning & troubleshooting techniques are. In the MySQL world there are big surprises too. Albeit sometimes of a different sort.
One that continues to defy my expectations is those surrounding replication. Even if it is running without error, you still have more checking today. Unfortunately, many DBAs don’t even know this!
That’s because MySQL replication can drift out of sync without error. We go into specific details of what things can cause this, but more importantly how to check and prevent it, by bulletproofing MySQL with table checksums.
Spinup a cloud server in Amazon EC2, and restore your logical dump or hotbackup onto that box. Point a test application at that database and verify that all is well. It may seem obvious that a backup will do all this.
But besides the trouble when a filesystem fills up, or some command had the wrong flag or option included. There can be even bigger problems if some piece or section of the database was simply overlooked.
It’s surprising how easy it is to run into this trouble. Testing also gives you a sense of what restoring time looks like in the real world. A bit of information your boss is sure to appreciate.
If you made it this far, you know you want to grab the newsletter.
That’s all about how to manage MySQL as a DBA. Hopefully, you have found this guide exceptional from other ordinary guides to MySQL management. For any further queries, our comment box is always open for you. Thanks for reading!
The post Accidental DBA’s Guide to MySQL Management appeared first on iheavy.
Planet MySQL
https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/d8dad39f888525d8adec05e95b0dbfda.png
The white tiles in the living area of my home are an abomination: I track in dirt from the garden constantly, my dog is forever bursting through the doggie door with muddy glee, and I seem to cook with the spirit of Ratatouille, absentmindedly splashing food all about. I find myself in constant pursuit of cleaning tools that will make my home seem like less of a disaster, and as a result, I’ve bought an embarrassing number of devices that promised to truly scrub my floor clean.
Among them, I’ve tried the Hoover SpinScrub (a precursor to this model), various steam cleaners, many tonics and potions, and even your plain old handheld scrub brush, because it finally seemed that every product that promised to really scrub away serious dirt on your tiles paled in comparison to just getting down and scrubbing the floor yourself. But one night while perusing a Home Depot ad, I saw it: It gleamed bright yellow, and it promised to answer all my problems. And it actually lived up to that promise.
The best floor scrubber is the Ryobi Telescoping Power Scrubber. Just look at it. It is quite literally a cordless powerhouse. Although it comes with a medium hard brush, you can also buy soft and hard brush heads for it. Ostensibly, it’s for scrubbing your car or boat exterior, perhaps your roof or house siding.
But if you’re looking for clean tile, there is nothing on the market like this tool.
I use the medium hardness brush, and I work the floor in sections, with a spray bottle of water in one hand, a container of Bar Keepers Friend, and a towel. (The only advantage that more traditional floor scrubbers have is their onboard water source. The Ryobi power scrubber has none of that, but to me, that’s a non-issue given the way it performs.)
The towel is on the floor, and I stand on it. You spray the floor in front of you, sprinkle it with Bar Keepers Friend, and then go to town with your scrubber. As you move forward, keep the towel under your feet, using it to mop up any water as you go. When you get to the end of the hall or room, you may need to give the wall trim a quick wipe for any splatter, but it’s pretty minimal.
The upside of this is incredibly satisfyingly clean tile. Every groove, every niche is clean. The downside is that you’ve likely taken off any sealer on the tile, so that might be worth refreshing with a sealer, which is easy enough. (You can even do so with the scrubber by swapping the head for one of the soft heads like the microfiber cloth.) In between serious cleanings, you can skip the Bar Keepers Friend and use water alone or a mopping solution, but really, the scrubber is doing the majority of the work.
To wash the scrubber, you disconnect the head and throw it in the dishwasher. Disconnect the battery and recharge it. I can even use one of my smaller 1.5 volt batteries with the scrubber and get a full house clean at once.
People tend to be loyalists when they get into a line of tools. If they start with Makita, they’ll stick with it, and DeWalt folks are die-hards. Like a lot of people, I started with Ryobi because of the price point and its absurdly wide selection of tools in the cordless series. I’ve stuck with the line because I genuinely have a lot of success with it as I’ve grown my collection. I find the batteries stay well charged (and I haven’t had one die yet). I recommend buying bare tools (without battery packs) as soon as you’ve acquired a few chargers, and only getting the higher-end batteries. I have two 4-volt batteries and I almost never find myself needing another. Ryobi has really expanded the line into a lot of consumer-friendly pieces like fans and air compressors, and it has invested in their brushless cordless line—a series of tools with less likelihood of burning out your motor, while also being more powerful. All this to say, I wasn’t surprised Ryobi had a great tool solution here.
For what its worth, they also have a handheld scrubber, and if I hadn’t previously picked up some brush heads that I can just throw on my Ryobi brushless hammer drill for scrubbing smaller surfaces like sinks and bathtubs, I’d have picked it up as well.
Lifehacker
https://www.iheavy.com/wp-content/uploads/2023/08/Top-MySQL-DBA-Interview-Questions.jpg
Continuing from our Top MySQL DBA interview questions (Part 1) here are five more questions that test a MySQL DBA’s knowledge, with two that will help suss out some personality traits.

Disk performance should be an ever-present concern to a DBA. So, although they don’t need to be a storage specialist, they should have a working knowledge. Ask them about RAID versions, mirroring versus striping, and so forth. Mirroring combines two disks as a unit. Every write is duplicated on both disks.
If you lose one disk, you have an immediate copy. Like a tandem truck that has spare tires running in parallel. Lose one, and you don’t have to pull over immediately to replace it. Striping spreads I/O over multiple disks so you on the one hand increase throughput linearly as you add disks.
That’s because you have more disks working for you. At the same time, you increase risk with each new disk you add, because the failure rate is then the sum total of all those disks.
For relational databases, the best RAID level is 10, which is striping over mirrored sets. You use more disks, but disks are cheap compared to the hassle of any outage.
If you’re deploying on Amazon, your candidate should be familiar with the Elastic Block Storage offering also known as EBS. This is virtualized storage, so it introduces a whole world of operational flexibility.
No longer do you have to jump through hoops to attach, add or reconfigure storage on your servers. It can all be done through command line API calls. That said EBS suffers from variability problems as with any other shared resource.
Although Amazon guarantees your average throughput, the I/O you get at a given time can swing wildly from low to high. Consider Linux software RAID across multiple EBS volumes to mitigate against this.
A basic replication setup involves creating a full dump of the primary database, while it’s tables are locked. The DBA should capture the master status, logfile & position at that time. She should then copy the dump file to the secondary machine & import the full dump.
Finally, the CHANGE MASTER TO statement should be run to point this database instance to its master. Lastly START SLAVE should be issued. If all goes well SHOW SLAVE STATUS should show YES for both of these status variables:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Master-master replication is similar, except one additional step. After the above steps have run, you know that your application is not pointing at the slave database. If you’re not sure, verify that fact first.
Now determine the logfile name & position on the slave with SHOW MASTER STATUS. Return to the primary box, and run the CHANGE MASTER TO command to make it slave from the secondary box. You’ve essentially asked MySQL to create a circular loop of replication.
How does MySQL avoid getting into an infinite loop in this scenario? The server_id variable must be set, and be unique for all MySQL instances in your replication topology.
For extra credit, ask the candidate about replication integrity checking. As important as this piece is to a solid reliable replication setup, many folks in the MySQL world are not aware of the necessity.
Though replication can be setup, and running properly, that does not mean it will keep your data clean and perfect.
Due to the nature of statement-based replication, and non-deterministic functions and/or non-transactional tables, statements can make their way into the binary logs, without completing. What this means is they may then complete on the slave, resulting in a different row set on the same table in the master & slave instance.
Percona’s pt-table-checksum is the preventative tool to use. It can build checksums of all your tables, and then propagate those checksums through replication to the slave. An additional check can then be run on the slave side to confirm consistency or show which rows & data are different.
Creating a grant in MySQL can effectively create the user as well. MySQL users are implemented in a very rudimentary fashion. The biggest misunderstanding in this area surrounds the idea of a user.
In most databases a username is unique by itself. In MySQL it is the *combination* of user & hostname that must be unique.
So, for example, if I create user sean@localhost, sean@server2 and sean@server3, they are actually three distinct users, which can have distinct passwords, and privileges. It can be very confusing that sean logging in from the local command line has different privileges or password than sean logging in from server2 and server3. So that’s an important point.
This is a good opportunity for the candidate to show some creativity with respect to operations and Linux servers. There are all sorts of ways into a database server:
There are endless possibilities here. Listening for creative thinking here, reveals how much that person will think thoroughly and effectively about protecting your systems from those same threats.
Google for a long time was a fan of these types of tests at interviews, but I’m not at all. For one thing, you filter for good test takers, and for another, the candidate has no resources – either books or the internet at their disposal.
Why not instead ask them to tell a story? Storytelling conveys a lot of things. It conveys a bit of teaching ability, which extends far beyond internalizing some multiple-choice questions.
It tells you more about their personality, which as I’ve said is very important. It shows how they solve problems, as they’ll take you through their process. And gives them an opportunity to tell you about a real-world triumph they presided over.
In my experience, some of the most important traits of a new hire center around personality traits, and how they might mix with your existing team. Being punctual for an interview, for instance, sets a precedent for many things. But that door swings both ways, so if you want to hire these types of folks, don’t keep them waiting either!
Pay attention to whether or not the candidate takes some lead in the conversation at all. This can indicate the person is a self-starter. Obviously, a great candidate will also listen carefully and patiently to what you have to say, but may then take the ball and run with it somewhat.
Listen for signals that the person is active in the field, posting on forums, and attending conferences, meetups, and forums on technology topics. You might also ask them if they blog, and what topics interest them.
As a job seeker, you need to have knowledge and experience in database administration in the beginning. While preparing for an interview, you need to review the job description carefully, conduct research on the company and its industry, and then refresh your technical knowledge of DBMS concepts and relevant programming languages accordingly.
Here are the general questions that are asked in a DBA interview:
Here are the questions which are generally asked in MySQL interview:
The first role of a database administrator in MySQL is to administer MySQL Server data systems and structures. A DBA can use software to store and organize data, records, or information. They also need to ensure that the data are protected securely from unauthorized access and that users can easily access the information as they need.
The basics that you need to know as a MySQL DBA are discussed in this article and we’ll come again with another part where we’ll discuss more about top MySQL DBA interview questions. Hopefully, now you have got the basic concept of how you need to prepare yourself for a DBA interview after reading this article. Read our next article on the same topic to learn about it in more detail. Till then, have a great day!
The post Top MySQL DBA Interview Questions (Part 2) appeared first on iheavy.
Planet MySQL