HHeLiBeXの日記 正道編

Web Name: HHeLiBeXの日記 正道編

WebSite: http://hhelibex.hatenablog.jp

ID:67358

Keywords:

正道,HHeLiBeX,日記,

Description:

# yum list postgresql* | grep ^postgresql[0-9]*[.] postgresql.x86_64 8.4.20-8.el6_9 @updates postgresql.i686 8.4.20-8.el6_9 base postgresql10.x86_64 10.13-1PGDG.rhel6 pgdg10 postgresql11.x86_64 11.8-1PGDG.rhel6 pgdg11 postgresql12.x86_64 12.3-1PGDG.rhel6 pgdg12 postgresql95.x86_64 9.5.22-1PGDG.rhel6 pgdg95 postgresql96.x86_64 9.6.18-1PGDG.rhel6 pgdg96 # yum list postgresql* | grep ^postgresql[0-9]*[.] postgresql.x86_64 9.2.24-1.el7_5 @updates postgresql.i686 9.2.24-4.el7_8 updates postgresql.x86_64 9.2.24-4.el7_8 updates postgresql10.x86_64 10.13-1PGDG.rhel7 pgdg10 postgresql11.x86_64 11.8-1PGDG.rhel7 pgdg11 postgresql12.x86_64 12.3-5PGDG.rhel7 pgdg12 postgresql95.x86_64 9.5.22-1PGDG.rhel7 pgdg95 postgresql96.x86_64 9.6.18-1PGDG.rhel7 pgdg96 # yum list postgresql* | grep ^postgresql[0-9]*[.] postgresql.x86_64 10.6-1.module_el8.0.0+15+f57f353b @AppStreamあれ、CentOS 8だけ、標準版以外が見つかりません。もう一度。# less /etc/yum.repos.d/pgdg-redhat-all.repo# yum list --disablerepo= AppStream --enablerepo= pgdg* postgresql* | grep ^postgresql[0-9]*[.] postgresql.x86_64 10.6-1.module_el8.0.0+15+f57f353b @AppStream postgresql10.src 10.13-1PGDG.rhel8 pgdg10-source postgresql10.x86_64 10.13-1PGDG.rhel8 pgdg10 postgresql11.src 11.8-2PGDG.rhel8 pgdg11-source postgresql11.src 11.8-2PGDG.rhel8 pgdg11-source-updates-testing postgresql11.x86_64 11.8-2PGDG.rhel8 pgdg11 postgresql11.x86_64 11.8-2PGDG.rhel8 pgdg11-updates-testing postgresql12.src 12.3-5PGDG.rhel8 pgdg12-source postgresql12.src 12.3-5PGDG.rhel8 pgdg12-source-updates-testing postgresql12.x86_64 12.3-5PGDG.rhel8 pgdg12 postgresql12.x86_64 12.3-5PGDG.rhel8 pgdg12-updates-testing postgresql13.x86_64 13-beta1_2PGDG.rhel8 pgdg13-updates-testing postgresql94.src 9.4.26-1PGDG.rhel8 pgdg94-source postgresql94.x86_64 9.4.26-1PGDG.rhel8 pgdg94 postgresql95.src 9.5.22-1PGDG.rhel8 pgdg95-source postgresql95.x86_64 9.5.22-1PGDG.rhel8 pgdg95 postgresql96.src 9.6.18-1PGDG.rhel8 pgdg96-source postgresql96.x86_64 9.6.18-1PGDG.rhel8 pgdg96 # yum -y install --disablerepo= AppStream --enablerepo= pgdg12 postgresql12-serverちなみに、CentOS 7でのインストール中に以下のようなエラーが出ますが、今回は無視します。標準版が入っているせいなので。シンボリックリンク /usr/bin/psql - /etc/alternatives/pgsql-psql の作成に失敗しました。 /usr/bin/psql がすでに存在しており、シンボリックリンクファイルではありません。 : データベース一覧 名前 | 所有者 | エンコーディング | 照合順序 | Ctype(変換演算子) | アクセス権限 -----------+----------+------------------+-------------+-------------------+-----------------------postgres | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 |template0 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgrestemplate1 | postgres | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres(3 行)postgres=# \q データベース一覧 名前 | 所有者 | エンコーディング | 照合順序 | Ctype(変換演算子) | アクセス権限 -----------+----------+------------------+------------+-------------------+-----------------------postgres | postgres | UTF8 | ja_JP.utf8 | ja_JP.utf8 |template0 | postgres | UTF8 | ja_JP.utf8 | ja_JP.utf8 | =c/postgres + | | | | | postgres=CTc/postgrestemplate1 | postgres | UTF8 | ja_JP.utf8 | ja_JP.utf8 | =c/postgres + | | | | | postgres=CTc/postgres(3 行)postgres=# \qちなみに、多くの記事で「rpms.famillecollet.com」からインストールする例を見ましたが、2020年6月15日現在、ここではミラーされていないようで、本家へのリダイレクトになっています。Remiリポジトリの追加上記のサイトでミラーサイトを確認し、適当なところから選び出します。日本では「http://ftp.riken.jp/Linux/remi/」が提供されているので、今回はそこを利用します。まず、EPELが必要となるので、その追加から。# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmこちらは標準リポジトリで提供されているので。# yum -y install epel-release# yum -y install http://ftp.riken.jp/Linux/remi/enterprise/remi-release-6.rpm# yum -y install http://ftp.riken.jp/Linux/remi/enterprise/remi-release-7.rpm# yum -y install http://ftp.riken.jp/Linux/remi/enterprise/remi-release-8.rpmphp.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStreamphp.x86_64 7.2.11-2.module_el8.1.0+209+03b9a8ff AppStreamphp56.x86_64 3.0-1.el8.remi remi-safephp70.x86_64 2.0-1.el8.remi remi-safephp71.x86_64 2.0-1.el8.remi remi-safephp72.x86_64 2.0-1.el8.remi remi-safephp73.x86_64 2.0-1.el8.remi remi-safephp74.x86_64 1.0-3.el8.remi remi-safephp80.x86_64 1.0-3.el8.remi remi-safeCopyright (c) 1997-2010 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend TechnologiesPHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20)Copyright (c) 1997-2013 The PHP GroupZend Engine v2.4.0, Copyright (c) 1998-2013 Zend TechnologiesPHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies# ls -1 /etc/httpd/conf.modules.d/*php*/etc/httpd/conf.modules.d/10-php56-php.conf/etc/httpd/conf.modules.d/15-php.confCentOS 8では「10-php56-php.conf」のLoadModuleが先に実行されるのでPHP 5.6が走りますが、CentOS 6/7では標準版のLoadModuleが先に実行されるので、注意しておかないと、どれが実行されているのか分からなくなります。最後に、php.ini の位置も確認しておきましょう。# /usr/bin/php56 -i 2 /dev/null | grep php.ini$ Loaded Configuration File = /opt/remi/php56/root/etc/php.ini よりにもよって繁忙期に、以下のROOT証明書期限切れで接続不可になるというトラブルに見舞われ、なんじゃゴルァ!と叫びながら対応した記憶の記録。状況としては、WinSCPだと(証明書のCNがホスト名と違うってエラーが出るけど(ボソッ))接続できるが、Javaプログラムやlftpコマンドだと証明書の期限切れだと怒られる事案。ひとまず、以下の情報を頼りに証明書チェインの情報を取ってみた。$ openssl s_client -connect xxxxx.com:21 -starttls ftp -showcerts /dev/null hoge.txt hoge.txt の中にある証明書4つを分割して別ファイルに保存$ openssl x509 -text -in 3.txt -noout Validity Not Before: May 30 10:48:38 2000 GMT Not After : May 30 10:48:38 2020 GMT Subject: C=US, ST=New Jersey, L=Jersey City, O=The USERTRUST Network, CN=USERTrust RSA Certification Authority$ openssl x509 -text -in 4.txt -noout Validity Not Before: May 30 10:48:38 2000 GMT Not After : May 30 10:48:38 2020 GMT Subject: C=SE, O=AddTrust AB, OU=AddTrust External TTP Network, CN=AddTrust External CA Root :import java.security.cert.CertificateException;import java.security.cert.X509Certificate;import javax.net.ssl.TrustManager;import javax.net.ssl.X509TrustManager;import org.apache.commons.net.ftp.FTPSClient;public class Main { public static void main(String[] args) { FTPSClient client = new FTPSClient( TLS , false); TrustManager tm = new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { client.setTrustManager(tm); try { client.connect( example.com , 21); } catch (IOException e) { e.printStackTrace();Java HttpsURLConnectionで、証明書エラーを無視して接続する - Symfowareimport java.security.KeyManagementException;import java.security.NoSuchAlgorithmException;import java.security.cert.CertificateException;import java.security.cert.X509Certificate;import javax.net.ssl.HttpsURLConnection;import javax.net.ssl.SSLContext;import javax.net.ssl.TrustManager;import javax.net.ssl.X509TrustManager;public class Mail { public static void main(String[] args) { TrustManager[] tm = { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } }; try { SSLContext sslcontext = SSLContext.getInstance( SSL ); sslcontext.init(null, tm, null); URL connectUrl = new URL( https://exaple.com/ ); HttpsURLConnection urlconn = (HttpsURLConnection) connectUrl.openConnection(); urlconn.setSSLSocketFactory(sslcontext.getSocketFactory()); urlconn.connect(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); 歳を取ると、いろんな形式の証明書ファイルや、サーバーにアクセスしての証明書の検証方法など、コマンドをすぐに忘れて、そのたびにググるということを繰り返しているので、とりあえず思いついたものを整理しておくテスト。用語などは適当かもですが、その辺はご容赦を・・・PEM形式の証明書以下のような形式のファイルです。-----BEGIN CERTIFICATE----------END CERTIFICATE-----Let's Encryptのcertbotで生成した証明書の表示コマンド例。openssl x509 -text -noout /etc/letsencrypt/live/xxx/cert.pemopenssl x509 -text -noout /etc/letsencrypt/live/xxx/chain.pem例えば「/etc/pki/java/cacerts」とか「/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64/jre/lib/security/cacerts」に置いてあるファイルです。keytool -storepass changeit -list -keystore /etc/pki/java/cacertsTomcatなんかで使いますね。そもそもTomcatをフロントエンド(略)keytool -storepass changeit -list -v -storetype PKCS12 -keystore hoge.p12openssl pkcs12 -in ssl/ks-lets202003.p12 -nodes -passin pass:changeit | openssl x509 -textサーバー証明書チェインの確認実際にサーバーにアクセスして、証明書チェインに問題がないかを確認する方法です。cat /dev/null | openssl s_client -connect server_host_name:443 -showcertscat /dev/null | openssl s_client -connect server_host_name:21 -starttls ftp -showcerts そもそも、静的型付けでない言語は好きではないのですが、好き嫌いを言っていると仕事が無くなってしまうので・・そんなわけで、Eclipse(PDT)でPHPのコードを書くわけですが、時にあるクラスのインスタンスの配列を関数/メソッドに渡す形にしたい時があります。 ?phpclass A { * ID * @var int public $id; * 名前 * @var string public $name; // A のインスタンスである保証がないし、 // Eclipseで変数名候補を表示させたりできない(重要!!) var_dump($aa- name);この時、関数「a0」内の変数「$aa」が何であるかという保証は何もありませんので、何らかのチェックをする必要があります。PHPにはtype hintingという機能があり、以下のように書ければいいのですが・・ ?php// 実際にはエラーになるfunction a0(A[] $a) { // ・・・そんなわけで、Eclipse(PDT)をだますために、ひと工夫したりします。instanceofで判定する ?phpfunction a1(array $a) { foreach ($a as $aa) { if ($aa instanceof A) { var_dump($aa- name);こうすると、「$aa」はクラスAのインスタンスであることが保証されるので、Eclipse(PDT)がそれを解釈して「$aa」をクラスAのインスタンスとして変数名候補の列挙などをしてくれます。フィルタ用の関数を作る ?phpfunction a2(array $a) { $a = filterA($a); foreach ($a as $aa) { var_dump($aa- name); * @param array $a * @return multitype:Afunction filterA(array $a) { $res = array(); foreach ($a as $aa) { if ($aa instanceof A) { $res[] = $aa; return $res;ポイントは、関数「filterA」のdocument comment内の「@return multitype:A」です。この関数を通してやることにより、戻り値がクラスAのインスタンスであることが一応保証されるので、Eclipse(PDT)をだますことができます。これを使って生成したテーブルがあるのだが、とある事情により、自動採番ではない形に変更する必要が生じた。うーん‥どうやって削除するんだ、これ?‥と悩み探して20分ほど。以下のページに助けられました。How to drop 'GENERATED ALWAYS' from column in V8.1 LUW プライベートでデータを蓄積しているDB2サーバーで、巨大なインデックスを作ろうとしたら、トランザクションログがいっぱいというエラーが発生しました。db2inst1@ubuntu14.04:~$ db2 CREATE INDEX idx_hoge_hogehoge ON hoge(hogehoge) DB21034E The command was processed as an SQL statement because it was not avalid Command Line Processor command. During SQL processing it returned:SQL0964C The transaction log for the database is full. SQLSTATE=57011db2inst1@ubuntu14.04:~$db2inst1@ubuntu14.04:~$ db2 get db cfg for HOGEHOGE | grep LOGCatalog cache size (4KB) (CATALOGCACHE_SZ) = 300Log buffer size (4KB) (LOGBUFSZ) = 256Log file size (4KB) (LOGFILSIZ) = 1024Number of primary log files (LOGPRIMARY) = 13Number of secondary log files (LOGSECOND) = 4Changed path to log files (NEWLOGPATH) =Path to log files = /home/db2inst1/db2inst1/NODE0000/SQL00002/SQLOGDIR/Overflow log path (OVERFLOWLOGPATH) =Mirror log path (MIRRORLOGPATH) =Block log on disk full (BLK_LOG_DSK_FUL) = NOBlock non logged operations (BLOCKNONLOGGED) = NOPercent max primary log space by transaction (MAX_LOG) = 0Num. of active log files for 1 active UOW(NUM_LOG_SPAN) = 0Log retain for recovery enabled (LOGRETAIN) = OFFFirst log archive method (LOGARCHMETH1) = OFFOptions for logarchmeth1 (LOGARCHOPT1) =Second log archive method (LOGARCHMETH2) = OFFOptions for logarchmeth2 (LOGARCHOPT2) =Log pages during index build (LOGINDEXBUILD) = OFFdb2inst1@ubuntu14.04:~$ db2inst1@ubuntu14.04:~$ db2 update db cfg for HOGEHOGE using LOGSECOND 4000 IMMEDIATESQL5130N The value specified for the configuration parameter logsecond isnot in the valid range of 0 to 254 .db2inst1@ubuntu14.04:~$ db2inst1@ubuntu14.04:~$ db2 update db cfg for HOGEHOGE using LOGSECOND 254 IMMEDIATESQL5153N The update cannot be completed because the following relationshipwould be violated: logprimary + logsecond = 256 .db2inst1@ubuntu14.04:~$ 結局、インスタンスを再起動する前提で、以下のように設定しました(元に戻しやすいように、それぞれ元の値の8倍)。db2inst1@ubuntu14.04:~$ db2 update db cfg for HOGEHOGE using LOGFILSIZ 8192DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.SQL1363W One or more of the parameters submitted for immediate modificationwere not changed dynamically. For these configuration parameters, allapplications must disconnect from this database before the changes becomeeffective.db2inst1@ubuntu14.04:~$ db2 update db cfg for HOGEHOGE using LOGPRIMARY 104DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.SQL1363W One or more of the parameters submitted for immediate modificationwere not changed dynamically. For these configuration parameters, allapplications must disconnect from this database before the changes becomeeffective.db2inst1@ubuntu14.04:~$ db2 update db cfg for HOGEHOGE using LOGSECOND 32DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.db2inst1@ubuntu14.04:~$ db2stopSQL1025N The database manager was not stopped because databases are still active.db2inst1@ubuntu14.04:~$ db2stop forceSQL1064N DB2STOP processing was successful.db2inst1@ubuntu14.04:~$ db2startSQL1063N DB2START processing was successful.db2inst1@ubuntu14.04:~$ db2 CREATE INDEX idx_hoge_hogehoge ON hoge(hogehoge) DB21034E The command was processed as an SQL statement because it was not avalid Command Line Processor command. During SQL processing it returned:SQL1224N The database manager is not able to accept new requests, hasterminated all requests in progress, or has terminated the specified requestbecause of an error or a forced interrupt. SQLSTATE=55032db2inst1@ubuntu14.04:~$ db2 CREATE INDEX idx_hoge_hogehoge ON hoge(hogehoge) DB21034E The command was processed as an SQL statement because it was not avalid Command Line Processor command. During SQL processing it returned:SQL1024N A database connection does not exist. SQLSTATE=08003db2inst1@ubuntu14.04:~$ db2 connect to HOGEHOGE Database Connection InformationDatabase server = DB2/LINUXX8664 9.7.5SQL authorization ID = DB2INST1Local database alias = HOGEHOGEdb2inst1@ubuntu14.04:~$ db2 CREATE INDEX idx_hoge_hogehoge ON hoge(hogehoge) echo 2020/02/07 08:07 ; dateDB20000I The SQL command completed successfully.db2inst1@ubuntu14.04:~$

