ha666_go运行环境配置

时间:2021-03-15 20:46:51

项目地址:http://git.oschina.net/ha666/ha666_go

服务器配置:

CPU: 1核
内存: 1024 MB
操作系统: CentOS 7.0 64位
内网IP: 10.171.231.48
带宽计费方式: 按使用流量
当前使用带宽: 带宽:66Mbps(峰值)

1、修改语言

  阿里云的ECS默认语言是:en_US.UTF-8,需要改成zh_CN.UTF-8

  修改方法:vim /etc/locale.conf,然后重启。

  查看方法:echo $LANG

2、安装ab(ApacheBench)

[root@iZ23n2t9gynZ ~]# yum install httpd-tools
已加载插件:langpacks
base                                                                    | 3.6 kB  00:00:00
epel                                                                    | 4.3 kB  00:00:00
extras                                                                  | 3.4 kB  00:00:00
updates                                                                 | 3.4 kB  00:00:00
(1/7): base/7/x86_64/group_gz                                           | 154 kB  00:00:00
(2/7): epel/x86_64/group_gz                                             | 169 kB  00:00:00
(3/7): epel/x86_64/updateinfo                                           | 368 kB  00:00:00
(4/7): extras/7/x86_64/primary_db                                       |  87 kB  00:00:00
(5/7): epel/x86_64/primary_db                                           | 3.6 MB  00:00:00
(6/7): base/7/x86_64/primary_db                                         | 5.1 MB  00:00:01
(7/7): updates/7/x86_64/primary_db                                      | 4.0 MB  00:00:01
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-31.el7.centos.1 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================================================
 Package                              架构                            版本                                            源                                大小
=============================================================================================================================================================
正在安装:
 httpd-tools                          x86_64                          2.4.6-31.el7.centos.1                           updates                           79 k

事务概要
=============================================================================================================================================================
安装  1 软件包

总下载量:79 k
安装大小:168 k
Is this ok [y/d/N]: y
Downloading packages:
httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm                                                                                          |  79 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                                                 1/1
  验证中      : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                                                 1/1 

已安装:
  httpd-tools.x86_64 0:2.4.6-31.el7.centos.1                                                                                                                 

完毕!

3、安装mysql

  先查看yum上提供的数据库可下载版本

