2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspbian OSからpipでのパッケージダウンロードや、httpsでのアクセスができないと思ったら時計ずれてただけだった話。

Posted at

タイトルまんま。なんかしらんけど、pipで変なエラー出る。

Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip in /usr/lib/python2.7/dist-packages
Downloading/unpacking pip
Cleaning up...
No distributions at all found for pip in /usr/lib/python2.7/dist-packages
Storing debug log for failure in /home/pi/.pip/pip.log

pip.logを見ると、connection errorとか出てる。
curlやwgetでhttpsに接続しても

curl: (60) SSL certificate problem: certificate is not yet valid
More details here: http://curl.haxx.se/docs/sslcerts.html

のように出る。apt-get install --reinstall ca-certificates しても、状況は変わらない。

なんじゃこりゃ! ってことで、さんざん調べたら、日時が全然合っていなかったのが原因らしい。
時計の初期設定をし忘れていたのが原因で、あと、ラズパイはハードウェアクロック持ってないから、起動時の時刻は前回システム終了時の時刻になるみたい。
ntpdは動いてるんだけど、ntpdって、全くトチ狂ってる時計を合わせるのが目的じゃなくて、あくまで微調整のため、ちょっとずつ合わせる、みたいなことをしているらしく、こういうときには役に立たない。

そこで。とれる方法が。

  1. 手動で時計合わせ
    sudo date -s "Oct 2 13:05 JST 2016"
  2. ntpdateで時計合わせ sudo service ntp stop ; sudo apt-get install ntpdate ; sudo ntpdate -s -b -u ntp.nict.jp ; sudo service ntp start

さらに。どうせなら起動時に同期したいよねって思って、調べてみた。
起動時、ネットワークを立ち上げる段階でntpdateを呼んでるようなので(/etc/network/if-up.d/ntpdate)、そいつが呼んでいる/usr/sbin/ntpdate-debianというシェルスクリプトが参照している/etc/default/ntpdateを編集する。

ntpdate
NTPDATE_USE_NTP_CONF=no
NTPSERVER="ntp.nict.jp"
NTPOPTIONS="-s -b -u"

これで再起動してみても、なぜか時刻更新されている気配がなかった。syslogみた感じ、dhcpcdより先にこのスクリプトが動いてNTPサーバにアクセスできてない?
仕方ないので、/etc/init.d/ntpをちょっと変えてみた。

/etc/init.d/ntp
start)
        #略
        lock_ntpdate
        ntpdate-debian  # この行を追加
        start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas #DAEMON -- -p $PIDFILE $NTPD_OPTS
        # 略

なんとなくうまくいってそうな雰囲気。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?