TAGS:正道 HHeLiBeX 日記 

<<< Thank you for your visit >>>

Websites to related :
The Pattern Trader

  With regard to Yield Spreads,we’ve been monitoring the 3mth/10yr spread this week for the possibility of a first indication that a U.S. Recession ma

Kentucky Wildcats Football News

  Kentucky Wildcats Football News | Lexington Herald Leader Take Us With You Real-time updates and all local stories you want right in the palm of your

8capita

  We Fund Executable Ideas & Exceptional Talent. An Investment Partnership focused on Internet + Mobile Companies. Best suited to provide a bridge and b

. . .

  The Millions Most Anticipated of 2017.Buzzfeed s Exciting New Books.Nylon s Books You ll Want To Read This Summer.Nylon s Best Books of 2017, So Far.W

Mathematical Equations - EqWorld

  Equations play a crucial role in modern mathematics and form thebasis for mathematical modelling of numerous phenomena and processes inscience and eng

Integral Heart Family - Guatema

  Education is the heart of our work. Our school is home to 80 children receiving classes in Spanish, English, Psychology, Human Rights, Homework Help,

Technische fout

  Onze excuses voor het ongemak. Er is een automatische melding verstuurd naar de technische leverancier van [sitenaam]. Wij zullen de fout zo spoedig m

Integral Business Insights Inc.

  Business Consulting for SaaS StartupsIntegral is a highly specialized consultancy focused on creating partnerships with software developers who need a

Center for Integral Science

  Science comes from the Latin word to know. Integralmeans to be whole, comprehensive, and complete. The term Integral Science,thus, refers to a compreh

Integral Software Systems: Home

  "Integral cut my work in half with the new database they designed for the Portland Fire Fighters' Union Office. I sometimes feel like my requests can'

ads

Hot Websites