How to find Cyberpanel MySQL root password?

Question

How to find cyberpanel mysql root password?

Resolution

Cyberpanel is a popular web hosting panel that utilizes Openlitespeed as a web server.

Root password for Cyberpanel MySQL is stored under the following file:

/etc/cyberpanel/mysqlPassword

You may find the password with the following:

cat /etc/cyberpanel/mysqlPassword

Now, if you want to avoid finding and typing the root password every time you run MySQL command, you may do the following

Login to your ssh using the root username.

Make sure you are in the root directory for the user root
# cd

Now create a file called .my.cnf with the following content
# nano .my.cnf

File Content
[client]
user=root
password="fydEAhdoMu9WKW"

Now save the file and try commands like the following:

mysqladmin proc stat

It shall work without asking for a password.

NB. Cyberpanel 2.1.2, they are populating .my.cnf automatically. Hence, you can also find your root password from this file using the following while logged in as root:

cat /root/.my.cnf

How to fix ‘underclocking’ Ryzen (5600x) Processors in OpenVZ 7 / CentOS 7 / OpenVZ 8

Question

My CPU is reporting underclocked eg. 2200Mhz while the actual CPU frequency is much higher (eg 3700Mhz for Ryzen 5600x)

Resolution

This issue appears because by default OpenVZ 7 / CentOS 7 uses a conservative approach to save your power. This approach is implemented using a tool called ‘CPUFREQ’. In OpenVZ 7, you can access this using the command ‘cpupower’.

CPUFreq comes with a set of profiles. There are profiles like ‘conservative’ or ‘ondemand’ which saves power for you by underclocking your CPU, while there is other profile, like ‘performance’ that gives the full power of your CPU.

By default, cpufreq uses ‘conservative’ or ‘ondemand’ profile, which is why you usually see the clock is under the maximum power you have.

To see the available governors or profile you have on your system, you may use the following:

cpupower frequency-info --governors

To see the cpufreq settings, you may see them from:

/sys/devices/system/cpu/[cpuid]/cpufreq/.

Replace cpuid with the CPU number.

Now, to change the underclocking of your CPU to the regular CPU clock, you may use the following command to set the governors to performance:

cpupower frequency-set --governor performance

This shall put your CPU back to 3700Mhz.

How to ‘safely’ delete Mysql relay-bin log file?

Question

My disk is full. When using du, I could see my MySQL log folder is taking up all the disk. These files are not mysql-bin files, instead, these are mysql-relay-bin files. How can I truncate or purge these files?

Answer

Mysql creates mysql-bin files which are called binary files for MySQL on the master side. It then streams the binary files to the replicas to reflect the changes. Mysql doesn’t really store the binaries on the replica side, hence it is safe to delete the relay-bin files. Although, there are other safe strategies to accomplish this or never fall into a situation of ‘out of space’.

Firstly, we need to understand, expire_log_days MySQL attribute doesn’t work for the replica. The reason is simple, it doesn’t store the binary files. Hence, using this is worthless for replicas. You can’t use ‘PURGE’ SQL command either for Replica log purging. Replica has a special attribute ‘relay_log_purge’ which purges the relay-bin logs periodically. You can also set replica to follow a specific size of the log file by using ‘relay_log_space_limit’ attribute.

Now at a very certain time, if you want to free up space, other than gross and brutal deleting relay-bin log files, what you can do is the following:

# start your mysql console session
mysql

# stop the slave
stop slave;
# reset the slave
reset slave;
# now start the slave again
start slave;

Now, once the slave is reset, it will start streaming the bin log from the “pos” it has in its queue to populate the pending jobs.

Once the sync is done, you may check the replica status using:

show slave status \G;

Make sure the following two are set to yes:

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

If not, you should look at the ‘Last_SQL_Error’ or ‘Last_IO_Error’ section to find out why these are not pushing.

Good luck.

Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject – Cyberpanel – CentOS 7

Error details:

After installing cyberpanel, you see the below error from shell when running any command:

** (pkttyagent:8559): WARNING **: 02:28:34.621: Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject
Error registering authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0)

Resolution:

The error is appearing because cybepranel adds the following line in your fstab:

proc    /proc        proc        defaults,hidepid=2    0 0

This is hiding the /proc from your shell that uses polkit. To fix this, keeping the above mount rule, you need to add a group for polkitd user and assign that group to to access /proc. You may do this using the following:

groupadd nohideproc
usermod -a -G nohideproc polkitd
mount -o remount,rw,hidepid=2,gid=nohideproc /proc
systemctl restart polkit
systemctl restart polkit (do this twice)

Once done, you may edit your fstab, and comment the old line, add the following line:

# Edit your fstab:
nano /etc/fstab

# comment the following line :
from : proc    /proc        proc        defaults,hidepid=2    0 0
to : # proc    /proc        proc        defaults,hidepid=2    0 0

# add the following line
proc /proc proc defaults,hidepid=2,gid=nohidproc 0 0

Good luck.

The name org.fedoraproject.FirewallD1 was not provided by any .service files – OpenVZ 7 KVM VM Start Erro

Problem

When starting an Openvz 7 based KVM VM, an error appears with the following:

The name org.fedoraproject.FirewallD1 was not provided by any .service files

How to solve the problem?

Resolution