[root@iZ23n2t9gynZ ~]# yum list | grep mysql
akonadi-mysql.x86_64                    1.9.2-4.el7                    base
apr-util-mysql.x86_64                   1.5.2-6.el7                    base
calligra-kexi-driver-mysql.x86_64       2.9.7-1.el7                    epel
collectd-mysql.x86_64                   5.5.0-2.el7                    epel
dmlite-plugins-mysql.x86_64             0.7.4-1.el7                    epel
dovecot-mysql.x86_64                    1:2.2.10-4.el7_0.1             base
dpm-copy-server-mysql.x86_64            1.8.10-1.el7                   epel
dpm-name-server-mysql.x86_64            1.8.10-1.el7                   epel
dpm-server-mysql.x86_64                 1.8.10-1.el7                   epel
dpm-srm-server-mysql.x86_64             1.8.10-1.el7                   epel
dspam-mysql.x86_64                      3.10.2-11.el7                  epel
exim-mysql.x86_64                       4.84-4.el7                     epel
freeradius-mysql.x86_64                 3.0.4-6.el7                    base
fts-mysql.x86_64                        3.3.1-3.el7                    epel
gnokii-smsd-mysql.x86_64                0.6.31-10.el7                  epel
holland-mysqldump.noarch                1.0.10-3.el7                   epel
holland-mysqllvm.noarch                 1.0.10-3.el7                   epel
lfc-server-mysql.x86_64                 1.8.10-1.el7                   epel
libdbi-dbd-mysql.x86_64                 0.8.3-16.el7                   base
libgda-mysql.x86_64                     1:5.1.2-2.el7.1                epel
libnss-mysql.x86_64                     1.5-19.el7                     epel
libodb-mysql.x86_64                     2.3.0-1.el7                    epel
libodb-mysql-devel.x86_64               2.3.0-1.el7                    epel
lighttpd-mod_mysql_vhost.x86_64         1.4.37-1.el7                   epel
mysql++.x86_64                          3.1.0-12.el7                   epel
mysql++-devel.x86_64                    3.1.0-12.el7                   epel
mysql++-manuals.x86_64                  3.1.0-12.el7                   epel
mysql-connector-java.noarch             1:5.1.25-3.el7                 base
mysql-connector-odbc.x86_64             5.2.5-6.el7                    base
mysql-connector-python.noarch           1.1.6-1.el7                    epel
mysql-proxy.x86_64                      0.8.5-2.el7                    epel
mysql-proxy-devel.x86_64                0.8.5-2.el7                    epel
mysql-utilities.noarch                  1.3.6-1.el7                    epel
mysqlreport.noarch                      3.5-11.el7                     epel
mysqltuner.noarch                       1.2.0-7.el7                    epel
nagios-plugins-mysql.x86_64             2.0.3-3.el7                    epel
nodejs-mysql.noarch                     2.3.2-1.el7                    epel
opendbx-mysql.x86_64                    1.4.6-6.el7                    epel
opensips-mysql.x86_64                   1.10.5-3.el7                   epel
owncloud-mysql.noarch                   8.0.8-1.el7                    epel
pdns-backend-mysql.x86_64               3.4.6-1.el7                    epel
perdition-mysql.x86_64                  2.1-2.el7                      epel
php-mysql.x86_64                        5.4.16-36.el7_1                updates
php-mysqlnd.x86_64                      5.4.16-36.el7_1                updates
php-pear-MDB2-Driver-mysql.noarch       1.5.0-0.8.b4.el7               epel
php-pear-MDB2-Driver-mysqli.noarch      1.5.0-0.8.b4.el7               epel
proftpd-mysql.x86_64                    1.3.5a-1.el7                   epel
qt-mysql.i686                           1:4.8.5-8.el7                  base
qt-mysql.x86_64                         1:4.8.5-8.el7                  base
qt5-qtbase-mysql.x86_64                 5.4.2-1.el7                    epel
redland-mysql.x86_64                    1.0.16-6.el7                   base
root-sql-mysql.x86_64                   5.34.32-3.el7                  epel
rsyslog-mysql.x86_64                    7.4.7-7.el7_0                  base
soci-mysql.x86_64                       3.2.3-1.el7                    epel
soci-mysql-devel.x86_64                 3.2.3-1.el7                    epel
voms-mysql-plugin.x86_64                3.1.6-5.el7                    epel
zabbix20-proxy-mysql.x86_64             2.0.15-1.el7                   epel
zabbix20-server-mysql.x86_64            2.0.15-1.el7                   epel
zabbix20-web-mysql.noarch               2.0.15-1.el7                   epel
zabbix22-dbfiles-mysql.noarch           2.2.10-1.el7                   epel
zabbix22-proxy-mysql.x86_64             2.2.10-1.el7                   epel
zabbix22-server-mysql.x86_64            2.2.10-1.el7                   epel
zabbix22-web-mysql.noarch               2.2.10-1.el7                   epel

  然后安装mariadb

[root@iZ23n2t9gynZ ~]# yum install mariadb mariadb-server
已加载插件:langpacks
软件包 1:mariadb-5.5.44-1.el7_1.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-server.x86_64.1.5.5.44-1.el7_1 将被 安装
--> 正在处理依赖关系 perl-DBI,它被软件包 1:mariadb-server-5.5.44-1.el7_1.x86_64 需要
--> 正在处理依赖关系 perl-DBD-MySQL,它被软件包 1:mariadb-server-5.5.44-1.el7_1.x86_64 需要
--> 正在处理依赖关系 perl(DBI),它被软件包 1:mariadb-server-5.5.44-1.el7_1.x86_64 需要
--> 正在检查事务
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-5.el7 将被 安装
---> 软件包 perl-DBI.x86_64.0.1.627-4.el7 将被 安装
--> 正在处理依赖关系 perl(RPC::PlServer) >= 0.2001,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在处理依赖关系 perl(RPC::PlClient) >= 0.2000,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在检查事务
---> 软件包 perl-PlRPC.noarch.0.0.2020-14.el7 将被 安装
--> 正在处理依赖关系 perl(Net::Daemon) >= 0.13,它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Test),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Log),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Zlib),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在检查事务
---> 软件包 perl-IO-Compress.noarch.0.2.061-2.el7 将被 安装
--> 正在处理依赖关系 perl(Compress::Raw::Zlib) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Raw::Bzip2) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
---> 软件包 perl-Net-Daemon.noarch.0.0.48-5.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 将被 安装
---> 软件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================================================
 Package                                        架构                          版本                                      源                              大小
=============================================================================================================================================================
正在安装:
 mariadb-server                                 x86_64                        1:5.5.44-1.el7_1                          updates                         11 M
