Your database version: 6030000. Required version: 6000000. helm cetic/zabbix - postgresql

Problem description:
I was following the instruction of https://github.com/cetic/helm-zabbix/tree/3.1.1#installation to install zabbix with helm in k8s with below commands but failed to visit the web page of zabbix with the error shown in the below pic
helm repo add cetic https://cetic.github.io/helm-charts
helm repo update
helm show values cetic/zabbix > /Users/xiaojueguan/code/AMD/workplace/docs/infra/zabbix/zabbix_values.yaml
helm upgrade --install zabbix cetic/zabbix \
--dependency-update \
--create-namespace \
-f /Users/xiaojueguan/code/AMD/workplace/docs/infra/zabbix/zabbix_values.yaml -n monitoring --debug
kubectl get pods -n monitoring
Things I tried
login into the postgresql server and set the mandatory db version to 6000000 but failed
k get secrets zabbixdb-pguser-zabbix --template={{.data.password}} | base64 -D
psql -h 10.244.0.151 -U zabbix
use zabbix
update dbversion set mandatory=6030000
flush privileges
change the version of postgresql from 14.4 to 13.8 but no luck
Add some update
In the logic of below, we can see that version is found in the db and the other is defined in the code. As the code side we can not change, maybe we can work on the db side.
maybe the field can be changed
maybe we need use postgresq with certain version
https://github1s.com/zabbix/zabbix/blob/release/6.2/ui/include/classes/db/DbBackend.php#L117-L139
/**
* Check if connected database version matches with frontend version.
*
* #return bool
*/
public function checkDbVersion() {
if (!$this->checkDbVersionTable()) {
return false;
}
$version = DBfetch(DBselect('SELECT dv.mandatory FROM dbversion dv'));
if ($version['mandatory'] != ZABBIX_DB_VERSION) {
$this->setError(_s('The Zabbix database version does not match current requirements. Your database version: %1$s. Required version: %2$s. Please contact your system administrator.',
$version['mandatory'], ZABBIX_DB_VERSION
));
return false;
}
return true;
}
https://github1s.com/zabbix/zabbix/blob/release/6.2/ui/include/defines.inc.php#L25
define('ZABBIX_DB_VERSION', 6020000);

Related

Unable to execute Liquibase update commands via Docker run

I am using docker here to build Liquibase and trying to execute Liquibase commands on fly.
Here is the Dockerfile:-
FROM liquibase/liquibase
RUN lpm add mysql --global
I am using below command on fly
docker run --rm -v ${bamboo.build.working.directory}/:/liquibase/changelog liquibase/liquibase --url="jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema" --changeLogFile=sql/changelog/db.changelog-master.xml --username=username --password=password update
I am getting below error:-
error 04-May-2022 22:08:38 Starting Liquibase at 05:08:38 (version 4.9.1 #1978 built at 2022-03-28 19:39+0000)
error 04-May-2022 22:08:38 Liquibase Version: 4.9.1
error 04-May-2022 22:08:38 Liquibase Community 4.9.1 by Liquibase
error 04-May-2022 22:08:48
error 04-May-2022 22:08:48 Unexpected error running Liquibase: Connection could not be created to jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema with driver org.postgresql.Driver. The connection attempt failed.
Please suggest
From this October 2021 GitHub issue, you need to use single quotes around your JDBC driver URL instead of double-quotes. Try entering it as edited below.
docker run --rm -v ${bamboo.build.working.directory}/:/liquibase/changelog liquibase/liquibase --url='jdbc:postgresql://app-liquibase-test.us-region.rds.amazonaws.com:5432/database?currentSchema=schema' --changeLogFile=sql/changelog/db.changelog-master.xml --username=username --password=password update

IllegalStateException: Can not connect to database. Please check connectivity and settings

CentOS 7
Docker 20.10.5
In my machine run PostgreSQL 9.5 and success open my db:
localhost:5432/sonar
And success open DB by PGAdmin
Nice.
Now in Docker I installed SonarQube 4.5. And want to connect to my db.
I try this:
sudo docker run -e SONARQUBE_JDBC_USERNAME=sonar -e SONARQUBE_JDBC_PASSWORD=sonar -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost:5432/sonar sonarqube:4.5.7
But I get error:
2021.04.20 11:47:55 INFO web[o.s.s.p.ServerImpl] SonarQube Server / 4.5.7 / e2afb0bff1b8be759789d2c1bc9348de6f519f83
2021.04.20 11:47:55 INFO web[o.s.c.p.Database] Create JDBC datasource for jdbc:postgresql://localhost:5432/sonar
2021.04.20 11:47:55 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
at org.sonar.core.persistence.DefaultDatabase.checkConnection(DefaultDatabase.java:115) ~[sonar-core-4.5.7.jar:na]
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:73) ~[sonar-core-4.5.7.jar:na]