The error is appearing because OpenVZ 7 expects to have the Firewalld daemon running. If it can’t find it, it will throw the above error and prevent from starting the VM. To solve the problem, just start your firewalld daemon.

service firewalld start

Now if you try to start the VM, it shall start.

PHP Parse error: syntax error, unexpected ‘::’ (T_PAAMAYIM_NEKUDOTAYIM)

Error

When using theme in WordPress, getting an error like the following:

[05-Dec-2021 21:11:48 UTC] PHP Parse error:  syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /home/***/public_html/wp-content/themes/stockholm/framework/admin/options/elements/map.php on line 71

Solution

In Hebrew ‘PAAMAYIM NEKUDOTAYIM’ means double colons. PHP has stopped using a double colon to refer to object elements. These need to use the ‘->’ arrow instead of the ‘::’ double colon. In our case, the issue was with the following:

$icons_instance = stockholm_qode_icon_collections()::getInstance();

This should have been

$icons_instance = stockholm_qode_icon_collections()->getInstance();

Hope this helps.

How to measure the sequential write/read speed of a Hard Disk or SSD?

Question: How to measure the sequential write speed of a hard disk or SSD?

Answer

We may use two ways. The most popular one is to use dd tools. For hard disks, we may not avoid using cache to measure the disk performance. As sequential writes can write the data to the cache, which is basically a DRAM and can perform excessively fast masking the original speed of the HDD. Let’s check how can we measure the HDD speed using dd bypassing HDD write cache:

dd if=/dev/zero of=/hddvz/testfile.img bs=1G count=1 oflag=direct

/hddvz is my HDD mount, oflag=direct instruct the dd to confirm writes to the disk, not just the cache before saying the write is completed.

If it’s a good quality hard disk alone or soft raid 1, you can get speed up to 157-161MBps:

[root@bd3 ~]# dd if=/dev/zero of=/hddvz/testfile.img bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 6.82675 s, 157 MB/s
[root@bd3 ~]#

With a good hardware raid controller and raid 10, you may be able to reach rates like 320MBps.

There is something to remember, software raid mdadm is able to read simultaneously from two disks. You may have the evidence, with two dd one by one, both in background as following:

[root@bd3 ~]# dd if=/dev/zero of=/hddvz/testfile.img bs=1G count=1 oflag=direct &
[1] 12039
[root@bd3 ~]# dd if=/dev/zero of=/hddvz/testfile1.img bs=1G count=1 oflag=direct &
[2] 12040
[root@bd3 ~]# 1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 11.1064 s, 96.7 MB/s
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 10.7155 s, 100 MB/s

[1]-  Done                    dd if=/dev/zero of=/hddvz/testfile.img bs=1G count=1 oflag=direct
[2]+  Done                    dd if=/dev/zero of=/hddvz/testfile1.img bs=1G count=1 oflag=direct

As you can see, both the request was able to reach 100MBps roughly while running in parallel.

Testing Read Speed Using hdparm

To check the read speed, you may use hdparm like the following:

[root@bd3 ~]# hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   40444 MB in  1.99 seconds = 20365.12 MB/sec
 Timing buffered disk reads: 396 MB in  3.06 seconds = 129.43 MB/sec
[root@bd3 ~]# hdparm -Tt /dev/sdb

/dev/sdb:
 Timing cached reads:   41006 MB in  1.99 seconds = 20649.43 MB/sec
 Timing buffered disk reads: 562 MB in  3.01 seconds = 186.81 MB/sec
[root@bd3 ~]#

How to connect CentOS Server to the Internet using USB Wifi Adapter?

I was recently working on an Asus RS300 server, installed with CentOS 7 minimal installation before placing it to the datacenter. I didn’t have any RJ45 cable to get this connected to the internet at home. I had a spare ‘Linksys wusb600n’ USB wifi adapter, that I wanted to try out. I connected it to the USB, and got the interface listed as wlp18s0b1 using ifconfig.

To connect this to wifi, we can use nmcli like the following:

Show the connection:

nmcli connection show

To connect to the wifi with the password, use the following:

nmcli dev wifi connect your-ssid password your-wifi-pass

Remember to replace ‘your-ssid’ with the wifi name of your and ‘your-wifi-pass’ with the password for your wifi.

Once you run the above command, this should get connected to the wifi. Now, you can see the connection details and up the device like the following:

nmcli connection show
nmcli connection up wlp18s0b1

Remember to replace ‘wlp18s0b1’ with the one you can see in ifconfig.

Good luck.

How to Use Memtest+ to Test Your RAM

If you suspect an issue with your system RAM, you should try to use a tool, that will write data in 100% of your RAM and let you know the errors it could get. One such tool available for linux is ‘Memtest+’

How to install memtest+ in CentOS 7

To install memtest+, run the following command in yum:

yum install memtest86+

Now, this will install memtest+ for you. But memtest+ runs the memory test at boot time. To accomplish that, you need to install memtest+ in grub. Memtest+ comes with a command, that does it for you. Run the following to do this:

memtest-setup

This would install the memtest for grub. But you would still need to remake the grub.cfg file for CentOS 7. To do that, run the following:

grub2-mkconfig -o /boot/grub2/grub.cfg

Now, reboot the server and select memtest from the boot screen. Memtest will automatically complete the process and let you know the result on that screen.