yum
インストールを正常に実行できるリポジトリ定義ファイルを生成するために、以下のbashスクリプトをどのように取得できますかmongodb
?
ご覧のとおり、現在のバージョンのスクリプトでエラーが発生しており、以下の内容を読むことができます。
現在のbashスクリプトの関連部分は次のとおりです。
echo "[STARTING TASK 4: Install MongoDB]"
echo "... About to create the repo file with a cat command ..."
cat >/etc/yum.repos.d/mongodb-org.repo <<EOL
line 1, [mongodb-org-3.4]
line 2, name=MongoDB Repository
line 3, baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
line 4, gpgcheck=1
line 5, enabled=1
line 6, gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
line 7 line
...
EOL
echo "... About to confirm with yum repolist"
yum repolist
echo "... About to yum -y install mongodb-org"
yum -y install mongodb-org
echo "... About to systemctl start mongod"
systemctl start mongod
スクリプトが実行されると、コンソール出力は次のようになります。
build 18-Dec-2017 17:09:07 [STARTING TASK 4: Install MongoDB]
build 18-Dec-2017 17:09:07 ... About to create the repo file with a cat command ...
build 18-Dec-2017 17:09:07 ... About to confirm with yum repolist
build 18-Dec-2017 17:09:07 Loaded plugins: fastestmirror, langpacks
error 18-Dec-2017 17:09:07
error 18-Dec-2017 17:09:07
error 18-Dec-2017 17:09:07 File contains no section headers.
error 18-Dec-2017 17:09:07 file: file:///etc/yum.repos.d/mongodb-org.repo, line: 1
error 18-Dec-2017 17:09:07 'line 1, [mongodb-org-3.4]\n'
build 18-Dec-2017 17:09:07 ... About to yum -y install mongodb-org
build 18-Dec-2017 17:09:07 Loaded plugins: fastestmirror, langpacks
error 18-Dec-2017 17:09:07
error 18-Dec-2017 17:09:07
error 18-Dec-2017 17:09:07 File contains no section headers.
error 18-Dec-2017 17:09:07 file: file:///etc/yum.repos.d/mongodb-org.repo, line: 1
error 18-Dec-2017 17:09:07 'line 1, [mongodb-org-3.4]\n'
build 18-Dec-2017 17:09:07 ... About to systemctl start mongod
error 18-Dec-2017 17:09:07 Failed to start mongod.service: Unit not found.
ご覧のように、エラーはスクリプトが/etc/yum.repos.d/mongodb-org.repo
。
ベストアンサー1
問題を解決する最も短い方法は、コードを再生成することです。
cat >/etc/yum.repos.d/mongodb-org.repo <<EOL
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOL
これにより、不要なテキストは印刷されません。 7行目以降は何があるのかわかりませんが、先頭の「line...」テキストを削除するアイデアを進めます。