linux環境:ubuntu18.04
1. 安裝node.js16.14
1.1 下載並安裝
wget https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.xz tar -Jxvf node-v16.14.2-linux-x64.tar.xz sudo mv node-v16.14.2-linux-x64/ /opt/ sudo ln -s /opt/node-v16.14.2-linux-x64/bin/node /usr/local/bin/ sudo ln -s /opt/node-v16.14.2-linux-x64/bin/npm /usr/local/bin/
1.2 修改npm源
sudo npm config delete registry sudo npm config set registry https://registry.npmmirror.com
2. 檢視node版本
node --version
3. 安裝mongodb
3.1 下載mongodb6.0.16
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-6.0.16.tgz tar -zxvf mongodb-linux-x86_64-ubuntu1804-6.0.16.tgz sudo mv mongodb-linux-x86_64-ubuntu1804-6.0.16 /opt/ mkdir /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/data mkdir /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/logs
3.2 新增配置檔案
vim /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/bin/mongodb.conf # 內容如下 dbpath = /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/data #資料檔案存放目錄 logpath = /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/logs/mongodb.log #日誌檔案存放目錄 port = 27017 #埠號 fork = true #以守護程式的方式啟用,即在後臺執行 #auth=true #是否需要登入認證,配置賬號密碼需要開啟,這裡註釋掉 noauth=true #不啟用驗證 storageEngine=wiredTiger #儲存引擎有mmapv1、wiretiger、mongorocks bind_ip=0.0.0.0 #這樣就可外部訪問了,例如從win10中去連虛擬機器中的MongoDB
3.3 配置環境變數
sudo vim /etc/profile # 在最後一行新增內容如下 export PATH=/opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/bin:$PATH
3.4 載入環境變數
source /etc/profile
3.5 新增到自啟動:
3.5.1 修改/lib/systemd/system/rc-local.service,在最後新增以下內容
[Install] WantedBy=multi-user.target Alias=rc-local.service
3.5.2 複製檔案
sudo cp /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
3.5.3 設定開機啟動
sudo systemctl enable rc-local
3.5.4 新增開機啟動指令碼/etc/rc.local並賦權
touch /etc/rc.local chmod 755 /etc/rc.local
3.5.5 /etc/rc.local內容如下:
#!/bin/bash /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/bin/mongod -f /opt/mongodb-linux-x86_64-ubuntu1804-6.0.16/bin/mongodb.conf
3.5.6 使用systemctl start rc-local或重啟即可
3.6 測試安裝是否成功
ps -ef |grep mongdb
3.6.1 若有以下截圖說明安裝成功
4. 安裝genieacs
4.1 安裝genieacs
sudo npm install -g genieacs@1.2.13
4.2 新增genieacs使用者
sudo useradd --system --no-create-home --user-group genieacs
4.3 建立相關目錄
sudo mkdir /opt/genieacs sudo mkdir /opt/genieacs/ext sudo chown genieacs:genieacs /opt/genieacs/ext
4.4 新增配置檔案
sudo vim /opt/genieacs/genieacs.env # 內容如下 GENIEACS_CWMP_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-cwmp-access.log GENIEACS_NBI_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-nbi-access.log GENIEACS_FS_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-fs-access.log GENIEACS_UI_ACCESS_LOG_FILE=/var/log/genieacs/genieacs-ui-access.log GENIEACS_DEBUG_FILE=/var/log/genieacs/genieacs-debug.yaml NODE_OPTIONS=--enable-source-maps GENIEACS_EXT_DIR=/opt/genieacs/ext
4.5 追加配置到配置檔案
sudo su
node -e "console.log(\"GENIEACS_UI_JWT_SECRET=\" + require('crypto').randomBytes(128).toString('hex'))" >> /opt/genieacs/genieacs.env
exit
4.6 修改檔案許可權
sudo chown genieacs:genieacs /opt/genieacs/genieacs.env sudo chmod 600 /opt/genieacs/genieacs.env
4.7 建立日誌檔案目錄
sudo mkdir /var/log/genieacs sudo chown genieacs:genieacs /var/log/genieacs
4.8 新增cwmp自啟動檔案
sudo vim /etc/systemd/system/genieacs-cwmp.service # 內容如下 [Unit] Description=GenieACS CWMP After=network.target [Service] User=genieacs EnvironmentFile=/opt/genieacs/genieacs.env ExecStart=/usr/bin/genieacs-cwmp [Install] WantedBy=default.target
4.9 新增nbi自啟動檔案
sudo vim /etc/systemd/system/genieacs-nbi.service
# 內容如下 [Unit] Description=GenieACS NBI After=network.target [Service] User=genieacs EnvironmentFile=/opt/genieacs/genieacs.env ExecStart=/usr/bin/genieacs-nbi [Install] WantedBy=default.target
4.10 新增fs自啟動檔案
sudo vim /etc/systemd/system/genieacs-fs.service # 內容如下 [Unit] Description=GenieACS FS After=network.target [Service] User=genieacs EnvironmentFile=/opt/genieacs/genieacs.env ExecStart=/usr/bin/genieacs-fs [Install] WantedBy=default.target
4.11 新增ui自啟動檔案
sudo vim /etc/systemd/system/genieacs-ui.service # 內容如下 [Unit] Description=GenieACS UI After=network.target [Service] User=genieacs EnvironmentFile=/opt/genieacs/genieacs.env ExecStart=/usr/bin/genieacs-ui [Install] WantedBy=default.target
4.12 修改日誌相關
sudo vim /etc/logrotate.d/genieacs # 新增內容如下 /var/log/genieacs/*.log /var/log/genieacs/*.yaml { daily rotate 30 compress delaycompress dateext }
4.13 啟動相關服務
sudo systemctl enable genieacs-cwmp sudo systemctl start genieacs-cwmp sudo systemctl status genieacs-cwmp sudo systemctl enable genieacs-nbi sudo systemctl start genieacs-nbi sudo systemctl status genieacs-nbi sudo systemctl enable genieacs-fs sudo systemctl start genieacs-fs sudo systemctl status genieacs-fs sudo systemctl enable genieacs-ui sudo systemctl start genieacs-ui sudo systemctl status genieacs-ui
5. 訪問genieacs
http://ip:3000/
6 cwmp填寫的url
http:ip:7547/