在centos7上安装夜莺监控2.7.2
所需包(仅作参考)
在 /opt 目录下建立目录 /n9e 和 /temp
安装包存放在 /opt/temp 目录下
mysql-5.7.31-linux-glibc2.12-x86_64.7z
nginx-1.14.2.7z
p7zip-16.02-10.el7.x86_64.rpm
redis-6.0.6.7z
n9e-2.7.2.7z
1.安装7z
rpm -ivh p7zip-16.02-10.el7.x86_64.rpm
yum -y install epel-release
yum -y install p7zip p7zip-plugins
解压命令 7za x *****.7z -o/解压目录
2.安装mysql
7za x mysql-5.7.31-linux-glibc2.12-x86_64.7z -o/opt/n9e
cd /opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/
以下操作在解压后的/opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/目录下
#根据情况修改conf/my.cnf,比如datadir(数据存放位置)
创建errmsg.sys,防止初始化报错
mkdir -p logs/error_message/
cp -a share/english/errmsg.sys logs/error_message/ #cp -a 保留源文件属性;cp -r dirname(源文件) destdi(目标文件)复制目录后其文件属性会发生变化
数据库初始化,并找到root随机密码记下(最后一行)例如:DQ_ilnDOI8Nc #如果初始化失败,执行 yum install -y libaio
./bin/mysqld –defaults-file=conf/my.cnf –initialize #初始化
root用户启动 nohup ./bin/mysqld –defaults-file=conf/my.cnf –user=root &
进入数据库 ./bin/mysql -uroot -p
#####如果无法登录,查看防火墙是否关闭了3306端口,打开命令
firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –reload
############################
输入初始化得到的随机密码
修改密码 ALTER USER \’root\’@\’localhost\’ IDENTIFIED WITH mysql_native_password BY \’密码\’;
刷新权限 FLUSH PRIVILEGES;
&&&&&&&&&&&&&&&&&&&&&&&&&&
持久修改mysql提示符
[root@centos8 ~]#vim /etc/my.cnf.d/mysql-clients.cnf
[mysql]
prompt=”\\r:\\m:\\s(\\u@\\h) [\\d]>\\_”
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3.编译安装nginx
安装 gcc 和 gcc-c++
yum -y install gcc gcc-c++
解压nginx包 7za x nginx-1.14.2.7z -o. (解压到temp文件夹)
cd nginx-1.14.2/
cd nginx-1.14.2/
编译安装,替换<安装目录>
./configure –prefix=/opt/n9e/nginx-1.14.2 –with-stream –with-http_stub_status_module –with-http_realip_module –with-http_ssl_module –with-http_gzip_static_module –with-pcre=../dependencies/pcre-8.38 –with-zlib=../dependencies/zlib-1.2.11 –with-openssl=../dependencies/openssl-1.1.1a
多核编译
make -j 4
make install
4.安装redis
7za x redis-6.0.6.7z -o/opt/n9e
cd /opt/n9e/redis-6.0.6/conf
vim redis.conf 修改redis密码,将requirepass redis修改为requirepass 密码
切换到上级目录cd /opt/n9e/redis-6.0.6 ; 非阻塞式启动 nohup ./bin/redis-server conf/redis.conf &
登陆验证 ./bin/redis-cli
5.安装夜莺
7za x n9e-2.7.2.7z -o/opt/n9e
cd /opt/n9e/n9e-2.7.2/
导入数据库 sql里面存放的 n9e_hbs.sql n9e_mon.sql n9e_uic.sql 三个文件
[root@centos7 n9e-2.7.2]$ /opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/bin/mysql -p < sql/n9e_hbs.sql
Enter password: Mysql数据库的密码
[root@centos7 n9e-2.7.2]$ /opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/bin/mysql -p < sql/n9e_mon.sql
Enter password:
[root@centos7 n9e-2.7.2]$ /opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/bin/mysql -p < sql/n9e_uic.sql
Enter password:
导入netsec_pure11.23.sql文件到Mysql
首先创建数据库netsec
>use mysql;
>create database netsec;
>exit
/opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/bin/mysql -p netsec < netsec_pure11.23.sql
切换到etc文件夹下 cd etc/ 修改配置文件
[root@centos7 etc]$ vim mysql.yml
—
uic:
addr: “netsec:netsec@tcp(127.0.0.1:3306)/n9e_uic?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
mon:
addr: “netsec:netsec@tcp(127.0.0.1:3306)/n9e_mon?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
hbs:
addr: “netsec:netsec@tcp(127.0.0.1:3306)/n9e_hbs?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
将netsec:netsec全部改成 root:mysql密码
uic:
addr: “root:120604@tcp(127.0.0.1:3306)/n9e_uic?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
mon:
addr: “root:120604@tcp(127.0.0.1:3306)/n9e_mon?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
hbs:
addr: “root:120604@tcp(127.0.0.1:3306)/n9e_hbs?charset=utf8&parseTime=True&loc=Asia%2FShanghai”
max: 16
idle: 4
debug: false
vim judge.yml
将 pass: netsec 修改为 pass:数据库密码 ###注意之间空格别删了
vim monapi.yml
将 pass: netsec 修改为 pass:vim 数据库密码 ###注意之间空格别删了
vim nginx.conf (可在这一步修改端口)
修改 root /opt/nightingale/n9e-2.7.2/pub; 为 root /opt/n9e/n9e-2.7.2/pub;
mkdir -p /var/log/nginx
touch /var/log/nginx/error.log
cp -a /opt/n9e/nginx-1.14.2/conf/ /etc/nginx/
/opt/n9e/nginx-1.14.2/sbin/nginx -c /opt/n9e/n9e-2.7.2/etc/nginx.conf
curl 127.0.0.1:8080 测试一下
./control start all 启动 (./control status查看状态)
6.打开监控
在网址栏输入 本机ip:8080 回车打开夜莺监控
用户 root 密码 root
附:
实际生产中防火墙一般开启,可能无法打开监控,这时检查8080端口是否关闭
开启防火墙8080端口 firewall-cmd –zone=public –add-port=8080/tcp –permanent
firewall-cmd –reload
[root@centos7 n9e-2.7.2]$ firewall-cmd –zone=public –add-port=8080/tcp –permanent
success
[root@centos7 n9e-2.7.2]$ firewall-cmd –reload
success
firewall-cmd –permanent –add-rich-rule=”rule family=”ipv4″ source address=”10.0.0.1″ port protocol=”tcp” port=”8081″ accept” 限制只有10.0.0.1 ip才能访问本机8081端口
firewall-cmd –permanent –remove-rich-rule=”rule family=”ipv4″ source address=”10.0.0.1″ port protocol=”tcp” port=”8081″ accept” 移除该条规则
firewall-cmd –reload
# firewall-cmd –list-all 查看已开发的端口
# firewall-cmd –zone=public –remove-port=2222/tcp –permanent 移除已放行的端口号,如2222
附:
关闭服务后需要重新打开
mysql nohup ./bin/mysqld –defaults-file=conf/my.cnf –user=root &
redis nohup ./bin/redis-server conf/redis.conf &
nginx /opt/n9e/nginx-1.14.2/sbin/nginx -c /opt/n9e/n9e-2.7.2/etc/nginx.conf (记得修改nginx.conf配置文件)
n9e ./control start all
##############################################################################
#!/bin/bash
(cd /opt/n9e/mysql-5.7.31-linux-glibc2.12-x86_64/;nohup ./bin/mysqld –defaults-file=conf/my.cnf –user=root &)
(cd /opt/n9e/redis-6.0.6/;nohup ./bin/redis-server conf/redis.conf &)
(cd /opt/n9e/nginx-1.14.2/;/opt/n9e/nginx-1.14.2/sbin/nginx -c /opt/n9e/n9e-2.7.2/etc/nginx.conf)
(cd /opt/n9e/n9e-2.7.2/;./control start all)
firewall-cmd –zone=public –add-port=8080/tcp –permanent
firewall-cmd –reload
################################################################################