Start MongoDb Test Container with credentials

I am able to start the mongo image, insert and read data just fine using the snippet below. Similar to the redis example on testcontainers.org.
private static final int MONGO_PORT = 27017;
#ClassRule
public static MongoDBContainer mongo = new MongoDBContainer("mongo:3.2.4")
.withExposedPorts(MONGO_PORT);
By default mongo doesn't have credentials but I'm looking for a way to set the credentials so that my app's MongoClient can get user/password from system properties and connect properly. I've tried adding the root user/password with the below but that didn't set the credentials properly.
#ClassRule
public static MongoDBContainer mongo = new MongoDBContainer("mongo:3.2.4")
.withExposedPorts(MONGO_PORT)
.withEnv("MONGO_INITDB_ROOT_USERNAME", "admin")
.withEnv("MONGO_INITDB_ROOT_PASSWORD", "admin");
My question is: How can I start the test container with a username and password to allow my app to connect to it during my integration test using wiremock.
Checking the docs you can have a GenericContainer rather than specifically a MongoDbContainer (not certain this makes much difference given it looks largely like I've got the same as what you've already tried)...
I've then run:
private static final int MONGO_PORT = 27017;
/**
* https://hub.docker.com/_/mongo shows:
*
* $ docker run -d --network some-network --name some-mongo \
* -e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
* -e MONGO_INITDB_ROOT_PASSWORD=secret \
* mongo
*/
public static GenericContainer mongo = new GenericContainer(DockerImageName.parse("mongo:4.4.1"));
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("MONGO_INITDB_ROOT_USERNAME=mongoadministrator");
list.add("MONGO_INITDB_ROOT_PASSWORD=secret");
list.add("MONGO_INITDB_DATABASE=db");
mongo.setEnv(list);
mongo.withExposedPorts(MONGO_PORT);
mongo.start();
}
the logs from the container show:
docker logs [container_id]:
...
Successfully added user: {
"user" : "mongoadministrator", <<<<<
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
...
I can login successfully inside the container with my new administrative user:
> docker exec -it 3ae15f01074c bash
Error: No such container: 3ae15f01074c
> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
755e214f23d6 mongo:4.4.1 "docker-entrypoint.s…" 2 seconds ago Up 2 seconds 0.0.0.0:32803->27017/tcp elegant_keldysh
cdb4f55930f4 testcontainers/ryuk:0.3.0 "/app" 3 seconds ago Up 3 seconds 0.0.0.0:32802->8080/tcp testcontainers-ryuk-ef84751e-bfd4-41eb-b381-1c1206186eda
> docker exec -it 755e214f23d6 bash
root#755e214f23d6:/# mongo admin -u mongoadministrator
MongoDB shell version v4.4.1
Enter password: <<<<<<<<<<<<<<<< BAD PASSWORD ENTERED HERE
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Error: Authentication failed. :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
root#755e214f23d6:/# mongo admin -u mongoadministrator
MongoDB shell version v4.4.1
Enter password: <<<<<<<< GOOD PASSWORD secret ENTERED HERE
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("63279398-d9c6-491d-9bd9-6b619dc4a99d") }
MongoDB server version: 4.4.1
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
---
The server generated these startup warnings when booting:
2020-10-24T22:06:24.914+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
---
---
Enable MongoDBs free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
>
In short, you can find working example of test with MongoDB container here.
To provide, more details: you can configure authentication to MongoDB test container by using GenericContainer and setting environment with following properties MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD:
#ClassRule
public static final GenericContainer<?> MONGODB = new GenericContainer<>(DockerImageName.parse(MONGO_IMAGE))
.withEnv("MONGO_INITDB_ROOT_USERNAME", USERNAME)
.withEnv("MONGO_INITDB_ROOT_PASSWORD", PASSWORD)
.withEnv("MONGO_INITDB_DATABASE", TEST_DATABASE)
.withExposedPorts(MONGO_PORT);
Then you should use MongoClient with corresponding MongoCredential. For example, below is the test, that writes and reads document to/from MongoDB container.
#Test
public void shouldWriteAndReadMongoDocument() {
ServerAddress serverAddress = new ServerAddress(MONGODB.getHost(), MONGODB.getMappedPort(MONGO_PORT));
MongoCredential credential = MongoCredential.createCredential(USERNAME, AUTH_SOURCE_DB, PASSWORD.toCharArray());
MongoClientOptions options = MongoClientOptions.builder().build();
MongoClient mongoClient = new MongoClient(serverAddress, credential, options);
MongoDatabase database = mongoClient.getDatabase(TEST_DATABASE);
MongoCollection<Document> collection = database.getCollection(TEST_COLLECTION);
Document expected = new Document("name", "foo").append("foo", 1).append("bar", "string");
collection.insertOne(expected);
Document actual = collection.find(new Document("name", "foo")).first();
assertThat(actual).isEqualTo(expected);
}
Notes:
To find more details on environment variables, you check documentation here (specifically, Environment Variables section)
To find more details on authenticated connection to MongoDB, you check documentation here

