Category: Database

  • Tuning performance Mariadb/ MySQL

    Add more config (maybe at /etc/my.cnf.d/server.conf): With a powerful server, can adjust I/O: How to find the good innodb_buffer_pool_size number? Here is Recommended InnoDB Buffer Pool Size: Or adjust more 10%: After your DB run with new config in a period time (daily, weekly,…), check how many memory in used. This Data_MB number can be…

  • Count the usage size of Mariadb/MySQL

    Query: Result:

  • Write Error Logs only in mongodb.log

    Write Cron Job as below Change example by your path

  • Create MongoDB cluster with 3 nodes

    Edit /etc/hosts file in 3 nodes, add with 3 node ips: In terminal, set root password: Create ssl key then COPY folder to all members for same key. Disable THP: Edit file /etc/mongod.conf, add: Restart mongod for all nodes: Connect to primary node (node 1) with your yourRootPassword Setup replication: Check it: Create new user…

  • Create Redis Cluster with few steps

    With 3 computers (10.5.10.1, 10.5.10.2, 10.5.10.3). My example is Rocky Linux/ Centos Step 1: Install Redis on computer Step 2: Edit /etc/redis.conf: Step 3: Open Firewall on 7001 & 17001 (7001+10000): Step 4: Run Redis Server with command: Repeat all steps above on other computer with other port (7002, 7003) Step 5: Create cluster Open…

  • MongoDB error: child process failed, exited with error number

    Check all path in /etc/mongod.conf. If files or folders not exist, create them then:

  • Store compressed data in MongoDB and decompress it

    Storing compressed data in MongoDB and decompressing it is a necessary task when you store large data files like Logs. Database schema Interface Upload Controller Method: POST – ‘multipart/form-data‘ Field name: file Type: Use .zip file for lightweight Allows to use multiple text files in a zip file Upload Service Input: file Extract the zip…

  • MongoServerError: Plan executor error during findAndModify :: caused by :: E11000 duplicate key error collection [Solved]

    Tips for “MongoServerError: Plan executor error during findAndModify :: caused by :: E11000 duplicate key error collection“. Mongo duplicate when findAndModify(), same for findOneAndUpdate() Don’t try to query the dynamic field with the upsert option! The same problem will occur when querying multiple conditions (include some not unique fields), while turn on option upsert=true. This…

  • MariaDB / MySQL write and read Log files on Centos / Rocky Linux

    By default, mariaDB never write logs hers for you. Sure, it’s her privacy that she doesn’t want others to know. However, you can enable her logging like this: Make your logs folder and change permission: Edit this file /etc/my.cnf.d/server.conf or /etc/my.cnf.d like as below: Restart your mariadb: Now, you have three file: /var/log/mariadb/error.log /var/log/mariadb/mysql.log /var/log/mariadb/slow.log…

  • Error: MySQL server has gone away

    “MySQL server has gone away”: This is an error when you tried to import a large file to MySQL/MariaDB. So, you can temporatly set max_allowed_packet by below guide: Your file size (MB): X Your file size (bytes): Y = X*1024*1024. Example: X = 2GB => Y = 2,097,152,000,000 Your import commands likes this: