Oracle Enterprise Manager Cloud Control 13c Release 5
Installation on Red Hat Enterprise Linux Server release 8.8
PURPOSE:All documents are provided on this Blog just for educational purposes only. Please make sure that you run it in your test environment before to move on to production environment.
Those are basic steps for the OS level. You may need or not. It depends on your environment.
You do not need to setup environment for Oracle_home and ASM and OEM. When the Installation completed then you can set it up.
You can download the Installation files from the Link Download
Step 1: Create a Database First
In my case, I have the following databases created:
EMCMDB
EMREP
Connect to the database to EMCMDB and execute the following commands:
Step 2: Configure the Database (EMCMDB)
Connect to the EMCMDB database and execute the following commands:
sql
SQL>alter system set"_allow_insert_with_update_check"=true scope=both;SQL>alter pluggable database EMREP save state;
Pluggable database altered.SQL>show parameter session_cached_cursors;
NAME TYPEVALUE------------------------------------ ----------- ------------------------------
session_cached_cursors integer50SQL>alter system set session_cached_cursors=500 scope=spfile;
System altered.
SQL>show parameter shared_pool_size;
NAME TYPEVALUE------------------------------------ ----------- ------------------------------
shared_pool_size big integer0SQL>alter system set shared_pool_size=600M scope=spfile;
System altered.
Step 3: Configure the OS Firewall
The following commands are required to be executed at the OS level to open the necessary ports:
Install MySQL 9.7 on Ubuntu 24.04 Master Slave Setup
Title: How to Install MySQL 9.7 on Ubuntu 24.04 and Move Data Directory to a Custom Location
Introduction
This guide walks you through installing MySQL 9.7 from the official community bundle on Ubuntu 24.04, and then moving the database storage to a separate disk or custom folder (e.g., /mysql9.7). This is useful when you want to separate database files from the root filesystem.
Following topics are covered:
Part 1: Prepare the Disk for MySQL Part 2: Download and Extract the MySQL Bundle Part 3: Install MySQL Packages Part 4: Move MySQL Data Directory to a Custom Location Part 5: Configure AppArmor Permissions Part 6: Start MySQL and Verify Part 7: Prepare the Replica Directories Part 8: Configure AppArmor for the Replica Part 9: Configure the Primary (Master) Instance Part 10: Create the Replica (Slave) Configuration Part 11: Initialize the Replica Data Directory Part 12: Launch the Replica Daemon Part 13: Create a Replication User on the Primary Part 14: Link the Replication Channels Part 15: Test the Replication Part 16: Test the Read-Only Rule on the Replica Part 17: Stop the Slave Database Part 18: Create a Systemd Service for the Replica Part 19: Move MySQL Data Directory to Custom Subdirectories Part 20: Change the MySQL Password Policy
Part 21: Useful Commands for Slave Database Management
Prerequisites
Ubuntu 24.04 server
Root or sudo privileges
An additional disk (e.g., /dev/sdb) if you want to store data on a separate drive
PURPOSE:All documents are provided on this Blog just for educational purposes only. Please make sure that you run it in your test environment before to move on to production environment.
Step 1: Prepare the Disk (Optional)
If you want to use a dedicated disk for MySQL data, follow these steps.
Check available disks:
fdisk -l
Create a new partition on /dev/sdb:
fdisk /dev/sdb
n
p
w
Format the partition with XFS:
mkfs.xfs /dev/sdb1
blkid /dev/sdb1
Copy the UUID from the blkid output, then edit /etc/fstab:
Ubuntu uses AppArmor to restrict software from accessing non-standard folders. If you skip this step, MySQL will fail to start.
Edit the AppArmor profile for MySQL:
sudo nano /etc/apparmor.d/usr.sbin.mysqld
Find the lines that reference /var/lib/mysql/. Add these two lines right below them:
/mysql9.7/ r,
/mysql9.7/** rwk,
Reload AppArmor to apply the new rules:
sudo systemctl reload apparmor
Step 6: Start MySQL and Verify
Start the MySQL service:
systemctl start mysql
Log in to MySQL:
mysql -u root -ptesttest
Check the data directory:
SELECT @@datadir;
You should see /mysql9.7/ as the output.
Introduction
This guide shows you how to configure a MySQL primary (master) and replica (slave) instance on the same physical host. This setup is useful for testing replication, learning MySQL internals, or running a local development environment without needing multiple servers.
We will use:
Primary instance: port 3306, data directory /var/lib/mysql (default)
Replica instance: port 3307, data directory /mysqlslave/data
Prerequisites
MySQL 9.7 already installed (see previous guide)
Root or sudo privileges
AppArmor enabled (default on Ubuntu)
Step 1: Prepare the Replica Directories
Create the folder structure for the slave instance:
mysql -u root -P 3307 --socket=/mysqlslave/run/mysqld.sock
Configure the replica to connect to the primary:
text
CHANGE MASTER TO
MASTER_HOST='127.0.0.1',
MASTER_PORT=3306,
MASTER_USER='repl',
MASTER_PASSWORD='replpassword',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=157;
Replace the MASTER_LOG_FILE and MASTER_LOG_POS values with the ones you noted from SHOW MASTER STATUS on the primary.
Start the replication:
text
START SLAVE;
Check the replication status:
text
SHOW SLAVE STATUS\G
Look for these two lines:
text
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
If both show Yes, replication is working.
Step 9: Test the Replication
On the primary (port 3306), create a test database:
text
CREATE DATABASE test_replication;
USE test_replication;
CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO test_table VALUES (1, 'Hello Replication');
On the replica (port 3307), verify the data was replicated:
text
SHOW DATABASES;
USE test_replication;
SELECT * FROM test_table;
You should see the same data on the replica.
Troubleshooting Tips
If Slave_IO_Running is No, check the error log at /mysqlslave/logs/error.log.
If AppArmor blocks access, verify the rules in /etc/apparmor.d/usr.sbin.mysqld and reload AppArmor.
Ensure the repl user is allowed to connect from 127.0.0.1 (use 'repl'@'%' if needed for remote hosts).
If the replica fails to start, check that the mysql user owns all files in /mysqlslave.
Title: MySQL Replica Management, Read-Only Rules, Systemd Service, and Data Directory Relocation
Introduction
This guide covers advanced MySQL replica (slave) management tasks, including enforcing read-only rules, creating a systemd service for the replica, relocating the data directory to custom subdirectories, changing password policies, and useful replication commands. It is a continuation of the MySQL master-slave setup guide.
Part 1: Test the Read-Only Rule on the Replica
By default, the read_only parameter does not apply to users with the SUPER privilege (such as root). This means root can still write to a replica unless you enforce super_read_only.
Try to insert data as root on the replica:
text
INSERT INTO employees (first_name, department) VALUES ('Eve', 'Malicious');
If this succeeds, you need to enforce stricter read-only rules.
Temporary Fix (Runtime)
Run this on the replica:
text
SET GLOBAL super_read_only = 1;
Now if you try to insert data as root, you will get:
text
ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement
Permanent Fix (Configuration File)
Edit the replica configuration:
text
sudo nano /etc/mysql/my_slave.cnf
Find the line read_only = 1 and add this line right below it:
text
read_only = 1
super_read_only = 1
Save and exit, then restart the replica.
Part 2: Stop the Slave Database
You can stop the replica using MySQL or Linux process control.
Method 1: Using MySQL SHUTDOWN
text
mysql -u root -P 3307 --host=127.0.0.1
SHUTDOWN;
Method 2: Using the Linux Process Control Approach
text
sudo kill $(cat /mysqlslave/run/mysqld.pid)
Verify it has stopped:
text
ss -tulpn | grep 3307
If no output appears, the replica has stopped successfully.
Part 3: Create a Systemd Service for the Replica
Instead of launching the replica manually in the background, create a proper systemd service so it starts automatically and is managed by the system.
Part 4: Move MySQL Data Directory to Custom Subdirectories
This section shows how to relocate the main MySQL data directory and its related files (binlogs, undo logs, error logs, relay logs) to a custom location with separate subdirectories.