linux环境:ubuntu18.04
1. 安装node.js16.14
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/
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 追加配置到配置文件
node -e "console.log(\"GENIEACS_UI_JWT_SECRET=\" + require('crypto').randomBytes(128).toString('hex'))" >> /opt/genieacs/genieacs.env
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 添加fs自启动文件
# 内容如下 [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 {dailyrotate 30compressdelaycompressdateext }
4.13 启动相关服务
sudo systemctl enable genieacs-cwmp sudo systemctl start genieacs-cwmp sudo systemctl status genieacs-cwmpsudo systemctl enable genieacs-nbi sudo systemctl start genieacs-nbi sudo systemctl status genieacs-nbisudo systemctl enable genieacs-fs sudo systemctl start genieacs-fs sudo systemctl status genieacs-fssudo 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/