Bandwidthd+Postgresql数据库配置笔记

Bandwidthd+Postgresql数据库配置笔记


本系列文章由ex_net(张建波)编写,转载请注明出处。

http://blog.csdn.net/zjianbo/article/details/16717625

作者:张建波 邮箱: 281451020@qq.com 电话:13577062679 欢迎来电交流!

一、安装前的准备工作

        (1)安装前请参考http://blog.csdn.net/zjianbo/article/details/16623879,了解Postgresql数据库的安装配置。

        (2)创建 bandwidthd-pgsql 账号,该账户用来让Bandwidthd登录Postgresql数据库的


root@ubuntu:~# su - postgres
postgres@ubuntu:~$ psql
psql (9.1.9)
Type "help" for help.

postgres=# CREATE USER bandwidthdpgsql;
CREATE ROLE
postgres=# ALTER USER bandwidthdpgsql PASSWORD '123456';
ALTER ROLE
postgres=# \q
postgres@ubuntu:~$ exit
logout
root@ubuntu:~# 


        (3)创建数据库

                   create database bandwidthdpgsql;

                  和第(2)步一样,还是用 su - postgres登录后执行

            说明:

                       在Ubuntu下,不需要用 schema.postgresql 这个脚本创建表了。这一点和用源码安装方式有点不一样,可能是Ubuntu实在是考虑的比较周全把。


二、安装Bandwidthd软件包

      apt-get install bandwidthd-pgsql 







     


三、稍微修改Bandwidthd配置文件即可

       vi /etc/bandwidthd/bandwidthd.conf


       /etc/init.d/bandwidthd restart    #重启bandwidthd服务

       启动后2~3分钟,用pgadmin工具看看数据库,就可以可能到数据了。



四、配置php页面

        vi /etc/bandwidthd/debian-db.php 

例如:

$dbuser='bandwidthdpgsql';
$dbpass='123456';
$basepath='';
$dbname='bandwidthdpgsql';
$dbserver='localhost';
$dbport='5432';
$dbtype='pgsql';


       将Bandwidthd的php站点添加到apache里面

      vi /etc/apache2/conf.d/bandwidthd

Alias /bandwidthd /var/lib/bandwidthd/htdocs

<Directory /var/lib/bandwidthd/htdocs>

DirectoryIndex index.php
AllowOverride None

order deny,allow
deny from all
#allow from 127.0.0.0/255.0.0.0 ::1/128
allow from all

<IfModule mod_php5.c>
  php_flag magic_quotes_gpc Off
  php_flag track_vars On
  php_value include_path .
</IfModule>
<IfModule !mod_php5.c>
  <IfModule mod_actions.c>
    <IfModule mod_cgi.c>
      AddType application/x-httpd-php .php
      Action application/x-httpd-php /cgi-bin/php
    </IfModule>
    <IfModule mod_cgid.c>
      AddType application/x-httpd-php .php
      Action application/x-httpd-php /cgi-bin/php
    </IfModule>
  </IfModule>
</IfModule>

</Directory>

敲入上面的配置信息,当然,你可以用 phppgadmin的配置文件作为范本,cp一个出来修改哈即可。

       

这2步完成后,重启apache即可

/etc/init.d/apache2 restart



打开浏览器,选择你的传感器后,你就可以看到流量信息了。。。。

例如:http://192.168.1.4/bandwidthd/sensors.php



五、如果有不清楚的地方,用  man bandwidthd 看看

FILES
       /usr/sbin/bandwidthd               - daemon binary.
       /etc/init.d/bandwidthd             - startscript.
       /etc/bandwidthd/bandwidthd.conf    - configuration file.
       /var/run/bandwidthd.pid            - main process id file.
       /var/lib/bandwidthd/               - log directory.
       /var/lib/bandwidtd/htdocs/         - html and graphs output directory.


六、如果还有不明白的地方,推荐你看看下面的资料

(1) Ubuntu 12.04环境下配置Postgresql和phppgadmin   http://blog.csdn.net/zjianbo/article/details/16623879

(2)Bandwidthd完整实战笔记_1  http://blog.csdn.net/zjianbo/article/details/15026111

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,关于mybatis plus和postgresql配置,可以按照以下步骤进行: 1. 在项目中引入mybatis plus和postgresql的依赖,例如: ```xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.2</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.16</version> </dependency> ``` 2. 在application.properties(或者application.yaml)中配置数据库的连接信息,例如: ```properties spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.username=myuser spring.datasource.password=mypassword # mybatis plus 配置 mybatis-plus.mapper-locations=classpath*:mapper/**/*.xml mybatis-plus.type-aliases-package=com.example.entity # 开启驼峰命名转换 mybatis-plus.configuration.map-underscore-to-camel-case=true ``` 3. 在实体类上使用相关注解,例如: ```java @Data @NoArgsConstructor @AllArgsConstructor @TableName("user") public class User { @TableId(type = IdType.AUTO) private Long id; private String name; private Integer age; } ``` 4. 在mapper接口中继承BaseMapper类,并定义自己的方法,例如: ```java @Mapper public interface UserMapper extends BaseMapper<User> { // 自定义查询方法 List<User> findByName(String name); } ``` 这样就可以轻松使用mybatis plus和postgresql进行数据操作了。希望对你有帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值