星期二, 12月 08, 2020

NOR1

MOSQUITTO1 yum install epel-release yum install libwebsockets #epel套件 yum install mosquitto vi mosquitto.conf #mqtt 服務 port port 1883 #以下二行為啟用mqtt 的 websockets port (給javascript用) listener 1893 protocol websockets persistence false persistence_location /var/lib/mosquitto/ allow_anonymous true #存檔 #測試 mosquitto -c /etc/mosquitto/mosquitto.conf #服務啟動 systemctl start mosquitto #開機啟動 syetemctl enable mosquitto #註服務log檔是記在 /var/log/messages 中。 postgresql yum install epel-release #連上官網,選擇OS, 版本等即可得到如鑑指令 dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm dnf -qy module disable postgresql dnf install -y postgresql13-server /usr/pgsql-13/bin/postgresql-13-setup initdb systemctl enable postgresql-13 systemctl start postgresql-13 www1 安裝anaconda #目前是python 3.8.5 conda create --name py3.8 python=3.8 vi ~/.bashrc #最後加上一行 source activate py3.8 #登出/登入 看看命令提示字元前面是否有(py3.8)字樣,有就正常。 conda install numpy conda install scipy conda install matplotlib conda install netcdf4 conda install pandas conda install pytz conda install python-dateutil conda install django # gdal conda install -c conda-forge gdal # 有些軟體版本會降 conda install -c conda-forge postgis # 有些軟體版本會降(包含gdal, 所以上面gdal應該不用裝 ) #安裝apache

星期一, 1月 13, 2020

centos 8

終於等到centos 8,是該準備做系統升級與搬移的事了
yum update
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf config-manager --set-enabled PowerTools # 執行這個指令才能裝netcdf,不然會有如下錯誤訊息。(qhull lapack也在PwoerTools裏)
# 註,如果上述指令失敗,可以試著改 vi /etc/yum.repos.d/CentOS-Linux-PowerTools.repo 這個檔案,修改裏面的 enabled=1。
Error: 
 Problem: conflicting requests
  - nothing provides libsz.so.2()(64bit) needed by netcdf-devel-4.7.0-2.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
dnf install redhat-rpm-config #不知道安裝什麼,出現如下的錯誤,如果遇到了,就執行這個指令。
gcc: 錯誤:/usr/lib/rpm/redhat/redhat-hardened-cc1: 沒有此一檔案或目錄
    error: command 'gcc' failed with exit status 1
安裝基本套件,先裝後裝八成都要裝。也可以事後遇到有缺再補裝。
yum install cmake.x86_64 httpd php git.x86_64 gcc.x86_64 libxml2-devel.x86_64 json-c-devel.x86_64 proj-devel.x86_64 zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel tcl-devel gdbm-devel libpcap-devel xz-devel lapack-devel.x86_64 qhull-devel.x86_64 libpng-devel.x86_64 gcc-c++.x86_64 netcdf-devel.x86_64 libjpeg-turbo-devel.x86_64 libffi-devel
# libffi-devel 是安裝jupyter 或 psycopg2等套件時,需要的,如果沒裝會有如下錯誤
ModuleNotFoundError: No module named '_ctypes'
# 重點是裝完libffi-devel之後python要重新make install 才行!!!!
# 這些套件目前yum沒有的裝 GMT-devel.x86_64 proj-epsg.x86_64 libdb4-devel agg-devel.x86_64
找不到make這個指令,可用如下指令找出是哪個套件
yum provides \*/bin/make

安裝python 3.8

CentOS 8 之後有提供python3.6,如果有安裝,為免麻煩,就先移除了吧…
yum remove python3

#export mypyenv=3.6.5;
export mypyenv=3.8.3;
wget https://www.python.org/ftp/python/"$mypyenv"/Python-"$mypyenv".tgz
tar zxvf Python-"$mypyenv".tgz
cd Python-"$mypyenv"/
export LDFLAGS=-L/usr/lib64;./configure --prefix=/opt/python"$mypyenv"  --enable-shared --enable-optimizations
make
make test
#如果順利沒有報錯,就進行下一步
make install
#設定python3 的環境變數
vi /etc/profile.d/pythonvar.sh
#! /bin/bash
PYTHON3=/opt/python3.8.2
if [ -z "${PATH}" ]
then
    PATH="$PYTHON3/bin"; export PATH
else
    PATH="${PATH}:$PYTHON3/bin"; export PATH
fi
if [ -z "${MANPATH}" ]
then
    MANPATH="$PYTHON3/share/man"; export MANPATH
else
    MANPATH="$PYTHON3/share/man:${MANPATH}"; export MANPATH
fi

if [ -z "${LIBRARY_PATH}" ]
then
    LIBRARY_PATH="$PYTHON3/lib"; export LIBRARY_PATH
else
    LIBRARY_PATH="$PYTHON3/lib:${LIBRARY_PATH}"; export LIBRARY_PATH
fi

if [ -z "${LD_LIBRARY_PATH}" ]
then
    LD_LIBRARY_PATH="$PYTHON3/lib"; export LD_LIBRARY_PATH
else
    LD_LIBRARY_PATH="$PYTHON3/lib:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH
fi
不知道從啥時開始,pip3 可以用一般的使用者安裝套件,只要後面加上--user,但這應該是裝在使用者的家目錄下的.local資料夾中。 一般使用者用pip3 install --upgrade pip --user,會把pip搞掛。解決方法是把家目錄下的.local資料夾移除…但不知道有啥影響。
pip3 install numpy 
pip3 install scipy 
pip3 install matplotlib
pip3 install netcdf4 
pip3 install pandas 
pip3 install pillow 
pip3 install pytz 
pip3 install python-dateutil 
# python GDAL 這個必需要跟系統裏的gdal版本一致(如果有裝多版本,還需確定是不是正確連結lib)
pip3 install --global-option=build_ext --global-option=`gdal-config --cflags`  GDAL==`gdal-config --version`

安裝postgresql 12


dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf --disablerepo AppStream install postgresql12-server postgresql12-contrib postgresql12-devel #需要加--disablerepo AppStream
dnf install postgis30_12-devel  #不需要加--disablerepo AppStream
dnf install geos38-devel-3.8.0-1.rhel8.x86_64
pip3 install psycopg2-binary