diff --git "a/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\215\225\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" "b/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\215\225\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..495b964dadb9d586b857b07ca0c973090904b843 --- /dev/null +++ "b/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\215\225\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" @@ -0,0 +1,216 @@ ++++ + +title = "openGauss与PostgreSQL对比测试SSL之自签名CA证书单向认证测试" + +date = "2021-03-31" + +tags = ["openGauss与PostgreSQL对比"] + +archives = "2021-03" + +author = "多米爸比" + +summary = "openGauss与PostgreSQL对比测试SSL之自签名CA证书单向认证测试" + +img = "/zh/post/duomibabi/title/img26.png" + +times = "16:30" + ++++ + +# openGauss与PostgreSQL对比测试SSL之自签名CA证书单向认证测试 + +本文测试自签名CA证书的单向认证: 客户端只验证服务器证书的有效性,而服务器端不验证客户端证书的有效性。服务器加载证书信息并发送给客户端,客户端使用根证书来验证服务器端证书的有效性。 + +## 服务端证书的客户端认证模式 + +客户端SSLMODE设置为verify-ca仅校验数据库证书真伪。 + +客户端SSLMODE设置为verify-full校验数据库证书真伪及通用名CN匹配数据库连接的hostname。 + +## 自签名CA证书单向认证测试 + +**1.创建CA证书** + +CA证书用于给数据库服务器证书签名,同时需要把CA证书发送给数据库客户端,客户端使用CA证书验证数据库服务器证书。 + +``` +$ openssl req -new -x509 -days 365 -nodes \ +-config openssl.cnf \ +-out ca.crt -keyout ca.key -subj "/CN=FooCA" +``` + +**2.生成数据库服务器证书请求文件** + +``` +$ openssl req -new -nodes -text \ +-config openssl.cnf \ +-out server.csr \ +-keyout server.key \ +-subj "/CN=192.168.137.5" +``` + +将证书请求文件\(包含用户信息\)和证书签名分开操作,证书请求文件可重用,因为后面可能需要重新生成签名信息。 + +**3.使用CA证书对证书请求文件签名** + +``` +$ openssl x509 -req -in server.csr -text -days 5 \ +-CA ca.crt \ +-CAkey ca.key \ +-CAcreateserial \ +-out server.crt +``` + +这里设置有效期为5天,可以观察在服务器证书有效期小于7天的时候,连接登录后会在日志中产生告警提醒。 + +**4.传输数据库服务器证书及未加密的私钥文件至数据库服务器** + +修改文件权限以符合安全设置。 + +``` +$ chmod 0600 server.crt server.key +``` + +传输文件到数据库服务器PGDATA目录。 + +``` +$ cp server.crt server.key $PGDATA +``` + +注意:如果PostgreSQL使用-g, --allow-group-access + +开启了组访问权限,则需要拷贝文件到PGDATA目录之外以符合安全设置。 + +**5.数据库SSL参数配置** + +pg\_hba.conf文件配置hostssl条目,认证方法保持md5或者scram不变。 + +``` +hostssl all all 0.0.0.0/0 md5 +``` + +说明:也可以按原来的host连接类型,同时支持非ssl和ssl连接,配置为hostssl只支持hostssl,这里配置为hostssl。 + +postgreql.conf文件配置参数 + +``` +ssl=on +ssl_cert_file= 'server.crt' +ssl_key_file= 'server.key' +``` + +然后重启数据库服务。 + +**6.发送CA证书到数据库客户端** + +本文数据库客户端使用linux下psql,证书文件的默认路径为$HOME/.postgresql/root.crt。 + +``` +cat ca.crt > ~/.postgresql/root.crt +chmod 0600 ~/.postgresql/root.crt +``` + +**测试一** + +数据库客户端未配置证书测试,删除上面第6步的文件。 + +openGauss + +``` +gsql "sslmode=verify-ca" -p6432 -h 192.168.137.5 -Upostgres +gsql: root certificate file "/home/omm/.postgresql/root.crt" does not exist +Either provide the file or change sslmode to disable server certificate verification. +``` + +PostgreSQL + +``` +psql "sslmode=verify-ca" -h192.168.137.11 +psql: error: root certificate file "/home/postgres/.postgresql/root.crt" does not exist +Either provide the file or change sslmode to disable server certificate verification. +``` + +可以看到设置sslmode=verify-ca后,客户端需要验证服务器证书,未配置默认root.crt问题,提示文件不存在,符合预期。 + +**测试二** + +人为修改数据库客户端证书内容。 + +openGauss + +``` +gsql "sslmode=verify-ca" -p6432 -h 192.168.137.5 -Upostgres +gsql: could not read root certificate file "/home/omm/.postgresql/root.crt": too long +gsql "sslmode=verify-ca" -p6432 -h 192.168.137.5 -Upostgres +gsql: could not read root certificate file "/home/omm/.postgresql/root.crt": wrong tag +``` + +PostgreSQL + +``` +psql "sslmode=verify-ca" -h192.168.137.11 +psql: error: could not read root certificate file "/home/postgres/.postgresql/root.crt": +bad base64 decode +psql "sslmode=verify-ca" -p7000 -h192.168.137.11 +psql: error: could not read root certificate file "/home/postgres/.postgresql/root.crt": too long +``` + +可以看到root.crt证书文件内容如果被篡改也是有相应的报错提示,符合预期。 + +**测试三** + +测试验证数据库服务器证书,将正确的证书文件发送至数据库客户端,参考上面第6步配置。 + +openGauss + +``` +gsql "sslmode=verify-ca" -p6432 -h 192.168.137.5 -Upostgres +Password for user postgres: +gsql ((GaussDB Kernel V500R001C20 build ) compiled at 2021-03-09 18:30:51 commit 0 last mr ) +SSL connection (cipher: DHE-RSA-AES128-GCM-SHA256, bits: 128) +Type "help" for help. + +postgres=> +``` + +PostgreSQL + +``` +psql "sslmode=verify-ca" -h192.168.137.11 +Password for user postgres: +psql (12.6) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) +Type "help" for help. + +postgres=# \q +``` + +使用sslmode=verify-ca仅验证服务器证书真伪,符合预期。 + +**测试四** + +测试数据库服务器证书设置的通用名CN是否匹配客户端连接的hostname。 + +openGauss + +``` +gsql "sslmode=verify-full" -p6432 -h opengauss1 -Upostgres +gsql: server common name "192.168.137.5" does not match host name "opengauss1" +``` + +PostgreSQL + +``` +psql "sslmode=verify-full" -hnode11 +psql: error: server certificate for "192.168.137.11" does not match host name "node11" +``` + +分别使用ip地址及主机名测试,与通用名CN匹配的ip地址可成功登录,使用主机名连接报错,报错提示如上,符合预期。 + +## 总结 + +1.数据库服务器证书的客户端认证需要在客户端配置服务器证书签名的CA证书,服务器设置支持hostssl连接,客户端使用sslmode连接参数。 + +2.sslmode连接参数设置为verify-ca仅校验数据库证书真伪,设置为verify-full校验数据库证书真伪及通用名CN匹配数据库连接的hostname。 + diff --git "a/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\217\214\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" "b/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\217\214\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..f6d12f1525bc79a9f8ad6eff3e8d443792e3a638 --- /dev/null +++ "b/content/zh/post/duomibabi/openGauss\344\270\216PostgreSQL\345\257\271\346\257\224\346\265\213\350\257\225SSL\344\271\213\350\207\252\347\255\276\345\220\215CA\350\257\201\344\271\246\345\217\214\345\220\221\350\256\244\350\257\201\346\265\213\350\257\225.md" @@ -0,0 +1,367 @@ ++++ + +title = "openGauss与PostgreSQL对比测试SSL之自签名CA证书双向认证测试" + +date = "2021-03-31" + +tags = ["openGauss与PostgreSQL对比"] + +archives = "2021-03" + +author = "多米爸比" + +summary = "openGauss与PostgreSQL对比测试SSL之自签名CA证书双向认证测试" + +img = "/zh/post/duomibabi/title/img27.png" + +times = "16:30" + ++++ + +# openGauss与PostgreSQL对比测试SSL之自签名CA证书双向认证测试 + +本文测试自签名CA证书的双向认证: 客户端验证服务器证书的有效性,同时服务器端也要验证客户端证书的有效性,只有认证成功,连接才能建立。 + +## 服务端证书的客户端认证模式 + +1.客户端SSLMODE设置为verify-ca仅校验数据库证书真伪。 + +2.客户端SSLMODE设置为verify-full校验数据库证书真伪及通用名CN匹配数据库连接的hostname。 + +## 客户端证书的服务器认证模式 + +1.数据库认证文件pg\_hba.conf配置认证选项clientcert=verify-ca仅验证客户端证书真伪,认证方法可选。 + +2.数据库认证文件pg\_hba.conf配置认证选项clientcert=verify-full验证客户端证书真伪及CN匹配数据库连接用户名或映射匹配,认证方法可选。 + +3.数据库认证文件pg\_hba.conf配置认证方法cert,免密验证客户端证书真伪及CN匹配数据库连接用户名或映射匹配 + +## 自签名CA证书双向认证测试 + +**1.创建CA证书** + +用于给数据库服务器证书签名的CA证书:ca\_server.crt + +``` +$ openssl req -new -x509 -days 365 -nodes \ +-config openssl.cnf \ +-out ca_server.crt -keyout ca_server.key -subj "/CN=FooServerCA" +``` + +用于给客户端证书签名的CA证书:ca\_client.crt + +``` +$ openssl req -new -x509 -days 365 -nodes \ +-config openssl.cnf \ +-out ca_client.crt -keyout ca_client.key -subj "/CN=FooClientCA" +``` + +**2.生成数据库服务器证书请求文件并签名** + +``` +$ openssl req -new -nodes -text \ +-config openssl.cnf \ +-out server.csr \ +-keyout server.key \ +-subj "/CN=192.168.137.5" +``` + +将证书请求文件\(包含用户信息\)和证书签名分开操作,证书请求文件可重用,因为后面可能需要重新生成证书。 + +使用ca\_server.crt对证书请求文件签名 + +``` +$ openssl x509 -req -in server.csr -text -days 5 \ +-CA ca_server.crt \ +-CAkey ca_server.key \ +-CAcreateserial \ +-out server.crt +``` + +这里设置有效期为5天,可以观察在服务器证书有效期小于7天的时候,连接登录后会在日志中产生告警提醒。 + +**3.生成客户端证书请求文件并签名** + +``` +$ openssl req -new -nodes -text \ +-config openssl.cnf \ +-out client.csr \ +-keyout client.key \ +-subj "/CN=dbuser1" +``` + +将证书请求文件\(包含用户信息\)和证书签名分开操作,证书请求文件可重用,因为后面可能需要重新生成证书。 + +使用ca\_client.crt对证书请求文件签名 + +``` +$ openssl x509 -req -in client.csr -text -days 30 \ +-CA ca_client.crt \ +-CAkey ca_client.key \ +-CAcreateserial \ +-out client.crt +``` + +**4.传输数据库服务器证书及未加密的私钥文件至数据库服务器** + +修改文件权限以符合安全设置 + +``` +$ chmod 0600 ca_client.crt server.crt server.key +``` + +传输文件到数据库服务器PGDATA目录 + +``` +$ cp ca_client.crt server.crt server.key $PGDATA +``` + +注意:如果PostgreSQL使用-g, --allow-group-access + +开启了组访问权限,则需要拷贝文件到PGDATA目录之外以符合安全设置。 + +**5.数据库SSL参数配置** + +postgreql.conf文件配置参数 + +``` +ssl=on +ssl_cert_file= 'server.crt' +ssl_key_file= 'server.key' +ssl_ca_file='ca_client.crt' +``` + +然后重启数据库服务。 + +**6.配置数据库客户端** + +客户端使用linux下psql,证书文件的默认路径为$HOME/.postgresql/ + +``` +chmod 0600 client.key client.crt +cp client.crt client.key ~/.postgresql/ +cat ca_server.crt > ~/.postgresql/root.crt +chmod 0600 ~/.postgresql/root.crt +``` + +**测试一** + +pg\_hba.conf文件配置hostssl条目。 + +``` +hostssl all all 0.0.0.0/0 md5 +``` + +测试验证数据库服务器证书 + +openGauss数据库 + +``` +gsql "sslmode=verify-ca" -p6432 -h 192.168.137.5 -Upostgres +Password for user postgres: +gsql ((GaussDB Kernel V500R001C20 build ) compiled at 2021-03-09 18:30:51 commit 0 last mr ) +SSL connection (cipher: DHE-RSA-AES128-GCM-SHA256, bits: 128) +Type "help" for help. + +postgres=> +``` + +PostgreSQL数据库 + +``` +psql "sslmode=verify-ca" -h192.168.137.11 +Password for user postgres: +psql (12.6) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) +Type "help" for help. + +postgres=# \q +``` + +使用sslmode=verify-ca仅验证服务器证书真伪,符合预期。 + +**测试二** + +测试数据库服务器证书设置的通用名CN是否匹配客户端连接的hostname + +openGauss数据库 + +``` +gsql "sslmode=verify-full" -p6432 -h opengauss1 -Upostgres +gsql: server common name "192.168.137.5" does not match host name "opengauss1" +``` + +PostgreSQL数据库 + +``` +psql "sslmode=verify-full" -hnode11 +psql: error: server certificate for "192.168.137.11" does not match host name "node11" +``` + +分别使用ip地址及主机名测试,与通用名CN匹配的ip地址可成功登录,使用主机名连接报错,报错提示如上,符合预期。 + +**测试三** + +测试验证客户端证书 + +pg\_hba.conf文件配置hostssl条目。 + +``` +hostssl all all 0.0.0.0/0 md5 clientcert=verify-ca +``` + +此时数据库连接使用ip地址或者hostname均可连接。 + +openGauss数据库 + +``` +gsql "sslcert=/home/omm/.postgresql/client.crt sslkey=/home/omm/.postgresql/client.key" +-h192.168.137.5 -p6432 -Upostgres +Password for user postgres: +Warning: The client certificate will expire in 29 days. +gsql ((GaussDB Kernel V500R001C20 build ) compiled at 2021-03-09 18:30:51 commit 0 last mr ) +SSL connection (cipher: DHE-RSA-AES128-GCM-SHA256, bits: 128) +Type "help" for help. + +postgres=> +``` + +使用hostname也可连接 + +``` +gsql "sslcert=/home/omm/.postgresql/client.crt sslkey=/home/omm/.postgresql/client.key" +-hopengauss1 -p6432 -Upostgres +``` + +如果使用不正确的客户端证书,比如手工修改client.crt内容,测试会失败。 + +PostgreSQL数据库 + +``` +psql "sslcert=/home/postgres/.postgresql/client.crt sslkey=/home/postgres/.postgresql/client.key" -h192.168.137.11 +Password for user postgres: +psql (12.6) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) +Type "help" for help. + +postgres=# \q +``` + +使用hostname也可连接。 + +``` +psql "sslcert=/home/postgres/.postgresql/client.crt sslkey=/home/postgres/.postgresql/client.key" -hnode11 +Password for user postgres: +psql (12.6) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) +Type "help" for help. + +postgres=# \q +``` + +如果使用不正确的客户端证书,比如手工修改client.crt内容,测试会失败。 + +``` +psql "sslcert=/home/postgres/.postgresql/client.crt sslkey=/home/postgres/.postgresql/client.key" -h192.168.137.11 +psql: error: SSL error: tlsv1 alert unknown ca +FATAL: no pg_hba.conf entry for host "192.168.137.11", user "postgres", database "postgres", SSL off +``` + +分别使用ip地址及主机名测试clientcert=verify-ca选项,测试结果符合预期。 + +**测试四** + +测试验证客户端证书及CN匹配用户或用户映射。 + +pg\_hba.conf文件配置hostssl条目。 + +``` +hostssl all all 0.0.0.0/0 md5 clientcert=verify-full +``` + +此时数据库连接用户必须配置CN中配置的名称dbuser1 + +openGauss数据库 + +``` +gsql "dbname=postgres sslcert=/home/omm/.postgresql/client.crt sslkey=/home/omm/.postgresql/client.key" -h192.168.137.5 -p6432 -Udbuser1 +``` + +上面使用dbuser1可以登录成功,如果使用其他用户也能登录成功。 + +PostgreSQL数据库 + +``` +psql "dbname=postgres sslcert=/home/postgres/.postgresql/client.crt sslkey=/home/postgres/.postgresql/client.key" -h192.168.137.11 -p6000 -Udbuser1 +``` + +上面使用dbuser1可以登录成功,如果使用其他用户比如postgres则会出现下面的错误提示。 + +``` +psql: error: FATAL: password authentication failed for user "postgres" +FATAL: no pg_hba.conf entry for host "192.168.137.11", user "postgres", database "postgres", SSL off +``` + +**测试五** + +测试cert免密认证:验证客户端证书及CN匹配用户或用户映射 + +pg\_hba.conf文件配置hostssl条目。 + +``` +hostssl all all 0.0.0.0/0 cert +``` + +此时数据库连接用户必须配置CN中配置的名称dbuser1,同时不需要输入密码。 + +openGauss数据库 + +``` +gsql "dbname=postgres sslcert=/home/omm/.postgresql/client.crt sslkey=/home/omm/.postgresql/client.key" -h192.168.137.5 -p6432 -Udbuser1 +Warning: The client certificate will expire in 29 days. +gsql ((GaussDB Kernel V500R001C20 build ) compiled at 2021-03-09 18:30:51 commit 0 last mr ) +SSL connection (cipher: DHE-RSA-AES128-GCM-SHA256, bits: 128) +Type "help" for help. + +postgres=> +``` + +上面使用dbuser1用户可直接登录,不需要输入密码,如果使用其他用户比如postgres则会出现下面的错误提示。 + +``` +Warning: The client certificate will expire in 29 days. +gsql: FATAL: certificate authentication failed for user "postgres" +FATAL: no pg_hba.conf entry for host "192.168.137.5", user "postgres", database "postgres", SSL off +``` + +PostgreSQL数据库 + +``` +psql "dbname=postgres sslcert=/home/postgres/.postgresql/client.crt sslkey=/home/postgres/.postgresql/client.key" +-h192.168.137.11 -Udbuser1 +psql (12.6) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) +Type "help" for help. + +postgres=> \q +``` + +上面使用dbuser1用户可直接登录,不需要输入密码,如果使用其他用户比如postgres则会出现下面的错误提示。 + +``` +psql: error: FATAL: certificate authentication failed for user "postgres" +FATAL: no pg_hba.conf entry for host "192.168.137.11", user "postgres", database "postgres", SSL off +``` + +## 总结 + +1.sslmode连接参数设置为verify-ca仅校验数据库证书真伪,设置为verify-full校验数据库证书真伪及通用名CN匹配数据库连接的hostname。 + +2.clientcert认证选项设置为verify-ca仅校验客户端证书真伪,设置为verify-full校验客户端证书真伪及通用名CN匹配数据库用户或用户映射。 + +3.使用clientcert认证选项时,连接类型可以设置为hostssl,但host类型也同时支持hostssl及hostnossl。 + +4.使用cert认证方法只能设置连接类型为hostssl。 + +5.客户端证书clientcert=verify-full认证方式,openGauss与PostgreSQL有差异,参见测试四。 + diff --git a/content/zh/post/gaoyunlong/figures/20210318-61e29181-afd4-44aa-beb1-66959513adef.png b/content/zh/post/gaoyunlong/figures/20210318-61e29181-afd4-44aa-beb1-66959513adef.png new file mode 100644 index 0000000000000000000000000000000000000000..accd2f50d9f9d3e50b390ad8549a433454a6be1d Binary files /dev/null and b/content/zh/post/gaoyunlong/figures/20210318-61e29181-afd4-44aa-beb1-66959513adef.png differ diff --git "a/content/zh/post/gaoyunlong/openGauss\347\233\221\346\216\247\344\271\213exporter\351\203\250\347\275\262.md" "b/content/zh/post/gaoyunlong/openGauss\347\233\221\346\216\247\344\271\213exporter\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..7e687d1ac64322eb05d570e486b61c48fdc67c21 --- /dev/null +++ "b/content/zh/post/gaoyunlong/openGauss\347\233\221\346\216\247\344\271\213exporter\351\203\250\347\275\262.md" @@ -0,0 +1,160 @@ ++++ + +title = "openGauss监控之exporter部署" + +date = "2021-03-31" + +tags = ["openGauss工具"] + +archives = "2021-03" + +author = "高云龙" + +summary = "openGauss监控之exporter部署" + +img = "/zh/post/gaoyunlong/title/img38.png" + +times = "16:30" + ++++ + +# openGauss监控之exporter部署 + +## 概述 + +opengauss\_exporter 是为openGauss数据库量身打造的数据采集工具,配合当前最受欢迎的监控报警框架prometheus + grafana组合实时展示数据库信息,为openGauss数据库的平稳运行保驾护航。opengauss\_exporter同openGauss数据库一样是开源的,源码下载地址:https://gitee.com/enmotech/opengauss_exporter。 + +## 提示 + +- opengauss\_exporter 目前只能通过md5的加密方式访问openGauss数据库。 +- openGauss 出于安全考虑,某些数据非管理员账号无法访问。 +- opengauss\_exporter 直接建立连接到你关注的的数据库,否则会获取不到数据。 + +## 参数介绍 + +``` +# ./opengauss_exporter --help +usage: opengauss_exporter_0318 [] + +Flags: + --help Show context-sensitive help (also try --help-long and --help-man). + --version Show application version. + --url="" openGauss database target url + --config="" path to config dir or file. + --constantLabels="" A list of label=value separated by comma(,). + --disable-cache force not using cache + --auto-discover-databases Whether to discover the databases on a server dynamically. + --exclude-databases="template0,template1" + A list of databases to remove when autoDiscoverDatabases is enabled + --namespace="pg" prefix of built-in metrics, (og) by default + --web.listen-address=":9187" Address to listen on for web interface and telemetry. + --web.telemetry-path="/metrics" + Path under which to expose metrics. + --time-to-string convert database timestamp to date string. + --dry-run dry run and print default configs and user config + --disable-settings-metrics Do not include pg_settings metrics. + --explain explain server planned queries + --parallel=5 Specify the parallelism. the degree of parallelism is now useful query database thread + --log.level="info" Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] + --log.format="logger:stderr" Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true" +``` + +## 数据库配置 + +**修改参数** + +openGauss默认加密方式是sha256,需要改成md5的密码加密方式。 + +方式一:直接修改postgresql.conf参数文件 + +``` +password_encryption_type=1 +``` + +重新加载数据库 + +``` +gsql -p $port postgres -r -c “select pg_reload_conf();” +``` + +方式二:使用集群管理工具 + +``` +gs_guc reload -I all -N all -c "password_encryption_type=1" +``` + +**创建数据库** + +数据库兼容PG模式,在PG数据库中’’ != null + +``` +create database ogexporter DBCOMPATIBILITY='PG'; +``` + +**创建用户** + +- 1.0.1版本的数据库,创建用户需要带有sysadmin权限。 +- 1.1.0版本的数据库,创建用户需要带有monadmin权限的。 +- 密码复杂度需要符合数据库密码策略。 + +``` +CREATE USER opengauss_exporter WITH PASSWORD 'opengauss_exporter123' MONADMIN; +``` + +**赋权** + +根据需要采集数据所在的表或视图,给相应的访问权限。 + +``` +grant usage on schema dbe_perf to opengauss_exporter; +grant select on pg_stat_replication to opengauss_exporter; +``` + +**访问控制** + +将opengauss\_exporter部署服务器的ip地址以md5的加密方式加入白名单; + +如果是部署在本地服务器,需要以md5的方式添加在host all all 127.0.0.1/32 trust前面, + +否则会有FATAL:Forbid remote connection with trust method! 报错 + +方式一:直接修改pg\_hba.conf文件,不需要加载 + +``` +host dbname opengauss_exporter x.x.x.x/32 md5 +``` + +方式二:使用管理工具 + +``` +gs_guc reload -I all -N all -h "host dbname opengauss_exporter x.x.x.x/32 md5" +``` + +## 安装部署 + +**配置环境变量** + +将以下配置添加到~/.bashrc 文件,也可以在每次执行命令前执行。 + +``` +export DATA_SOURCE_NAME="host=x.x.x.x user=opengauss_exporter password=opengauss_exporter123 port=9832 dbname=og_pg sslmode=disable" +``` + +**启动opengauss\_exporter** + +将编译好的二进制文件opengauss\_exporter 放到目录/opt/opengauss\_exporter/下,以nohup的方式启动。 + +``` +nohup /opt/opengauss_exporter/opengauss_exporter --config="/opt/opengauss_exporter/default_queries.yaml" --log.level=debug & +``` + +## 检验 + +确保防火墙关闭,如果防火墙打开,则需要开通9187端口。 + +在浏览器输入服务器ip及exporter 端口号,如:http://127.0.0.1:9187//metrics + +展示效果如下: + +![](../figures/20210318-61e29181-afd4-44aa-beb1-66959513adef.png) + diff --git "a/content/zh/post/shine/openGauss\345\215\207\347\272\247\346\214\207\345\257\274\344\271\246.md" "b/content/zh/post/shine/openGauss\345\215\207\347\272\247\346\214\207\345\257\274\344\271\246.md" index ca7f724b9a29efa008542ebdabcc101f0f5ddeaa..7f5c8c7eb5f55b46c185cb31afe8683743bf3778 100644 --- "a/content/zh/post/shine/openGauss\345\215\207\347\272\247\346\214\207\345\257\274\344\271\246.md" +++ "b/content/zh/post/shine/openGauss\345\215\207\347\272\247\346\214\207\345\257\274\344\271\246.md" @@ -113,7 +113,6 @@ openGauss升级版本要求如[表1](#table7961729)所示。 - 升级过程中如果系统表新增了字段,升级后通过**\\d**命令将查看不到这些新增的字段。此时通过**select**命令可以查到这些新增的字段。 - 升级需要guc参数enable\_stream\_replication=on,该参数为off时不允许升级。 - 灰度升级中,业务并发要小于200并发读加200并发写的情况。 -- 一主多备的集群,在升级到openGauss1.1.0之后的版本后,如果修改了配置文件中的listen_addresses为“\*”,则需要修改对应的replconninfo1,......replconninfo\*中的localport的值为原有的值再加5,例如,原有的值为16000,现在需要修改为16005,否则会导致重启集群失败。 # # 升级