为依赖而安装:
 perl-Compress-Raw-Bzip2                        x86_64                        2.061-3.el7                               base                            32 k
 perl-Compress-Raw-Zlib                         x86_64                        1:2.061-4.el7                             base                            57 k
 perl-DBD-MySQL                                 x86_64                        4.023-5.el7                               base                           140 k
 perl-DBI                                       x86_64                        1.627-4.el7                               base                           802 k
 perl-IO-Compress                               noarch                        2.061-2.el7                               base                           260 k
 perl-Net-Daemon                                noarch                        0.48-5.el7                                base                            51 k
 perl-PlRPC                                     noarch                        0.2020-14.el7                             base                            36 k

事务概要
=============================================================================================================================================================
安装  1 软件包 (+7 依赖软件包)

总下载量:12 M
安装大小:59 M
Is this ok [y/d/N]: y
Downloading packages:
(1/8): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                 |  32 kB  00:00:00
(2/8): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                  |  57 kB  00:00:00
(3/8): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                                                                                          | 140 kB  00:00:00
(4/8): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                | 802 kB  00:00:00
(5/8): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                          |  51 kB  00:00:00
(6/8): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                        | 260 kB  00:00:00
(7/8): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                            |  36 kB  00:00:00
(8/8): mariadb-server-5.5.44-1.el7_1.x86_64.rpm                                                                                       |  11 MB  00:00:02
-------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                         5.1 MB/s |  12 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                               1/8
  正在安装    : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                              2/8
  正在安装    : perl-IO-Compress-2.061-2.el7.noarch                                                                                                      3/8
  正在安装    : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                        4/8
  正在安装    : perl-PlRPC-0.2020-14.el7.noarch                                                                                                          5/8
  正在安装    : perl-DBI-1.627-4.el7.x86_64                                                                                                              6/8
  正在安装    : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                        7/8
  正在安装    : 1:mariadb-server-5.5.44-1.el7_1.x86_64                                                                                                   8/8
  验证中      : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                        1/8
  验证中      : 1:mariadb-server-5.5.44-1.el7_1.x86_64                                                                                                   2/8
  验证中      : perl-IO-Compress-2.061-2.el7.noarch                                                                                                      3/8
  验证中      : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                              4/8
  验证中      : perl-PlRPC-0.2020-14.el7.noarch                                                                                                          5/8
  验证中      : perl-DBI-1.627-4.el7.x86_64                                                                                                              6/8
  验证中      : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                               7/8
  验证中      : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                        8/8 

已安装:
  mariadb-server.x86_64 1:5.5.44-1.el7_1                                                                                                                     

作为依赖被安装:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7 perl-DBI.x86_64 0:1.627-4.el7
  perl-IO-Compress.noarch 0:2.061-2.el7        perl-Net-Daemon.noarch 0:0.48-5.el7         perl-PlRPC.noarch 0:0.2020-14.el7  

完毕!

  启动mariadb

[root@iZ23n2t9gynZ ~]# systemctl start mariadb

  开机自动启动

[root@iZ23n2t9gynZ ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

  设置root密码

[root@iZ23n2t9gynZ ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

  登录测试

[root@iZ23n2t9gynZ ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

4、安装redis

yum install -y tcl

wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

cd redis-stable

make

 cd src

 make test

  配置redis

cd /root/redis-stable

cp redis.conf /usr/local/bin

cd src

cp redis-server /usr/local/bin

cp redis-cli /usr/local/bin

  配置redis.conf(vim /usr/local/bin/redis.conf)

daemonize yes

port 26125

bind 127.0.0.1

# save 900 1

# save 300 10

# save 60 10000

maxclients 60000

maxmemory 500mb

  启动与客户端连接

[root@iZ23n2t9gynZ ~]# redis-server /usr/local/bin/redis.conf
[root@iZ23n2t9gynZ ~]# redis-cli -p 26125
127.0.0.1:26125> info
# Server
redis_version:3.0.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:8960fb2f771de35e
redis_mode:standalone
os:Linux 3.10.0-123.9.3.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.2
process_id:32538
run_id:2b0eb3b85cfcb8c3d37157e12756d6b0bcdcc467
tcp_port:26125
uptime_in_seconds:68
uptime_in_days:0
hz:10
lru_clock:2251601
config_file:/usr/local/bin/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:3416888
used_memory_human:3.26M
used_memory_rss:9699328
used_memory_peak:3416888
used_memory_peak_human:3.26M
used_memory_lua:36864
mem_fragmentation_ratio:2.84
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1445092109
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:2
total_commands_processed:2
instantaneous_ops_per_sec:0
total_net_input_bytes:42
total_net_output_bytes:3849
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.02
used_cpu_user:0.06
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
127.0.0.1:26125>

环境配置完了。