I'm running Percona 5.5 on a Centos 6.3. I'm using the prepackaged "huge" my.cnf which ships with percona, it matches my server specs pretty well. My database uses innodb tables. Reading the my.cnf file, there is a section pertaining to innodb:
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
I uncommented the above lines (obviously leaving the actual comments commented), restarted percona and I get the following message:
Starting MySQL (Percona Server). ERROR! The server quit without updating PID file (/var/lib/mysql/rmdb.pid).
I'm new to managing a database server. What benefit is there to uncommenting the above lines, and why does it crash mySQL when I restart when I do?
Thanks
Related
I have a small DB that I use to train my Python ML models. Data is in a collection with 20 mil documents. I accesso to data using this code.
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient['local']
collection = mydb['mydataset']
for i in tqdm(range(len(list_of_companies))):
cursor = collection.find({'company': companies[i]})
dataset_part_df = pd.DataFrame(list(cursor))
dataset_df = pd.concat([dataset_df,dataset_part_df)
del cursor
The PC Mongo and Python are running on has 32 GB or RAM. Mongo is 5.0.6 and is running as a service in Windows 10.
When whole dataset is loaded, Python is using 8 GB or RAM, while "MongoDB Database Server" is using 12 GB of RAM (leaving me with very little free RAM to do any data analysis)
I have already tried setting this parameters in Mongo CGC files:
storage:
dbPath: G:\MongoDB\Server\5.0\data
journal:
enabled: true
wiredTiger:
engineConfig:
cacheSizeGB: 2
wiredTigerCacheSizeGb: 2
directoryForIndexes: true
I have also tried to set "wiredTigerCacheSizeGB" instead of "wiredTigerCacheSizeGb", but nothing is working. Mongo DB just take so much ram.
Thanks a lot in advance to anyone that can help
It is very Noob question about compressing Archive Logs in PostgreSQL 10.
My situation.
Ubuntu 18
postgresql 10
pg_wal - 10Gb
path - /var/lib/postgresql/10/main/pg_wal/
I have a big pg_wal folder right now it is 10 Gg and growing. In pg_wal I saw a very large number journal of files capacity 16mb.
Right now I don't have a capacity.
I read the postgresql manual 25.3.6.2 (gzip)
and I saw two command it is
archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f'
restore_command = 'gunzip < /mnt/server/archivedir/%f > %p'
Can I use the path /var/lib/postgresql/10/main/pg_wal/
in archive_command?
archive_command = 'gzip <%p> /var/lib/postgresql/10/main/pg_wal/%f'.
restore_command = ''gunzip < /var/lib/postgresql/10/main/pg_wal/%f > %p'
Is it a possible or it is stupid idea?
No, you can only archive the WAL segments to a different destination.
First, remove whatever obstacle kept the WAL segments from being deleted:
failing archive_command (check pg_stat_archiver)
abandoned replication slot (check pg_replication_slots)
high wal_keep_segments
Do not manually remove or modify files in pg_wal.
I have pgbouncer.ini file with the below configuration
[databases]
test_db = host=localhost port=5432 dbname=test_db
[pgbouncer]
logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid
listen_addr = 0.0.0.0
listen_port = 5433
unix_socket_dir = /var/run/postgresql
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
#pool_mode = transaction
pool_mode = session
server_reset_query = RESET ALL;
ignore_startup_parameters = extra_float_digits
max_client_conn = 25000
autodb_idle_timeout = 3600
default_pool_size = 250
max_db_connections = 250
max_user_connections = 250
and I have in my postgresql.conf file
max_connections = 2000
does it effect badly on the performance ? because of max_connections in my postgresql.conf ? or it doesn't mean anything and already the connection handled by the pgbouncer ?
one more question. in pgpouncer configuration, does it right listen_addr = 0.0.0.0 ? or should to be listen_addr = * ?
Is it better to set default_pool_size on PgBouncer equal to the number of CPU cores available on this server?
Shall all of default_pool_size, max_db_connections and max_user_connections to be set with the same value ?
So the idea of using pgbouncer is to pool connections when you can't afford to have a higher number of max_connections in PG itself.
NOTE: Please DO NOT set max_connections to a number like 2000 just like that.
Let's start with an example, if you have a connection limit of 20 and then your app or organization wants to have a 1000 connections at a given time, that is where pooler comes into picture and in this specific case you want the 20 connections to pool that 1000 coming in from the application.
To understand how it actually works let's take a step back and understand what happens when you do not have a connection pooler and only rely on PG config setting for the max connections which in our case is 20.
So when a connection comes in from a client\application etc. the main process of postgresql(PID, i.e. parent ID) spawns a child for that. So each new connection spawns a child process under the main postgres process, like so:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24379 postgres 20 0 346m 148m 122m R 61.7 7.4 0:46.36 postgres: sysbench sysbench ::1(40120)
24381 postgres 20 0 346m 143m 119m R 62.7 7.1 0:46.14 postgres: sysbench sysbench ::1(40124)
24380 postgres 20 0 338m 137m 121m R 57.7 6.8 0:46.04 postgres: sysbench sysbench ::1(40122)
24382 postgres 20 0 338m 129m 115m R 57.4 6.5 0:46.09 postgres: sysbench sysbench ::1(40126)
So now once a connection request is sent, it is received by the POSTMASTER process and creates a child process at OS level under the main parent process. This connection then has a life span of "unlimited" unless close by the application or you have a time out set for idle connections in postgresql.
Now here comes the situation where it can be a very costly affair to manage the connections with a given compute, if they exceed a certain limit. Meaning n number of connections when served have a given compute cost and after some time the OS won't be able to handle a situation with HUGE connections and will in turn cause contentions at different compute level(i.e. Memory, CPU, I/O).
What if you can use the presently spawned child processes(backends) if they are not doing any work. You will save time on getting the child process(backends) and the additional cost as well(this can be different at times). This is where the pool of connections that are always open help to serve different client requests comes in and is also called pooling.
So basically now you have only n connections available but the pooler can manage n+i number of connections to serve the client requests.
This where pg-bouncer helps to reuse the connections. It can be configured with 3 types of pooling i.e Session pooling, Statement pooling and Transaction pooling. Basically bouncer returns the connection back to the pool once it has done, statement level work or transaction level work etc. Only during session pooling it keeps the connections unless it disconnects.
So basically lower down the number of connections at PG conf file level and tune all settings in the bouncer.ini.
To answer the second part:
one more question. in pgpouncer configuration, does it right listen_addr = 0.0.0.0 ? or should to be listen_addr = * ?
It depends if you have a standalone deployment, server etc.
basically if its on the server itself and you want it to allow connections from everywhere(incoming) use "*" if you want only the local network to be allowed use "127.0.0.0".
For the rest of your questions check this link: pgbouncer docs
I have tried to share a little of what I know, feel free to ask away if anything was unclear or or correct if it was incorrectly mentioned.
I run a mongodb in docker container, and i have data file backup.
But today I removed my mongodb careless.
I tried to run an another container and put the datafile into the container, but it did not work.
How can I restore my data from the data file?
the database file I only have now:
the container I use is tutum/mongodb.my docker-compose.yml file is
mongo_db:
image: tutum/mongodb
privileged: true
restart: always
ports:
- 27016:27017
- 28016:28017
volumes:
- /var/mongodb:/data/db
environment:
- MONGODB_PASS=xxxxxx
- AUTH=yes
and now I want restore my data from dirctory /var/mongodb to my new container
I put the file except mongod.lock in my new container,but my mongodb can't run.
it's the screenshot:
the mongod.conf is:
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
#port = 27017
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Enable the HTTP interface (Defaults to port 28017).
#httpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Replication Options
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile
the container ower set STORAGE_ENGINE in env while the container start running
the enviroment of the container is:
# mongod.conf
STORAGE_ENGINE=wiredTiger
HOSTNAME=bb544551ec2b
MONGODB_PASS=xxxxxx
LS_COLORS=
AUTH=yes
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/etc
SHLVL=1
HOME=/root
LESSOPEN=| /usr/bin/lesspipe %s
JOURNALING=yes
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/
the logs under tutum/mongodb:3.0:
It depends how you performed your backup.
1 - You took a filesystem snapshot.
=> you can untar your snapshot in your data folder (check on mongod.conf where is located your data folder).
2 - You used mongodump command.
=> you need to use mongorestore command
I am struggling with mongodb and the lack of persistent storage across reboots myself. Reading your post here makes me wonder what this means:
From your mongod.conf:
Disables write-ahead journaling
nojournal = true
and from your environment variable:
JOURNALING=yes
Perhaps your env should be:
NOJOURNAL=false
or
NOJOURNAL=no
(Im also struggling with the markdown here)
I personally was finally able to persist data using this compose section - and by setting an ENV variable NODE_ENV: production (in a different service which was depending on the mongodb service)
image: mongo:4.4
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: something
MONGO_INITDB_ROOT_PASSWORD: otherthanthis
volumes:
- ./mongodata:/data/db:cached
I have the following problem: i am trying to set up a streaming replication scenario with load balancing. I read various tutorials but i cannot find the mistake. The replication does not work. I do not have a "wal sender/receiver process". The archiving works and everytime the master restarts, the archived wal files are copied to the slave. I even do not get any error. And in configuration file(s) everything looks like fine for me, e.g. master:
wal_level = hot_standby
wal_keep_segments = 32
max_wal_senders = 5
max_replication_slots = 5
wal_sender_timeout = 60s
What irritates me the most is that there is no "wal sender process" and there is no error thrown.
Thank you for any idea,
Sven
UPDATE 1: my recovery.conf:
standby_mode = 'on'
primary_conninfo = 'host=arcserver1 port=5432 user=postgres pass=postgres'
restore_command = 'pg_standby /db/pg_archived %f %p >> /var/log/standby.log'
primary_slot_name='standby1'
and my client postgresql.conf contains:
hot_standby = on
I found the solution:i replaced pg_standby with cp, because pg_standby seems to be only for warm standby, not hot standby.