Cloud Guru Online

We simplify everything!

Mounting a Google Cloud Storage bucket into CentOS/Ubuntu/Debian server

Step 1: Create a GCP Cloud Storage bucket

In navigation menu at top left, Storage >> Buckets >> Click on Create

Name your bucket Pick a globally unique, permanent name -- You can use underscore to get unique names example : google_custom_bucket_2023 
Choose where to store your data -- select Region and a location of your choice.
Choose a storage class for your data - Select Coldline
(more details on storage classes https://cloud.google.com/storage/docs/storage-classes)
Choose how to control access to objects --- Keep Default
Choose how to protect object data  --- Keep Default

Step 2: Add a service account that needs to have access to that bucket

Navigation Menu (Top left) >> IAM & Admin >> Service Accounts >> Create Service Account

Add a unique name, and press Create
In the grant service account access step, select Cloud Storage > Storage Object Admin
Skip grant user step

Now locate the created service account from the list, and click the three dots under Actions, and select Create Key , in dialog box, select JSON (this is the default option selected) and click create. A json file will get downloaded to your computer.

Step 3: Install GCSFuse on the server

Installing on Ubuntu / Debian

export GCSFUSE_REPO=gcsfuse-lsb_release -c -s
echo “deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main” | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –
sudo apt-get update
sudo apt-get install gcsfuse

Installing for RHEL/CentOS

sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF
[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

sudo yum install -y gcsfuse

Step 4: Mount the bucket

Upload the json file to safe location in server example /root
Create mount point “mkdir /backup/newbackup”

Run below command:

gcsfuse --key-file /root/steady-grid-2354105-96908911eed7.json google_custom_bucket_2023 /backup/newbackup

The result will be:

[root@backup ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.1G 0 3.1G 0% /dev
tmpfs 3.1G 0 3.1G 0% /dev/shm
tmpfs 3.1G 49M 3.1G 2% /run
tmpfs 3.1G 0 3.1G 0% /sys/fs/cgroup
/dev/sda2 55G 7.5G 48G 14% /
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/sdb1 4.0T 3.8T 154G 97% /backup
tmpfs 631M 0 631M 0% /run/user/0
google_custom_bucket_2023 1.0P 0 1.0P 0% /backup/newbackup

Now you can simply copy files/folders to /backup/newbackup, it will be automatically uploaded to Google cloud storage.

If you face any issues, please let me know in the comments sections.

Change mail IP

If your primary IP of the server is blacklisted or having poor reputation, the emails send from you can end up in recipients spam folder. Un til you get the IP issue sorted, you can change the Exim’s mail sending IP to another fresh IP preset in the server.

1.Edit /etc/mailips.

If you wish to change the IP for all domains in the server, add
*: new_IP
If you wish to change the IP for only one domain, add
domains.com : new_IP

2. Enable “Reference /etc/mailips for outgoing SMTP connections” in WHM >> Exim Configuration

3. Enable “Allow users to relay mail if they use an IP address through which someone has validated an IMAP or POP3 login within the last hour (Pop-before-SMTP)” in WHM >> Tweak Settings

4. Modify the domain’s SPF record to include the new IP.

5. Restart Exim

MySQL temp directory full

In such situations, you will have to change the MySQL’s tmpdir.

  1. Create the new temp directory

mkdir /var/lib/mysql/tmp
chmod 1777 /var/lib/mysql/tmp

  1. Make the new folder as the tmpdir by adding the below to server’s /etc/my.cnf

tmpdir = /var/lib/mysql/tmp

  1. Restart mysql

service mysqld restart

MySQL – Convert all tables from MyISAM to InnoDB

1. Convert the engine using the below command and dump the database.

mysql -e "SELECT concat('ALTER TABLE ', TABLE_NAME,' ENGINE=InnoDB;') FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'successc_wordpress' AND ENGINE = 'MyISAM' AND TABLE_TYPE = 'BASE TABLE'" | tail -n+2 >> alter.sql

2. Restore the dump created above to the original database.

mysql original_database < alter.sql