CentOS 6.7 and Windows MSSQL connection - FreeTDS and PHP

I searched for answers related to my question but not found what I'm looking for.
I have server with Linux CentOS 6.7. I need to connect to MS SQL Server 2005 on Windows Small Business Server 2003. In CentOS I installed FreeTDS and I managed to connect to SQL Server from terminal using this command:
# TDSVER=7.0 tsql -H ServerIPAdress -p 1433 -U username -P password
As far as I know this command bypass settings in freetds.conf.
Now I need to connect from PHP script. I'm using PDO extension and I tried this DSN string:
$db = new PDO("dblib:version=7.0;host=ServerIPAdress;dbname=Database;","username","password");
This leads me to first error:
Could not find driver
Ok, I understand that - my PHP 5.3.3 installation doesn't have installed PDO driver dblib.
My question: How can I install pdo_dblib driver in CentOS? Many tutorials and answers suggest to install through this command:
yum install php5-sybase
But that package doesn't exist:
No package php-sybase available.
If I check tsql configuration with command
tsql -C
I get these output:
Version: freetds v0.95
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
As I understand I need to configure FreeTDS:
./configure --enable-msdblib --with-pdo-dblib=/usr/local
But how can I configure FreeTDS after instalation? I tried to remove current version but I can't find way to do that. Also I tried to install another version but configuration doesn't change.
Any advice are appreciated.
When I run command # odbcinst -j I can see this output:
unixODBC 2.3.0
DRIVERS ...........: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLSETPOSIROW Size.: 8
Content of my freetds.conf:
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
tds version = 7.0
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 7.0
# A typical Microsoft server
[MSServer]
host = 192.168.1.55
port = 1433
tds version = 7.0
odbcinst.ini:
[FreeTDS]
Description = FreeTDS v7.0
Driver = /usr/local/lib/libtdsodbc.so
UsageCount = 1
odbc.ini:
[MSSQL]
Driver = FreeTDS
Description = MSSQL Server Connection
TDS_Version = 7.0
Trace = No
Server = MSServer
Port = 1433
Database = MyDatabase
Username = DOMAIN\MyUsername
Password = MyPassword
I can make connection with isql command when I specify username and password:
# isql -v MSSQL "DOMAIN\MyUsername" MyPassword
But if I omit username and password isql generate error:
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
I suspect that my username make problems because I have to use DOMAIN name followed by backslash before username when I connect to SQL Server 2005.
UPDATE:
I succesfully made connection in PHP and now I can run queries. I added this line on top of my script: putenv("FREETDSCONF=/usr/local/etc/freetds.conf")
Why is this necessary?

Unable to load Mongodb Driver

I have a Nnginx -FPM php server running on Ubuntu.
I am trying to make the MongoDB Driver for PHP work but some how it never shows in my phpinfo() and every time I run a test script i get Fatal error: Class 'Mongo' not found
The actual MongoDB server is not installed in that server given that I will be connecting to another server.
What am I missing that it doesnt work?
I followed this straight forward steps
1) pecl search mongo
Show the latest 1.4.3 (stable) verion
2) sudo pecl install mongo
3) vim /etc/php5/fpm/php.ini
and at the end of the [dba] tag i add
[Mongo]
extension=mongo.so
4)
service nginx restart
service php5-fpm restart
Check to see if you have mongodb.ini in /etc/php5/conf.d/ The contents should look something like:
extension=mongo.so
mongo.auto_reconnect = true
mongo.allow_persistent = On
mongo.max_persistent = -1
mongo.max_connections = -1
;mongo.default_host = www.example.com
mongo.default_port = 42
mongo.chunk_size = 1024
mongo.cmd = "$"